@@ -85,9 +85,10 @@ diff --git a/swift/internal/extensions/toolchain.BUILD b/swift/internal/extensio
8585+ sdkroot = "{macos_sdkroot}",
8686 static_runtime = select({
8787diff --git a/swift/internal/extensions/standalone_toolchain.bzl b/swift/internal/extensions/standalone_toolchain.bzl
88+ index 119ded9..b7065b7 100644
8889--- a/swift/internal/extensions/standalone_toolchain.bzl
8990+++ b/swift/internal/extensions/standalone_toolchain.bzl
90- @@ -91,11 +91,17 @@ def _standalone_toolchain_impl(repository_ctx):
91+ @@ -95,6 +95,11 @@ def _standalone_toolchain_impl(repository_ctx):
9192 strip_prefix = filename.removesuffix(".tar.gz"),
9293 )
9394
@@ -99,77 +100,11 @@ diff --git a/swift/internal/extensions/standalone_toolchain.bzl b/swift/internal
99100 repository_ctx.file(".swift-version", repository_ctx.attr.swift_version)
100101 repository_ctx.template(
101102 "BUILD.bazel",
102- repository_ctx.attr._build_template,
103- substitutions = {
103+ @@ -103,6 +108,7 @@ def _standalone_toolchain_impl(repository_ctx):
104+ "{external_static_runtime}": (
105+ ' external_static_runtime = "{}",'.format(repository_ctx.attr.static_runtime) if repository_ctx.attr.static_runtime else ""
106+ ),
104107+ "{macos_sdkroot}": macos_sdkroot,
105108 "{swift_version}": repository_ctx.attr.swift_version,
106109 },
107110 )
108- @@ -107,19 +109,29 @@ def _standalone_toolchain_impl(repository_ctx):
109- - standalone_toolchain = repository_rule(
110- - implementation = _standalone_toolchain_impl,
111- - attrs = {
112- - "_build_template": attr.label(
113- - default = "//swift/internal/extensions:toolchain.BUILD",
114- - ),
115- - "platform": attr.string(
116- - doc = "The host platform name in the swift package download URL",
117- - mandatory = True,
118- - ),
119- - "sha256": attr.string(
120- - doc = "The expected SHA-256 of the file downloaded. This must match the SHA-256 of the file downloaded.",
121- - ),
122- - "swift_version": attr.string(
123- - doc = "Version of the swift toolchain to be installed.",
124- - mandatory = True,
125- - ),
126- - },
127- + _STANDALONE_TOOLCHAIN_ATTRS = {
128- + "_build_template": attr.label(
129- + default = "//swift/internal/extensions:toolchain.BUILD",
130- + ),
131- + "platform": attr.string(
132- + doc = "The host platform name in the swift package download URL",
133- + mandatory = True,
134- + ),
135- + "sha256": attr.string(
136- + doc = "The expected SHA-256 of the file downloaded. This must match the SHA-256 of the file downloaded.",
137- + ),
138- + "swift_version": attr.string(
139- + doc = "Version of the swift toolchain to be installed.",
140- + mandatory = True,
141- + ),
142- + }
143- +
144- + standalone_toolchain = repository_rule(
145- + implementation = _standalone_toolchain_impl,
146- + attrs = _STANDALONE_TOOLCHAIN_ATTRS,
147- + )
148- +
149- + standalone_macos_toolchain = repository_rule(
150- + implementation = _standalone_toolchain_impl,
151- + attrs = _STANDALONE_TOOLCHAIN_ATTRS,
152- + configure = True,
153- + environ = ["DEVELOPER_DIR"],
154- + local = True,
155- )
156- diff --git a/swift/extensions.bzl b/swift/extensions.bzl
157- --- a/swift/extensions.bzl
158- +++ b/swift/extensions.bzl
159- @@ -17 +17,5 @@
160- - load("//swift/internal/extensions:standalone_toolchain.bzl", "standalone_toolchain")
161- + load(
162- + "//swift/internal/extensions:standalone_toolchain.bzl",
163- + "standalone_macos_toolchain",
164- + "standalone_toolchain",
165- + )
166- @@ -182,7 +186,8 @@ def _standalone_toolchain_impl(module_ctx):
167- toolchain_releases = toolchain.platform_sha256.items() or swift_releases[swift_version].items()
168- for platform, sha256 in toolchain_releases:
169- repository_name = toolchain.name + "_{}".format(platform)
170- - standalone_toolchain(
171- + toolchain_repository = standalone_macos_toolchain if platform == "xcode" else standalone_toolchain
172- + toolchain_repository(
173- name = repository_name,
174- sha256 = sha256,
175- platform = platform,
0 commit comments