diff --git a/foreign_cc/boost_build.bzl b/foreign_cc/boost_build.bzl index 3745a371e..9caae9053 100644 --- a/foreign_cc/boost_build.bzl +++ b/foreign_cc/boost_build.bzl @@ -14,7 +14,6 @@ def _boost_build_impl(ctx): ctx.attr, configure_name = "BoostBuild", create_configure_script = _create_configure_script, - make_commands = ["./b2 install {} --prefix=.".format(" ".join(ctx.attr.user_options))], ) return cc_external_rule_impl(ctx, attrs) @@ -26,13 +25,15 @@ def _create_configure_script(configureParameters): "cd $INSTALLDIR", "##copy_dir_contents_to_dir## $$EXT_BUILD_ROOT$$/{}/. .".format(root), "chmod -R +w .", + "##enable_tracing##", "./bootstrap.sh {}".format(" ".join(ctx.attr.bootstrap_options)), + "./b2 install {} --prefix=.".format(" ".join(ctx.attr.user_options)), + "##disable_tracing##", ] def _attrs(): attrs = dict(CC_EXTERNAL_RULE_ATTRIBUTES) attrs.pop("targets") - attrs.pop("make_commands") attrs.update({ "bootstrap_options": attr.string_list( doc = "any additional flags to pass to bootstrap.sh", diff --git a/foreign_cc/cmake.bzl b/foreign_cc/cmake.bzl index 965675c8d..d7b824d7b 100644 --- a/foreign_cc/cmake.bzl +++ b/foreign_cc/cmake.bzl @@ -345,7 +345,6 @@ def _get_generator_target(ctx): def _attrs(): attrs = dict(CC_EXTERNAL_RULE_ATTRIBUTES) - attrs.pop("make_commands") attrs.update({ "build_args": attr.string_list( doc = "Arguments for the CMake build command", diff --git a/foreign_cc/configure.bzl b/foreign_cc/configure.bzl index c9ca72b7c..cc0975308 100644 --- a/foreign_cc/configure.bzl +++ b/foreign_cc/configure.bzl @@ -57,7 +57,6 @@ def _create_configure_script(configureParameters): attrs = configureParameters.attrs inputs = configureParameters.inputs - root = detect_root(ctx.attr.lib_source) install_prefix = _get_install_prefix(ctx) tools = get_tools_info(ctx) @@ -76,16 +75,15 @@ def _create_configure_script(configureParameters): make_commands = [] prefix = "{} ".format(ctx.expand_location(attrs.tool_prefix, data)) if attrs.tool_prefix else "" configure_prefix = "{} ".format(ctx.expand_location(ctx.attr.configure_prefix, data)) if ctx.attr.configure_prefix else "" - - if not ctx.attr.make_commands: - for target in ctx.attr.targets: - make_commands.append("{prefix}{make} -C $$EXT_BUILD_ROOT$$/{root} {target} {args}".format( - prefix = prefix, - make = attrs.make_path, - root = root, - args = args, - target = target, - )) + + for target in ctx.attr.targets: + # Configure will have generated sources into `$BUILD_TMPDIR` so make sure we `cd` there + make_commands.append("{prefix}{make} -C $$BUILD_TMPDIR$$ {target} {args}".format( + prefix = prefix, + make = attrs.make_path, + args = args, + target = target, + )) configure = create_configure_script( workspace_name = ctx.workspace_name, @@ -93,7 +91,7 @@ def _create_configure_script(configureParameters): target_os = os_name(ctx), tools = tools, flags = flags, - root = root, + root = detect_root(ctx.attr.lib_source), user_options = ctx.attr.configure_options, user_vars = dict(ctx.attr.configure_env_vars), is_debug = is_debug_mode(ctx), diff --git a/foreign_cc/make.bzl b/foreign_cc/make.bzl index 09196b25d..b4d2f5cab 100644 --- a/foreign_cc/make.bzl +++ b/foreign_cc/make.bzl @@ -70,7 +70,6 @@ def _create_make_script(configureParameters): def _attrs(): attrs = dict(CC_EXTERNAL_RULE_ATTRIBUTES) - attrs.pop("make_commands") attrs.update({ "args": attr.string_list( doc = "A list of arguments to pass to the call to `make`", diff --git a/foreign_cc/ninja.bzl b/foreign_cc/ninja.bzl index ef6ac4633..8fe5b9ccd 100644 --- a/foreign_cc/ninja.bzl +++ b/foreign_cc/ninja.bzl @@ -32,7 +32,6 @@ def _ninja_impl(ctx): create_configure_script = _create_ninja_script, tools_deps = tools_deps, ninja_path = ninja_data.path, - make_commands = [], ) return cc_external_rule_impl(ctx, attrs) @@ -91,9 +90,6 @@ def _attrs(): """ attrs = dict(CC_EXTERNAL_RULE_ATTRIBUTES) - # Drop old vars - attrs.pop("make_commands") - attrs.update({ "args": attr.string_list( doc = "A list of arguments to pass to the call to `ninja`", diff --git a/foreign_cc/private/framework.bzl b/foreign_cc/private/framework.bzl index d0e2e647d..885c95d56 100644 --- a/foreign_cc/private/framework.bzl +++ b/foreign_cc/private/framework.bzl @@ -15,11 +15,6 @@ load( "shebang", ) load("//foreign_cc/private/framework:platform.bzl", "os_name") -load( - "//toolchains/native_tools:tool_access.bzl", - "get_make_data", - "get_ninja_data", -) load( ":cc_toolchain_util.bzl", "LibrariesToLinkInfo", @@ -128,11 +123,6 @@ CC_EXTERNAL_RULE_ATTRIBUTES = { mandatory = False, default = [], ), - "make_commands": attr.string_list( - doc = "Optional make commands.", - mandatory = False, - default = ["make", "make install"], - ), "out_bin_dir": attr.string( doc = "Optional name of the output subdirectory with the binary files, defaults to 'bin'.", mandatory = False, @@ -336,9 +326,8 @@ def cc_external_rule_impl(ctx, attrs): These variables should be used by the calling rule to refer to the created directory structure. 4. calls 'attrs.create_configure_script' - 5. calls 'attrs.make_commands' - 6. calls 'attrs.postfix_script' - 7. replaces absolute paths in possibly created scripts with a placeholder value + 5. calls 'attrs.postfix_script' + 6. replaces absolute paths in possibly created scripts with a placeholder value Please see cmake.bzl for example usage. @@ -381,8 +370,6 @@ def cc_external_rule_impl(ctx, attrs): env_prelude, env = _env_prelude(ctx, lib_name, data_dependencies, target_root) - make_commands, build_tools = _generate_make_commands(ctx, attrs) - postfix_script = [attrs.postfix_script] if not attrs.postfix_script: postfix_script = [] @@ -399,7 +386,7 @@ def cc_external_rule_impl(ctx, attrs): "##mkdirs## $$EXT_BUILD_DEPS$$", ] + _print_env() + _copy_deps_and_tools(inputs) + [ "cd $$BUILD_TMPDIR$$", - ] + attrs.create_configure_script(ConfigureParameters(ctx = ctx, attrs = attrs, inputs = inputs)) + make_commands + postfix_script + [ + ] + attrs.create_configure_script(ConfigureParameters(ctx = ctx, attrs = attrs, inputs = inputs)) + postfix_script + [ # replace references to the root directory when building ($BUILD_TMPDIR) # and the root where the dependencies were installed ($EXT_BUILD_DEPS) # for the results which are in $INSTALLDIR (with placeholder) @@ -884,35 +871,8 @@ def _collect_libs(cc_linking): libs.append(library) return collections.uniq(libs) -def _generate_make_commands(ctx, attrs): - make_commands = getattr(attrs, "make_commands", []) - tools_deps = [] - - # Early out if there are no commands set - if not make_commands: - return make_commands, tools_deps - - if _uses_tool(attrs.make_commands, "make"): - make_data = get_make_data(ctx) - tools_deps += make_data.deps - make_commands = [_expand_command_path("make", make_data.path, command) for command in make_commands] - - if _uses_tool(attrs.make_commands, "ninja"): - ninja_data = get_ninja_data(ctx) - tools_deps += ninja_data.deps - make_commands = [_expand_command_path("ninja", ninja_data.path, command) for command in make_commands] - - return make_commands, [tool.files for tool in tools_deps] - def _expand_command_path(binary, path, command): if command == binary or command.startswith(binary + " "): return command.replace(binary, path, 1) else: return command - -def _uses_tool(make_commands, tool): - for command in make_commands: - (before, separator, after) = command.partition(" ") - if before == tool: - return True - return False