@@ -31,6 +31,13 @@ bazel_dep(name = "gazelle", version = "0.50.0")
3131bazel_dep (name = "rules_dotnet" , version = "0.21.5-codeql.1" )
3232bazel_dep (name = "googletest" , version = "1.17.0.bcr.2" )
3333bazel_dep (name = "rules_rust" , version = "0.69.0" )
34+ bazel_dep (name = "rules_swift" , version = "4.0.0-rc4" )
35+ bazel_dep (name = "swift-syntax" , version = "603.0.2" )
36+
37+ # Needed so we can `use_repo` `local_config_xcode` and
38+ # `local_config_apple_cc_toolchains` below (referenced by the per-target
39+ # Xcode-config transition in `unified/swift-syntax-rs/xcode_transition.bzl`).
40+ bazel_dep (name = "apple_support" , version = "2.6.1" )
3441bazel_dep (name = "zstd" , version = "1.5.7.bcr.1" )
3542
3643bazel_dep (name = "buildifier_prebuilt" , version = "6.4.0" , dev_dependency = True )
@@ -219,6 +226,41 @@ use_repo(
219226 "swift-resource-dir-macos" ,
220227)
221228
229+ # Swift toolchain for building `unified/swift-syntax-rs`. On Linux we register
230+ # a hermetic swift.org toolchain as the exec toolchain; on macOS `rules_swift`
231+ # auto-registers `xcode_swift_toolchain` (host Xcode + OS-provided Swift
232+ # runtime), which is not hermetic.
233+ #
234+ # The version is pinned as a literal rather than read from
235+ # `unified/swift-syntax-rs/.swift-version` via `swift_version_file`: the latter
236+ # makes the extension `module_ctx.read` a `//unified/...` label, which fails to
237+ # resolve when this repo is consumed as a dependency module (`@@ql+`) whose
238+ # `unified/swift-syntax-rs` package is not loadable in that context. Keep this
239+ # in sync with `unified/swift-syntax-rs/.swift-version` (used by the `cargo`
240+ # build) and the `swift-syntax` release in `swift/Package.swift`.
241+ swift = use_extension ("@rules_swift//swift:extensions.bzl" , "swift" )
242+ swift .toolchain (
243+ name = "swift_toolchain" ,
244+ swift_version = "6.3.2" ,
245+ )
246+ use_repo (
247+ swift ,
248+ "swift_toolchain" ,
249+ "swift_toolchain_ubuntu22.04" ,
250+ )
251+
252+ register_toolchains (
253+ "@swift_toolchain//:swift_toolchain_exec_ubuntu22.04" ,
254+ )
255+
256+ # `apple_support`'s xcode_config and CC toolchains, needed by the Xcode
257+ # transition in `unified/swift-syntax-rs/xcode_transition.bzl`.
258+ xcode_configure = use_extension ("@apple_support//xcode:xcode_configure.bzl" , "xcode_configure_extension" )
259+ use_repo (xcode_configure , "local_config_xcode" )
260+
261+ apple_cc_configure = use_extension ("@apple_support//crosstool:setup.bzl" , "apple_cc_configure_extension" )
262+ use_repo (apple_cc_configure , "local_config_apple_cc_toolchains" )
263+
222264node = use_extension ("@rules_nodejs//nodejs:extensions.bzl" , "node" )
223265node .toolchain (
224266 name = "nodejs" ,
0 commit comments