Skip to content

Commit 1529b58

Browse files
committed
Swift: add resource dir updater
1 parent e8b857b commit 1529b58

File tree

4 files changed

+57
-7
lines changed

4 files changed

+57
-7
lines changed

swift/third_party/BUILD.swift-toolchain-linux.bazel

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files")
1+
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
2+
load("@rules_pkg//pkg:pkg.bzl", "pkg_zip")
23

34
_strip_prefix = "usr/lib/swift"
45

@@ -42,8 +43,13 @@ _pm_interface_files = [
4243
for dir, interface, module in _pm_interface_files
4344
]
4445

45-
pkg_filegroup(
46-
name = "resource-dir",
46+
pkg_zip(
47+
name = "resource-dir-linux",
4748
srcs = [":resource-dir-original"] + [":pkg-%s" % module for _, _, module in _pm_interface_files],
49+
)
50+
51+
alias(
52+
name = "swift_toolchain_linux",
53+
actual = ":resource-dir-linux",
4854
visibility = ["//visibility:public"],
4955
)
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
2+
load("@rules_pkg//pkg:pkg.bzl", "pkg_zip")
23

34
_strip_prefix = "usr/lib/swift"
45

56
pkg_files(
6-
name = "resource-dir",
7+
name = "resource-dir-files",
78
srcs = glob(
89
["usr/lib/swift/**/*"],
910
),
1011
strip_prefix = _strip_prefix,
12+
)
13+
14+
pkg_zip(
15+
name = "resource-dir-macos",
16+
srcs = [":resource-dir-files"],
17+
)
18+
19+
alias(
20+
name = "swift_toolchain_macos",
21+
actual = ":resource-dir-macos",
1122
visibility = ["//visibility:public"],
1223
)
+24-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1-
load("//misc/bazel:pkg.bzl", "codeql_pkg_zip")
1+
load("//misc/bazel:pkg.bzl", "codeql_pkg_zip_import")
22

3-
codeql_pkg_zip(
3+
codeql_pkg_zip_import(
44
name = "resource-dir",
55
src = select({"@platforms//os:" + os: "@swift-resource-dir-" + os for os in ("linux", "macos")}),
66
arch_specific = True,
7-
target_compatible_with = select({"@platforms//os:windows": ["@platforms//:incompatible"]}),
7+
target_compatible_with = select({
8+
"@platforms//os:windows": ["@platforms//:incompatible"],
9+
"//conditions:default": [],
10+
}),
811
visibility = ["//swift:__pkg__"],
912
)
13+
14+
[
15+
sh_binary(
16+
name = "update-" + os,
17+
srcs = ["update.sh"],
18+
args = [
19+
"$(rlocationpath @swift_toolchain_%s)" % os,
20+
"$(rlocationpath resource-dir-%s.zip)" % os,
21+
],
22+
data = [
23+
"resource-dir-%s.zip" % os,
24+
"@swift_toolchain_" + os,
25+
],
26+
target_compatible_with = ["@platforms//os:" + os],
27+
deps = ["@bazel_tools//tools/bash/runfiles"],
28+
)
29+
for os in ("linux", "macos")
30+
]

swift/third_party/resource-dir/update.sh

100644100755
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# --- begin runfiles.bash initialization v3 ---
2+
# Copy-pasted from the Bazel Bash runfiles library v3.
3+
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
4+
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
5+
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
6+
source "$0.runfiles/$f" 2>/dev/null || \
7+
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
8+
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
9+
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
10+
# --- end runfiles.bash initialization v3 ---
11+
12+
cp "$(rlocation "$1")" "$(rlocation "$2")"

0 commit comments

Comments
 (0)