Skip to content
Compare
Choose a tag to compare
@zadlg zadlg released this 19 Feb 18:29
· 1 commit to main since this release
ef6c384

gnumake v0.1

This is the very first release of rules_gnumake for Buck2.

Features

  • Custom compiler flags (both CC and CXX)
    • compiler_flags = list[arg]
  • Custom platform-specific compiler flags
    • platform_compiler_flags = tuple[regex, list]
  • Custom install prefix (default: install/)
    • install_prefix = str
  • Custom Makefile entrypoint (default: Makefile)
    • makefile = str
  • Specifying the subdirectory of the install prefix that contains the executable binaries (default: bin/)
    • out_bin_dir = str
  • Specifying the subdirectory of the install prefix that contains the shared and static libraries (default: lib/)
    • out_lib_dir = str
  • Specifying the subdirectory of the install prefix that contains the public headers (default: include/)
    • out_include_dir = str
  • Specifying filenames of shared libraries being built
    • out_shared_libs = list[str]
  • Specifying filenames of static libraries being built
    • out_static_libs = list[str]
  • Specifying filenames of executable binaries being built
    • out_binaries = list[str]
  • Specifying targets to build
    • targets = list[str]

See the documentation of gnumake rule for more information.

Quick example

load("@gnumake//gnumake:rules.bzl", "gnumake")

http_archive(
    name = "mylib_ar",
    urls = ["https://example.com/mylib.tar.gz"],
    sha256 = "abc123…",
)

gnumake(
    name = "mylib_build",
    srcs = [":mylib_ar"],
    out_static_libs = ["mylib.a"],
    out_include_dir = "include",
)

prebuilt_cxx_library(
    name = "mylib",
    import_lib = ":mylib_build[mylib.a]",
    header_dirs = [":mylib_build[include]"],
)

Setting up the rules

Importing into existing Buck2 project

Clone this repository under a specific directory:

$ git clone -b v0.1 'https://github.com/zadlg/buck2_rules_gnumake.git' vendor/rules_gnumake

Then, declare the directory as a cell by adding the following line to your .buckconfig file, under the repositories section:

[repositories]
gnumake = vendor/rules_gnumake

Finally, add the following under the parser section of your .buckconfig file:

[parser]
target_platform_detector_spec = target:gnumake//...->prelude//platforms:default

Loading the toolchain

# BUCK file
load("@gnumake//gnumake:gnumake.bzl", "gnumake_toolchain")

gnumake_toolchain(
    name = "gnumake",
    visibility = ["PUBLIC"],
)

Importing the gnumake rule

# BUCK file
load("@gnumake//gnumake:rules.bzl", "gnumake")

gnumake(
    name = "mylib",
    srcs = glob(["Makefile", "*.c", "*.h"]),
    compiler_flags = ["-DENABLE_MY_FEATURE"],
    out_static_libs = ["mylib.a"],
    out_include_dir = "include",
    out_shared_libs = ["mylib.so"],
)

Thanks @lfousse for reviewing everything.

What's Changed

  • Add a GitHub Actions job for integration tests. by @zadlg in #3
  • Add a GitHub Actions job for testing on linux-x86_64. by @zadlg in #2
  • Add CODEOWNERS by @zadlg in #4
  • Fix #5: declare gnumake executable. by @zadlg in #7
  • Implement gnumake rule with simple arguments. by @zadlg in #1
  • Fix #8: symlink all sources using actions.symlinked_dir. by @zadlg in #9
  • Fix #6: use c and cxx flags from the current cxx toolchain. by @zadlg in #10
  • Fix #13: add makefile attribute to gnumake. by @zadlg in #15
  • Fix #12: support platform-specific compiler flags. by @zadlg in #16
  • Update the README.md with additional information. by @zadlg in #18
  • Fix #14: generate starlark documentation using buck2 doc. by @zadlg in #21
  • Use composite action to fetch Buck2 binaries in GitHub Actions. by @zadlg in #22
  • Fix #11: create the install directory within the rule. by @zadlg in #17
  • Upgrade zadlg/buck2-github-composite-action to v2. by @zadlg in #23
  • Fix #25: run buildifier. by @zadlg in #30
  • #19: implement out_binaries and out_binary_dir. by @zadlg in #27
  • #19: implement out_static_libs and out_lib_dir. by @zadlg in #28
  • #19: implement out_shared_libs. by @zadlg in #29
  • #19: implement out_include_dir. by @zadlg in #31
  • Move gnumake attributes to its own file. by @zadlg in #32
  • Make the starlark documentation consistent. by @zadlg in #33
  • Fix #26: define several providers to provide additional information. by @zadlg in #34
  • Fix #24: run full build on macOS. by @zadlg in #38
  • Fix #35: forward CC and CXX from CxxToolchain to GNU Make. by @zadlg in #37
  • Release 0.1. by @zadlg in #39

New Contributors

  • @zadlg made their first contribution in #3

Full Changelog: https://github.com/zadlg/buck2_rules_gnumake/commits/v0.1