Skip to content

Commit

Permalink
Fix #1161: set the CMAKE environment variables for prebuilt toolcha…
Browse files Browse the repository at this point in the history
…ins. (#1163)
  • Loading branch information
thomas authored Mar 13, 2024
1 parent 5547abc commit cecdab0
Show file tree
Hide file tree
Showing 3 changed files with 397 additions and 373 deletions.
18 changes: 14 additions & 4 deletions toolchains/native_tools/native_tools_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ToolInfo = provider(
},
)

def _resolve_tool_path(ctx, path, target):
def _resolve_tool_path(ctx, path, target, tools):
"""
Resolve the path to a tool.
Expand All @@ -32,7 +32,7 @@ def _resolve_tool_path(ctx, path, target):
_, resolved_bash_command, _ = ctx.resolve_command(
command = path,
expand_locations = True,
tools = [target],
tools = tools + [target],
)

return resolved_bash_command[-1]
Expand All @@ -43,10 +43,10 @@ def _native_tool_toolchain_impl(ctx):
path = None
env = {}
if ctx.attr.target:
path = _resolve_tool_path(ctx, ctx.attr.path, ctx.attr.target)
path = _resolve_tool_path(ctx, ctx.attr.path, ctx.attr.target, ctx.attr.tools)

for k, v in ctx.attr.env.items():
env[k] = _resolve_tool_path(ctx, v, ctx.attr.target)
env[k] = _resolve_tool_path(ctx, v, ctx.attr.target, ctx.attr.tools)

else:
path = ctx.expand_location(ctx.attr.path)
Expand Down Expand Up @@ -88,6 +88,16 @@ native_tool_toolchain = rule(
),
allow_files = True,
),
"tools": attr.label_list(
mandatory = False,
cfg = "exec",
doc = (
"Additional tools." +
"If `target` expands to several files, `tools` can be used to " +
"isolate a specific file that can be used in `env`."
),
allow_files = True,
),
},
incompatible_use_toolchain_transition = True,
)
Loading

0 comments on commit cecdab0

Please sign in to comment.