This repository implements a Buck2 toolchain for using GNU Make.
GNU Make binaries are not downloaded from some source. Instead, the source code is built from the source.
TL;DR: See gnumake
.
python_bootstrap
, genrule
and cxx
toolchains must be enabled.
To do so, make sure that the following two rules are called:
load("@prelude//toolchains:cxx.bzl", "system_cxx_toolchain")
load("@prelude//toolchains:genrule.bzl", "system_genrule_toolchain")
load("@prelude//toolchains:python.bzl", "system_python_bootstrap_toolchain", "system_python_toolchain")
system_python_bootstrap_toolchain(
name = "python_bootstrap",
visibility = ["PUBLIC"],
)
system_genrule_toolchain(
name = "genrule",
visibility = ["PUBLIC"],
)
system_cxx_toolchain(
name = "cxx",
visibility = ["PUBLIC"],
)
Clone this repository to your repository. Then, to enable the GNU Make toolchain, add the following cell:
# .buckconfig
[repositories]
rules_gnumake = <path_to_gnumake>/
[parser]
target_platform_detector_spec = target:rules_gnumake//...->prelude//platforms:default
First, we clone the repository under external_deps/rules_gnumake
:
$ mkdir -p external_deps/rules_gnumake
$ git clone 'https://github.com/zadlg/rules_gnumake.git' external_deps/rules_gnumake
Then, we declare the cell by adding an entry under the section repositories
of the .buckconfig
file:
# .buckconfig
[repositories]
rules_gnumake = external_deps/rules_gnumake
Finally, we add a new entry under the section parser
to tell Buck which
platforms should be targeted for the rules_gnumake
cell:
# .buckconfig
[parser]
target_platform_detector_spec = target:rules_gnumake//...->prelude//platforms:default
First, we have to enable the GNU Make toolchain. To do so, edit your toolchain
BUCK
file (usually under toolchains/BUCK
), and add the following:
load("@rules_gnumake//gnumake:gnumake.bzl", "gnumake_toolchain")
gnumake_toolchain(
name = "gnumake",
visibility = ["PUBLIC"],
)
Once the toolchain is enabled, one can do the following:
# BUCK file
load("@rules_gnumake//gnumake:rules.bzl", "gnumake")
gnumake(
name = "mylib",
srcs = glob(["Makefile", "*.c"]),
compiler_flags = ["-DENABLE_MY_FEATURE"],
)
To build your target, simply use buck:
$ buck2 build //:mylib
See examples/
.
Apache2, see License.