Skip to content

Commit

Permalink
Expand "Make" variables inside of values in the env dictionary on tes…
Browse files Browse the repository at this point in the history
…t rules

Signed-off-by: Aaron Sky <aaronsky@skyaaron.com>
  • Loading branch information
aaronsky committed Nov 15, 2024
1 parent 8f527c9 commit 62364ab
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ bazel_dep(name = "bazel_features", version = "1.3.0")
bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(
name = "rules_swift",
version = "1.6.0",
version = "1.18.0",
max_compatibility_level = 2,
repo_name = "build_bazel_rules_swift",
)
bazel_dep(
name = "rules_apple",
version = "2.0.0",
version = "3.6.0",
repo_name = "build_bazel_rules_apple",
)
bazel_dep(name = "rules_python", version = "0.27.1")
Expand Down
38 changes: 20 additions & 18 deletions xcodeproj/internal/incremental_xcodeprojinfos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def _target_info_fields(

def _make_skipped_target_xcodeprojinfo(
*,
ctx,
automatic_target_info,
rule_attr,
skip_type,
Expand All @@ -269,6 +270,7 @@ def _make_skipped_target_xcodeprojinfo(
forwards them on, not collecting any information for the current target.
Args:
ctx: The aspect context.
automatic_target_info: The `XcodeProjAutomaticTargetProcessingInfo` for
`the target.
rule_attr: `ctx.rule.attr`.
Expand Down Expand Up @@ -360,6 +362,22 @@ def _make_skipped_target_xcodeprojinfo(
],
)

if automatic_target_info.env:
direct_envs = []
for info in deps_transitive_infos:
if not info.xcode_target:
continue

info_env = getattr(rule_attr, automatic_target_info.env, {})
info_env = {
k: ctx.expand_make_variables("env", v, {})
for k, v in info_env.items()
}
env = dicts.add(info_env, test_env)
direct_envs.append(struct(id = info.xcode_target.id, env = tuple([(k, v) for k, v in env.items()])))
else:
direct_envs = None

return _target_info_fields(
args = memory_efficient_depset(
[
Expand All @@ -380,24 +398,7 @@ def _make_skipped_target_xcodeprojinfo(
compilation_providers = provider_compilation_providers,
direct_dependencies = direct_dependencies,
envs = memory_efficient_depset(
[
struct(
id = info.xcode_target.id,
env = tuple([
(k, v)
for k, v in dicts.add(
getattr(
rule_attr,
automatic_target_info.env,
{},
),
test_env,
).items()
]),
)
for info in deps_transitive_infos
if info.xcode_target
] if automatic_target_info.env else None,
direct_envs,
transitive = [
info.envs
for info in valid_transitive_infos
Expand Down Expand Up @@ -797,6 +798,7 @@ def _make_xcodeprojinfo(
)
if target_skip_type:
info_fields = _make_skipped_target_xcodeprojinfo(
ctx = ctx,
automatic_target_info = automatic_target_info,
rule_attr = rule_attr,
skip_type = target_skip_type,
Expand Down
30 changes: 14 additions & 16 deletions xcodeproj/internal/legacy_xcodeprojinfos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,19 @@ def _make_skipped_target_xcodeprojinfo(
"{}:{}".format(package_label_str, label_name),
)

if automatic_target_info.env:
direct_envs = []
for info in deps_transitive_infos:
info_env = getattr(rule_attr, automatic_target_info.env, {})
info_env = {
k: ctx.expand_make_variables("env", v, {})
for k, v in info_env.items()
}
env = dicts.add(info_env, ctx.configuration.test_env)
direct_envs.append(struct(id = info.xcode_target.id, env = struct(**env)))
else:
direct_envs = None

return _target_info_fields(
args = memory_efficient_depset(
[
Expand All @@ -371,22 +384,7 @@ def _make_skipped_target_xcodeprojinfo(
compilation_providers = provider_compilation_providers,
direct_dependencies = direct_dependencies,
envs = memory_efficient_depset(
[
struct(
id = info.xcode_target.id,
env = struct(
**dicts.add(
getattr(
rule_attr,
automatic_target_info.env,
{},
),
ctx.configuration.test_env,
)
),
)
for info in deps_transitive_infos
] if automatic_target_info.env else None,
direct_envs,
transitive = [
info.envs
for info in valid_transitive_infos
Expand Down

0 comments on commit 62364ab

Please sign in to comment.