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
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bazel_dep(name = "gazelle", version = "0.50.0")
bazel_dep(name = "rules_dotnet", version = "0.21.5-codeql.1")
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
bazel_dep(name = "rules_rust", version = "0.74.0")
bazel_dep(name = "rules_swift", version = "4.0.0-rc5-codeql.2")
bazel_dep(name = "rules_swift", version = "4.0.0-rc5-codeql.3")
bazel_dep(name = "swift-syntax", version = "603.0.2")
bazel_dep(name = "zstd", version = "1.5.7.bcr.1")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module(
name = "rules_swift",
version = "4.0.0-rc5-codeql.2",
version = "4.0.0-rc5-codeql.3",
bazel_compatibility = [">=8.0.0"],
compatibility_level = 3,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ index b77f636..1255ba7 100644
"swift_version_file": attr.label(doc = "A label to the .swift_version file to use. Cannot be used concurrently with `swift_version`"),
})
diff --git a/swift/internal/extensions/standalone_toolchain.bzl b/swift/internal/extensions/standalone_toolchain.bzl
index a1e09ea..1fcf56d 100644
index 801aad7..119ded9 100644
--- a/swift/internal/extensions/standalone_toolchain.bzl
+++ b/swift/internal/extensions/standalone_toolchain.bzl
@@ -105,6 +105,9 @@ def _standalone_toolchain_impl(repository_ctx):
@@ -100,6 +100,9 @@ def _standalone_toolchain_impl(repository_ctx):
"BUILD.bazel",
repository_ctx.attr._build_template,
substitutions = {
+ "{external_static_runtime}": (
+ ' external_static_runtime = "{}",'.format(repository_ctx.attr.static_runtime) if repository_ctx.attr.static_runtime else ""
+ ),
"{macos_sdkroot}": macos_sdkroot,
"{swift_version}": repository_ctx.attr.swift_version,
},
@@ -121,6 +124,9 @@ _STANDALONE_TOOLCHAIN_ATTRS = {
"sha256": attr.string(
doc = "The expected SHA-256 of the file downloaded. This must match the SHA-256 of the file downloaded.",
),
+ "static_runtime": attr.label(
+ doc = "External static runtime package used by this execution toolchain.",
+ ),
"swift_version": attr.string(
doc = "Version of the swift toolchain to be installed.",
mandatory = True,
)
@@ -117,6 +120,9 @@ standalone_toolchain = repository_rule(
"sha256": attr.string(
doc = "The expected SHA-256 of the file downloaded. This must match the SHA-256 of the file downloaded.",
),
+ "static_runtime": attr.label(
+ doc = "External static runtime package used by this execution toolchain.",
+ ),
"swift_version": attr.string(
doc = "Version of the swift toolchain to be installed.",
mandatory = True,
diff --git a/swift/internal/extensions/toolchain.BUILD b/swift/internal/extensions/toolchain.BUILD
index 1304dc2..ee77866 100644
--- a/swift/internal/extensions/toolchain.BUILD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ diff --git a/swift/internal/extensions/toolchain.BUILD b/swift/internal/extensio
+ sdkroot = "{macos_sdkroot}",
static_runtime = select({
diff --git a/swift/internal/extensions/standalone_toolchain.bzl b/swift/internal/extensions/standalone_toolchain.bzl
index 119ded9..b7065b7 100644
--- a/swift/internal/extensions/standalone_toolchain.bzl
+++ b/swift/internal/extensions/standalone_toolchain.bzl
@@ -91,11 +91,17 @@ def _standalone_toolchain_impl(repository_ctx):
@@ -95,6 +95,11 @@ def _standalone_toolchain_impl(repository_ctx):
strip_prefix = filename.removesuffix(".tar.gz"),
)

Expand All @@ -99,77 +100,11 @@ diff --git a/swift/internal/extensions/standalone_toolchain.bzl b/swift/internal
repository_ctx.file(".swift-version", repository_ctx.attr.swift_version)
repository_ctx.template(
"BUILD.bazel",
repository_ctx.attr._build_template,
substitutions = {
@@ -103,6 +108,7 @@ def _standalone_toolchain_impl(repository_ctx):
"{external_static_runtime}": (
' external_static_runtime = "{}",'.format(repository_ctx.attr.static_runtime) if repository_ctx.attr.static_runtime else ""
),
+ "{macos_sdkroot}": macos_sdkroot,
"{swift_version}": repository_ctx.attr.swift_version,
},
)
@@ -107,19 +109,29 @@ def _standalone_toolchain_impl(repository_ctx):
-standalone_toolchain = repository_rule(
- implementation = _standalone_toolchain_impl,
- attrs = {
- "_build_template": attr.label(
- default = "//swift/internal/extensions:toolchain.BUILD",
- ),
- "platform": attr.string(
- doc = "The host platform name in the swift package download URL",
- mandatory = True,
- ),
- "sha256": attr.string(
- doc = "The expected SHA-256 of the file downloaded. This must match the SHA-256 of the file downloaded.",
- ),
- "swift_version": attr.string(
- doc = "Version of the swift toolchain to be installed.",
- mandatory = True,
- ),
- },
+_STANDALONE_TOOLCHAIN_ATTRS = {
+ "_build_template": attr.label(
+ default = "//swift/internal/extensions:toolchain.BUILD",
+ ),
+ "platform": attr.string(
+ doc = "The host platform name in the swift package download URL",
+ mandatory = True,
+ ),
+ "sha256": attr.string(
+ doc = "The expected SHA-256 of the file downloaded. This must match the SHA-256 of the file downloaded.",
+ ),
+ "swift_version": attr.string(
+ doc = "Version of the swift toolchain to be installed.",
+ mandatory = True,
+ ),
+}
+
+standalone_toolchain = repository_rule(
+ implementation = _standalone_toolchain_impl,
+ attrs = _STANDALONE_TOOLCHAIN_ATTRS,
+)
+
+standalone_macos_toolchain = repository_rule(
+ implementation = _standalone_toolchain_impl,
+ attrs = _STANDALONE_TOOLCHAIN_ATTRS,
+ configure = True,
+ environ = ["DEVELOPER_DIR"],
+ local = True,
)
diff --git a/swift/extensions.bzl b/swift/extensions.bzl
--- a/swift/extensions.bzl
+++ b/swift/extensions.bzl
@@ -17 +17,5 @@
-load("//swift/internal/extensions:standalone_toolchain.bzl", "standalone_toolchain")
+load(
+ "//swift/internal/extensions:standalone_toolchain.bzl",
+ "standalone_macos_toolchain",
+ "standalone_toolchain",
+)
@@ -182,7 +186,8 @@ def _standalone_toolchain_impl(module_ctx):
toolchain_releases = toolchain.platform_sha256.items() or swift_releases[swift_version].items()
for platform, sha256 in toolchain_releases:
repository_name = toolchain.name + "_{}".format(platform)
- standalone_toolchain(
+ toolchain_repository = standalone_macos_toolchain if platform == "xcode" else standalone_toolchain
+ toolchain_repository(
name = repository_name,
sha256 = sha256,
platform = platform,
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"integrity": "sha256-Ly2lS4AlZJMiyqAxKHyCB+2pGeP5aYkQ6zv8QheeSTI=",
"url": "https://github.com/bazelbuild/rules_swift/releases/download/4.0.0-rc5/rules_swift.4.0.0-rc5.tar.gz",
"patches": {
"register_downloaded_macos_toolchain.patch": "sha256-249WJ4YEH2HmxlvGftl4eD53792joKJx9Dh0j5eHAgo=",
"external_static_runtime.patch": "sha256-VY8UPZjCdlLjDB4taEpRfENRlkw4pGNYD2MAgNFITC4="
"external_static_runtime.patch": "sha256-bnyDyK3dU+vmNVKr16y0vMrtkUSYlVOkWtIBVtjqBGw=",
"register_downloaded_macos_toolchain.patch": "sha256-w6/S2LEFXEFE+eLUeowKl4mQ5bLvb2SxQknXfXEglyE="
},
"patch_strip": 1
}
2 changes: 1 addition & 1 deletion misc/bazel/registry/modules/rules_swift/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"github:bazelbuild/rules_swift"
],
"versions": [
"4.0.0-rc5-codeql.2"
"4.0.0-rc5-codeql.3"
],
"yanked_versions": {}
}
Loading