Skip to content

Commit 26ec221

Browse files
authored
bazel: auto-enable swift_macos on macOS so Swift builds work zero-config
1 parent 45a42b0 commit 26ec221

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

.bazelrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ common --override_module=semmle_code=%workspace%/misc/bazel/semmle_code_stub
1212

1313
build --repo_env=CC=clang --repo_env=CXX=clang++
1414

15-
# macOS Xcode-coupled flags, scoped to Swift builds only so that non-Swift
16-
# builds (C/C++/Rust/...) work with just the Command Line Tools. Enable
17-
# with `--config=swift_macos` (see `unified/swift-syntax-rs/README.md`).
15+
# macOS Xcode-coupled flags, grouped under `--config=swift_macos` so they're
16+
# easy to see, disable, or omit for non-Xcode setups. Auto-enabled for
17+
# macOS below via `common:macos --config=swift_macos` because `rules_swift`
18+
# auto-registers `xcode_swift_toolchain` on macOS, and its analysis fails
19+
# without these flags whenever a Swift target is in the graph.
1820
#
1921
# - `--xcode_version_config` selects `apple_support`'s xcode_config, whose
2022
# version strings match the ones `rules_swift`'s `system_sdk` selects are
@@ -26,6 +28,7 @@ build --repo_env=CC=clang --repo_env=CXX=clang++
2628
# toolchains; only matches Apple platforms.
2729
build:swift_macos --xcode_version_config=@local_config_xcode//:host_xcodes
2830
build:swift_macos --extra_toolchains=@local_config_apple_cc_toolchains//:all
31+
common:macos --config=swift_macos
2932

3033
# Disable Android SDK auto-detection (we don't use it, and rules_android has Bazel 9 compatibility issues)
3134
build --repo_env=ANDROID_HOME=

unified/swift-syntax-rs/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,6 @@ bazel test //unified/swift-syntax-rs:swift_syntax_rs_test
139139
bazel run //unified/swift-syntax-rs:swift-syntax-parse < some.swift
140140
```
141141

142-
On **macOS**, add `--config=swift_macos` to any of the above so that
143-
`rules_swift`'s `xcode_swift_toolchain` gets the Xcode-coupled CC toolchain
144-
and xcode_config it needs. The flag is opt-in so that non-Swift builds on
145-
macOS don't require a full Xcode.app install.
146-
147142
Requirements:
148143

149144
- **`clang`** must be installed on the runner. `rules_swift` requires the Bazel

0 commit comments

Comments
 (0)