Skip to content

Commit fe0e622

Browse files
committed
Unified: Address Copilot code review
1 parent 8f5a8db commit fe0e622

2 files changed

Lines changed: 75 additions & 3 deletions

File tree

misc/bazel/registry/modules/rules_swift/4.0.0-rc5-codeql.1/patches/register_downloaded_macos_toolchain.patch

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,15 @@ diff --git a/swift/internal/extensions/toolchain.BUILD b/swift/internal/extensio
8787
diff --git a/swift/internal/extensions/standalone_toolchain.bzl b/swift/internal/extensions/standalone_toolchain.bzl
8888
--- a/swift/internal/extensions/standalone_toolchain.bzl
8989
+++ b/swift/internal/extensions/standalone_toolchain.bzl
90-
@@ -91,11 +91,13 @@ def _standalone_toolchain_impl(repository_ctx):
90+
@@ -91,11 +91,17 @@ def _standalone_toolchain_impl(repository_ctx):
9191
strip_prefix = filename.removesuffix(".tar.gz"),
9292
)
9393

94-
+ macos_sdkroot = _run(repository_ctx, ["xcrun", "--sdk", "macosx", "--show-sdk-path"]) if repository_ctx.attr.platform == "xcode" else ""
94+
+ macos_sdkroot = ""
95+
+ if repository_ctx.attr.platform == "xcode":
96+
+ macos_sdkroot = _run(repository_ctx, ["xcrun", "--sdk", "macosx", "--show-sdk-path"])
97+
+ repository_ctx.watch(macos_sdkroot)
98+
+
9599
repository_ctx.file(".swift-version", repository_ctx.attr.swift_version)
96100
repository_ctx.template(
97101
"BUILD.bazel",
@@ -101,3 +105,71 @@ diff --git a/swift/internal/extensions/standalone_toolchain.bzl b/swift/internal
101105
"{swift_version}": repository_ctx.attr.swift_version,
102106
},
103107
)
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,

misc/bazel/registry/modules/rules_swift/4.0.0-rc5-codeql.1/source.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"integrity": "sha256-Ly2lS4AlZJMiyqAxKHyCB+2pGeP5aYkQ6zv8QheeSTI=",
33
"url": "https://github.com/bazelbuild/rules_swift/releases/download/4.0.0-rc5/rules_swift.4.0.0-rc5.tar.gz",
44
"patches": {
5-
"register_downloaded_macos_toolchain.patch": "sha256-kFzGyE1MhhiDxUfEzRPUTahvycyy+VNgPzQ5I44zRYc="
5+
"register_downloaded_macos_toolchain.patch": "sha256-249WJ4YEH2HmxlvGftl4eD53792joKJx9Dh0j5eHAgo="
66
},
77
"patch_strip": 1
88
}

0 commit comments

Comments
 (0)