Skip to content

Commit 6e0fdb1

Browse files
authored
Add support for CLT only (#354)
The only thing stopping us from supporting the command line tools was that we always tried to send the Xcode derived environment variables to every action. For the command line tools there are reasonable replacements that should always be safe to hardcode. The only thing weird about this setup is that the target uses the default in bazel which is currently 10.11. It respects --macos_minimum_os, so that's probably fine. In this setup the SDK version is not part of the cache key, users could pass something in the --action_env to solve this if they wanted. That seems hard enough to manage just from the CLT installation side so it probably just doesn't matter for this use case.
1 parent 8d477fc commit 6e0fdb1

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

crosstool/cc_toolchain_config.bzl

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,19 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new
15011501
],
15021502
)
15031503

1504+
if xcode_config.xcode_version():
1505+
apple_env = {
1506+
"XCODE_VERSION_OVERRIDE": str(xcode_config.xcode_version()),
1507+
# TODO: Remove once we drop bazel 7.x support
1508+
"APPLE_SDK_VERSION_OVERRIDE": str(sdk_version),
1509+
"APPLE_SDK_PLATFORM": _sdk_name(platform_type, is_simulator),
1510+
}
1511+
else:
1512+
apple_env = {
1513+
"DEVELOPER_DIR": "/Library/Developer/CommandLineTools",
1514+
"SDKROOT": "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk",
1515+
}
1516+
15041517
apple_env_feature = feature(
15051518
name = "apple_env",
15061519
env_sets = [
@@ -1520,24 +1533,9 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new
15201533
ACTION_NAMES.linkstamp_compile,
15211534
],
15221535
env_entries = [
1523-
env_entry(
1524-
key = "XCODE_VERSION_OVERRIDE",
1525-
value = str(xcode_config.xcode_version()),
1526-
),
1527-
# TODO: Remove once we drop bazel 7.x support
1528-
env_entry(
1529-
key = "APPLE_SDK_VERSION_OVERRIDE",
1530-
value = str(sdk_version),
1531-
),
1532-
env_entry(
1533-
key = "APPLE_SDK_PLATFORM",
1534-
value = _sdk_name(platform_type, is_simulator),
1535-
),
1536-
env_entry(
1537-
key = "ZERO_AR_DATE",
1538-
value = "1",
1539-
),
1540-
] + [env_entry(key = key, value = value) for key, value in ctx.attr.extra_env.items()],
1536+
env_entry(key = key, value = value)
1537+
for key, value in (apple_env | ctx.attr.extra_env).items()
1538+
],
15411539
),
15421540
],
15431541
)

0 commit comments

Comments
 (0)