Skip to content

Commit

Permalink
Fix current toolchains (#978)
Browse files Browse the repository at this point in the history
  • Loading branch information
jheaff1 authored Nov 2, 2022
1 parent c923238 commit ee079b7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
13 changes: 13 additions & 0 deletions examples/current_toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"],
)
7 changes: 2 additions & 5 deletions toolchains/native_tools/native_tools_toolchain.bzl
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions toolchains/toolchains.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
]
Expand Down

0 comments on commit ee079b7

Please sign in to comment.