Skip to content

Commit 3af3a0d

Browse files
gregmagolanalexeagle
authored andcommitted
fix: expand_variables helper should handle external labels
1 parent 8a13e7c commit 3af3a0d

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

internal/common/expand_variables.bzl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ def expand_variables(ctx, s, outs = [], output_dir = False):
3131
https://docs.bazel.build/versions/master/be/make-variables.html#predefined_genrule_variables
3232
for more information of how these special variables are expanded.
3333
"""
34-
rule_dir = [ctx.bin_dir.path, ctx.label.package]
34+
rule_dir = [f for f in [
35+
ctx.bin_dir.path,
36+
ctx.label.workspace_root,
37+
ctx.label.package,
38+
] if f]
3539
additional_substitutions = {}
3640

3741
if output_dir:
@@ -41,7 +45,12 @@ def expand_variables(ctx, s, outs = [], output_dir = False):
4145
See https://github.com/bazelbuild/rules_nodejs/releases/tag/0.42.0""")
4246

4347
# We'll write into a newly created directory named after the rule
44-
output_dir = [ctx.bin_dir.path, ctx.label.package, ctx.attr.name]
48+
output_dir = [f for f in [
49+
ctx.bin_dir.path,
50+
ctx.label.workspace_root,
51+
ctx.label.package,
52+
ctx.label.name,
53+
] if f]
4554
else:
4655
if s.find("$@") != -1 or s.find("$(@)") != -1:
4756
if len(ctx.outputs.outs) > 1:

0 commit comments

Comments
 (0)