2
0
Fork 0
mirror of https://github.com/bazel-contrib/rules_foreign_cc synced 2024-12-01 22:16:27 +00:00
rules_foreign_cc/for_workspace/make_build.bzl
UebelAndre 8b8f31dd1b
Created a ./docs directory to house documentation (#466)
* Added links to docs to top level README

* Updated more docs

* Added generated header
2021-01-24 15:23:19 -08:00

48 lines
1.4 KiB
Python

""" Rule for building GNU Make from sources. """
load("//tools/build_defs:detect_root.bzl", "detect_root")
load("@rules_foreign_cc//tools/build_defs:shell_script_helper.bzl", "convert_shell_script")
def _make_tool(ctx):
root = detect_root(ctx.attr.make_srcs)
make = ctx.actions.declare_directory("make")
script = [
"export BUILD_DIR=##pwd##",
"export BUILD_TMPDIR=##tmpdir##",
"##copy_dir_contents_to_dir## ./{} $BUILD_TMPDIR".format(root),
"cd $$BUILD_TMPDIR$$",
"./configure --prefix=$$BUILD_DIR$$/{}".format(make.path),
"./build.sh",
"./make install",
]
script_text = convert_shell_script(ctx, script)
ctx.actions.run_shell(
mnemonic = "BootstrapMake",
inputs = ctx.attr.make_srcs.files,
outputs = [make],
tools = [],
use_default_shell_env = True,
command = script_text,
execution_requirements = {"block-network": ""},
)
return [DefaultInfo(files = depset([make]))]
make_tool = rule(
doc = "Rule for building Make. Invokes configure script and make install.",
attrs = {
"make_srcs": attr.label(
doc = "target with the Make sources",
mandatory = True,
),
},
fragments = ["cpp"],
output_to_genfiles = True,
implementation = _make_tool,
toolchains = [
"@rules_foreign_cc//tools/build_defs/shell_toolchain/toolchains:shell_commands",
],
)