Skip to content

Commit b6cc4df

Browse files
committed
Fix "Make" variable expansion for test rules under Bazel 9
Signed-off-by: Aaron Sky <aaronsky@skyaaron.com>
1 parent 40bab89 commit b6cc4df

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

xcodeproj/internal/xcodeproj_aspect.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ def _xcodeproj_aspect_impl(target, ctx):
115115
# Only create a `XcodeProjInfo` if the target hasn't already created
116116
# one
117117
rule_attr = ctx.rule.attr
118+
# Update when Bazel 8 is dropped
119+
var_attr = getattr(ctx.rule, "var", ctx.var)
118120

119121
attrs = dir(rule_attr)
120122
info = xcodeprojinfos.make(
@@ -127,6 +129,7 @@ def _xcodeproj_aspect_impl(target, ctx):
127129
attrs = attrs,
128130
rule_attr = rule_attr,
129131
),
132+
var_attr = var_attr,
130133
)
131134
if info:
132135
providers.append(info)

xcodeproj/internal/xcodeprojinfos.bzl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ def _make_skipped_target_xcodeprojinfo(
260260
rule_attr,
261261
skip_type,
262262
test_env,
263-
transitive_infos):
263+
transitive_infos,
264+
var_attr):
264265
"""Passes through existing target info fields, not collecting new ones.
265266
266267
Merges `XcodeProjInfo`s for the dependencies of the current target, and
@@ -275,6 +276,7 @@ def _make_skipped_target_xcodeprojinfo(
275276
test_env: `ctx.configuration.test_env`.
276277
transitive_infos: A `list` of `depset`s of `XcodeProjInfo`s from the
277278
transitive dependencies of the target.
279+
var_attr: `ctx.rule.var` (or `ctx.var` for Bazel 8 and below).
278280
279281
Returns:
280282
The return value of `_target_info_fields`, with values merged from
@@ -367,7 +369,7 @@ def _make_skipped_target_xcodeprojinfo(
367369

368370
info_env = getattr(rule_attr, automatic_target_info.env, {})
369371
info_env = {
370-
k: ctx.expand_make_variables("env", v, {})
372+
k: ctx.expand_make_variables("env", v, var_attr)
371373
for k, v in info_env.items()
372374
}
373375
env = dicts.add(info_env, test_env)
@@ -756,7 +758,8 @@ def _make_xcodeprojinfo(
756758
rule_attr,
757759
rule_kind,
758760
target,
759-
transitive_infos):
761+
transitive_infos,
762+
var_attr):
760763
"""Creates an `XcodeProjInfo` for the given target.
761764
762765
Args:
@@ -767,6 +770,7 @@ def _make_xcodeprojinfo(
767770
target: The `Target` to process.
768771
transitive_infos: A `list` of `XcodeProjInfo`s from the transitive
769772
dependencies of `target`.
773+
var_attr: `ctx.rule.var` (or `ctx.var` for Bazel 8 and below).
770774
771775
Returns:
772776
An `XcodeProjInfo` populated with information from `target` and
@@ -799,6 +803,7 @@ def _make_xcodeprojinfo(
799803
skip_type = target_skip_type,
800804
test_env = ctx.configuration.test_env,
801805
transitive_infos = transitive_infos,
806+
var_attr = var_attr,
802807
)
803808
else:
804809
info_fields = _make_non_skipped_target_xcodeprojinfo(

0 commit comments

Comments
 (0)