Skip to content
Draft
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
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ build:remote_macos_arm64 --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build:remote_macos_arm64 --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1
build:remote_macos_arm64 --xcode_version_config=//platform/macos_arm64/xcode:installed_xcodes
build:remote_macos_arm64 --extra_toolchains=//platform/macos_arm64/cc:all
build:remote_macos_arm64 --extra_toolchains=//platform/macos_arm64/swift:all
# Disable workers: Builds fail with remote swift workers
build:remote_macos_arm64 --experimental_remote_mark_tool_inputs=false

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ jobs:
- { version: "26.5", ios_sdk: "26.5" }
- { version: "27.2", ios_sdk: "27.2", ios_simulator_device: "iPhone Duo" }
exclude:
# TODO: Re-enable when remote-only Xcode versions are supported.
- execution_type: remote
xcode: { version: "27.2", ios_sdk: "27.2", ios_simulator_device: "iPhone Duo" }
# TODO: Re-enable when Xcode 27.2 is installed on the macos CI fleet.
- execution_type: local
xcode: { version: "27.2", ios_sdk: "27.2", ios_simulator_device: "iPhone Duo" }
Expand Down
15 changes: 15 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ use_repo(maven, "maven")
bazel_dep(name = "rules_kotlin", version = "2.3.20")
bazel_dep(name = "rules_perl", version = "1.1.1")
bazel_dep(name = "rules_swift", version = "4.1.1")

# Vendored explicit modules for the Xcode versions on the remote macOS workers.
# Only used by the Swift toolchains registered by --config=remote_macos_arm64;
# local builds use rules_swift's auto-detected @system_sdk.
vendored_system_sdk = use_extension("//platform/macos_arm64/swift:extensions.bzl", "vendored_system_sdk")
vendored_system_sdk.configure_xcode(
build_file = "//platform/macos_arm64/swift:vendored.26.5.BUILD",
version = "26.5.0.17F42",
)
vendored_system_sdk.configure_xcode(
build_file = "//platform/macos_arm64/swift:vendored.27.2.BUILD",
version = "27.2.0.27B52",
)
use_repo(vendored_system_sdk, "vendored_system_sdk")

bazel_dep(name = "rules_nodejs", version = "6.7.4")
bazel_dep(name = "aspect_rules_ts", version = "3.8.10")
bazel_dep(name = "aspect_bazel_lib", version = "2.22.5")
Expand Down
20 changes: 2 additions & 18 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions platform/macos_arm64/swift/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
load("@apple_support//configs:platforms.bzl", "APPLE_PLATFORMS_CONSTRAINTS")
load("@rules_swift//swift/internal:feature_names.bzl", "SWIFT_FEATURE_MODULE_MAP_NO_PRIVATE_HEADERS")
load("@rules_swift//swift/toolchains:xcode_swift_toolchain.bzl", "xcode_swift_toolchain")

# Vendored Swift configuration for different XCode versions.

# Regenerate them with:
# DEVELOPER_DIR=/Applications/Xcode-$VERSION.app/Contents/Developer/ bazel run -- @rules_swift//tools/explicit_modules:scan --output vendored.BUILD --developer-dir /Applications/Xcode-$VERSION.app/Contents/Developer/

exports_files(["vendored.27.2.BUILD", "vendored.26.5.BUILD"])

# Same as @rules_swift//swift/toolchains:xcode-toolchain, but uses the vendored
# explicit modules instead of scanning the local Xcode installations. These
# toolchains are registered by --config=remote_macos_arm64.
xcode_swift_toolchain(
name = "xcode-toolchain",
cross_import_overlays = ["@vendored_system_sdk//:all_cross_import_overlays"],
features = [SWIFT_FEATURE_MODULE_MAP_NO_PRIVATE_HEADERS],
implicit_system_modules = "@vendored_system_sdk//:implicit_modules",
system_modules = "@vendored_system_sdk//:all_modules",
tags = ["manual"],
)

[
toolchain(
name = "xcode-toolchain-" + arch,
exec_compatible_with = [
"@platforms//os:macos",
],
target_compatible_with = constraints,
toolchain = ":xcode-toolchain",
toolchain_type = "@rules_swift//toolchains:toolchain_type",
)
for arch, constraints in APPLE_PLATFORMS_CONSTRAINTS.items()
]
70 changes: 70 additions & 0 deletions platform/macos_arm64/swift/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"""Vendored Swift explicit module repos for the remote macOS workers.

This mirrors the `configure_xcode` mode of rules_swift's `system_sdk`
extension, but generates a separate `@vendored_system_sdk` hub repo so that
local builds keep using rules_swift's auto-detected `@system_sdk`. The hub is
only used by the toolchains in this package, which are registered by
`--config=remote_macos_arm64`.
"""

load(
"@rules_swift//tools/explicit_modules:precomputed_xcode_explicit_module_repo.bzl",
"precomputed_xcode_explicit_module_repo",
)
load(
"@rules_swift//tools/explicit_modules:xcode_explicit_module_hub_repo.bzl",
"xcode_explicit_module_hub_repo",
)

def _sanitize(v):
return v.replace(".", "_").replace("-", "_")

def _vendored_system_sdk_impl(module_ctx):
versions = []
default_manifest = None
for mod in module_ctx.modules:
for tag in mod.tags.configure_xcode:
if tag.version in versions:
fail("Duplicate configure_xcode() for Xcode version '{}'.".format(tag.version))
versions.append(tag.version)

# The hub repo refers to these repos as `@system_sdk_xcode_<version>`.
repo_name = "system_sdk_xcode_" + _sanitize(tag.version)
precomputed_xcode_explicit_module_repo(
name = repo_name,
xcode_version = tag.version,
build_file = tag.build_file,
)
if default_manifest == None:
default_manifest = "@{}//:module_names.json".format(repo_name)

if not versions:
fail("At least one configure_xcode() tag is required.")

xcode_explicit_module_hub_repo(
name = "vendored_system_sdk",
xcode_versions = versions,
default_manifest = default_manifest,
)

return module_ctx.extension_metadata(reproducible = True)

vendored_system_sdk = module_extension(
implementation = _vendored_system_sdk_impl,
tag_classes = {
"configure_xcode": tag_class(
attrs = {
"build_file": attr.label(
mandatory = True,
allow_single_file = True,
doc = "Explicit module BUILD for the given Xcode.",
),
"version": attr.string(
mandatory = True,
doc = "Canonical Xcode version string (e.g. 26.5.0.17F42).",
),
},
),
},
doc = "Generate @vendored_system_sdk from vendored explicit module BUILD files.",
)
Loading
Loading