2018-08-30 16:32:03 +00:00
|
|
|
""" Rule for building Ninja from sources. """
|
|
|
|
|
2018-08-30 15:31:02 +00:00
|
|
|
load("//:detect_root.bzl", "detect_root")
|
2018-08-20 20:24:42 +00:00
|
|
|
|
|
|
|
def _ninja_tool(ctx):
|
|
|
|
root = detect_root(ctx.attr.ninja_srcs)
|
|
|
|
|
|
|
|
ninja = ctx.actions.declare_directory("ninja")
|
|
|
|
script_text = "\n".join([
|
|
|
|
"mkdir " + ninja.path,
|
2018-08-22 20:06:37 +00:00
|
|
|
"cp -R ./{}/. {}".format(root, ninja.path),
|
2018-08-20 20:24:42 +00:00
|
|
|
"cd " + ninja.path,
|
|
|
|
"./configure.py --bootstrap",
|
|
|
|
])
|
|
|
|
|
|
|
|
ctx.actions.run_shell(
|
2018-08-22 13:15:53 +00:00
|
|
|
mnemonic = "BootstrapNinja",
|
2018-08-20 20:24:42 +00:00
|
|
|
inputs = ctx.attr.ninja_srcs.files,
|
|
|
|
outputs = [ninja],
|
|
|
|
tools = [],
|
|
|
|
use_default_shell_env = True,
|
|
|
|
command = script_text,
|
|
|
|
execution_requirements = {"block-network": ""},
|
|
|
|
)
|
|
|
|
|
|
|
|
return [DefaultInfo(files = depset([ninja]))]
|
|
|
|
|
2018-08-30 16:32:03 +00:00
|
|
|
""" Rule for building Ninja. Invokes configure script and make install.
|
|
|
|
Attributes:
|
|
|
|
ninja_srcs - target with the Ninja sources
|
|
|
|
"""
|
2018-08-20 20:24:42 +00:00
|
|
|
ninja_tool = rule(
|
|
|
|
attrs = {
|
|
|
|
"ninja_srcs": attr.label(mandatory = True),
|
|
|
|
},
|
|
|
|
fragments = ["cpp"],
|
|
|
|
output_to_genfiles = True,
|
|
|
|
implementation = _ninja_tool,
|
|
|
|
)
|