Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ string_flag(
visibility = ["//visibility:public"],
)

string_flag(
name = "flag_with_make_variable",
build_setting_default = "",
make_variable = "FLAG_WITH_MAKE_VARIABLE",
visibility = ["//visibility:public"],
)

# Example of xcodeproj cache warming
#
# 1. Register a single macOS execution platform in `MODULE.bazel`:
Expand Down
2 changes: 2 additions & 0 deletions examples/integration/iOSApp/Test/ObjCUnitTests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ ios_unit_test(
bundle_id = "rules-xcodeproj.example.objctests",
env = {
"IOS_APP_UNIT_TESTS": "CUSTOM_ENV_VALUE",
"IOS_APP_UNIT_TESTS_MAKE": "$(FLAG_WITH_MAKE_VARIABLE)",
},
minimum_os_version = "15.0",
tags = ["manual"],
test_host = "//iOSApp",
toolchains = ["//:flag_with_make_variable"],
visibility = [
"//iOSApp:__subpackages__",
"@rules_xcodeproj//xcodeproj:generated",
Expand Down
4 changes: 4 additions & 0 deletions xcodeproj/internal/xcodeproj_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def _xcodeproj_aspect_impl(target, ctx):
# one
rule_attr = ctx.rule.attr

# Update when Bazel 8 is dropped
var_attr = getattr(ctx.rule, "var", ctx.var)

attrs = dir(rule_attr)
info = xcodeprojinfos.make(
ctx = ctx,
Expand All @@ -127,6 +130,7 @@ def _xcodeproj_aspect_impl(target, ctx):
attrs = attrs,
rule_attr = rule_attr,
),
var_attr = var_attr,
)
if info:
providers.append(info)
Expand Down
11 changes: 8 additions & 3 deletions xcodeproj/internal/xcodeprojinfos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ def _make_skipped_target_xcodeprojinfo(
rule_attr,
skip_type,
test_env,
transitive_infos):
transitive_infos,
var_attr):
"""Passes through existing target info fields, not collecting new ones.

Merges `XcodeProjInfo`s for the dependencies of the current target, and
Expand All @@ -275,6 +276,7 @@ def _make_skipped_target_xcodeprojinfo(
test_env: `ctx.configuration.test_env`.
transitive_infos: A `list` of `depset`s of `XcodeProjInfo`s from the
transitive dependencies of the target.
var_attr: `ctx.rule.var` (or `ctx.var` for Bazel 8 and below).

Returns:
The return value of `_target_info_fields`, with values merged from
Expand Down Expand Up @@ -367,7 +369,7 @@ def _make_skipped_target_xcodeprojinfo(

info_env = getattr(rule_attr, automatic_target_info.env, {})
info_env = {
k: ctx.expand_make_variables("env", v, {})
k: ctx.expand_make_variables("env", v, var_attr)
for k, v in info_env.items()
}
env = dicts.add(info_env, test_env)
Expand Down Expand Up @@ -756,7 +758,8 @@ def _make_xcodeprojinfo(
rule_attr,
rule_kind,
target,
transitive_infos):
transitive_infos,
var_attr):
"""Creates an `XcodeProjInfo` for the given target.

Args:
Expand All @@ -767,6 +770,7 @@ def _make_xcodeprojinfo(
target: The `Target` to process.
transitive_infos: A `list` of `XcodeProjInfo`s from the transitive
dependencies of `target`.
var_attr: `ctx.rule.var` (or `ctx.var` for Bazel 8 and below).

Returns:
An `XcodeProjInfo` populated with information from `target` and
Expand Down Expand Up @@ -799,6 +803,7 @@ def _make_xcodeprojinfo(
skip_type = target_skip_type,
test_env = ctx.configuration.test_env,
transitive_infos = transitive_infos,
var_attr = var_attr,
)
else:
info_fields = _make_non_skipped_target_xcodeprojinfo(
Expand Down
Loading