From ee079b7261b9b4d1e01474e35fe45b25d76d8837 Mon Sep 17 00:00:00 2001 From: jheaff1 <48310225+jheaff1@users.noreply.github.com> Date: Wed, 2 Nov 2022 22:02:55 +0000 Subject: [PATCH] Fix current toolchains (#978) --- examples/current_toolchains/BUILD.bazel | 13 +++++++++++++ toolchains/native_tools/native_tools_toolchain.bzl | 7 ++----- toolchains/toolchains.bzl | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 examples/current_toolchains/BUILD.bazel diff --git a/examples/current_toolchains/BUILD.bazel b/examples/current_toolchains/BUILD.bazel new file mode 100644 index 000000000..16c86a943 --- /dev/null +++ b/examples/current_toolchains/BUILD.bazel @@ -0,0 +1,13 @@ +load("@bazel_skylib//rules:build_test.bzl", "build_test") + +genrule( + name = "current_make_toolchain_test", + outs = ["out.txt"], + cmd = "$(MAKE) --version > $@", + toolchains = ["@rules_foreign_cc//toolchains:current_make_toolchain"], +) + +build_test( + name = "current_toolchain_tests", + targets = [":current_make_toolchain_test"], +) diff --git a/toolchains/native_tools/native_tools_toolchain.bzl b/toolchains/native_tools/native_tools_toolchain.bzl index 36a4e5af2..620c2d5a9 100644 --- a/toolchains/native_tools/native_tools_toolchain.bzl +++ b/toolchains/native_tools/native_tools_toolchain.bzl @@ -1,8 +1,5 @@ """Rules for building native build tools such as ninja, make or cmake""" -# buildifier: disable=bzl-visibility -load("//foreign_cc/private:framework.bzl", "expand_locations_and_make_variables") - # buildifier: disable=module-docstring ToolInfo = provider( doc = "Information about the native tool", @@ -28,10 +25,10 @@ def _native_tool_toolchain_impl(ctx): path = None if ctx.attr.target: path = ctx.expand_location(ctx.attr.path, targets = [ctx.attr.target]) - env = expand_locations_and_make_variables(ctx, ctx.attr.env, "env", [ctx.attr.target]) + env = {k: ctx.expand_location(v, targets = [ctx.attr.target]) for (k, v) in ctx.attr.env.items()} else: path = ctx.expand_location(ctx.attr.path) - env = expand_locations_and_make_variables(ctx, ctx.attr.env, "env", []) + env = {k: ctx.expand_location(v) for (k, v) in ctx.attr.env.items()} return platform_common.ToolchainInfo(data = ToolInfo( env = env, path = path, diff --git a/toolchains/toolchains.bzl b/toolchains/toolchains.bzl index 64f880e48..dafcf5a21 100644 --- a/toolchains/toolchains.bzl +++ b/toolchains/toolchains.bzl @@ -26,6 +26,7 @@ def _current_toolchain_impl(ctx): toolchain, platform_common.TemplateVariableInfo(toolchain.data.env), DefaultInfo( + files = toolchain.data.target.files, runfiles = toolchain.data.target.default_runfiles, ), ]