Skip to content

Commit 0c5e260

Browse files
authored
Merge pull request #18282 from github/redsun82/swift-remove-linux
Swift: remove linux from standard pack
2 parents 906c517 + a8238b1 commit 0c5e260

File tree

2 files changed

+77
-32
lines changed

2 files changed

+77
-32
lines changed

misc/bazel/utils.bzl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def select_os(linux = None, macos = None, windows = None, posix = None, otherwise = []):
2+
selection = {}
3+
if posix != None:
4+
if linux != None or macos != None:
5+
fail("select_os: cannot specify both posix and linux or macos")
6+
selection["@platforms//os:linux"] = posix
7+
selection["@platforms//os:macos"] = posix
8+
if linux != None:
9+
selection["@platforms//os:linux"] = linux
10+
if macos != None:
11+
selection["@platforms//os:macos"] = macos
12+
if windows != None:
13+
selection["@platforms//os:windows"] = windows
14+
if len(selection) < 3:
15+
selection["//conditions:default"] = otherwise
16+
elif otherwise != []:
17+
fail("select_os: cannot specify all three OSes and an otherwise")
18+
return select(selection)

swift/BUILD.bazel

Lines changed: 59 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ load(
55
"codeql_pkg_files",
66
"codeql_pkg_runfiles",
77
)
8+
load("//misc/bazel:utils.bzl", "select_os")
89

910
filegroup(
1011
name = "schema",
@@ -30,37 +31,39 @@ codeql_pkg_files(
3031
)
3132

3233
codeql_pkg_runfiles(
33-
name = "autobuilder",
34+
name = "autobuilder-files",
3435
exes = ["//swift/swift-autobuilder"],
3536
)
3637

3738
pkg_filegroup(
38-
name = "tools-arch",
39-
srcs = select({
40-
"@platforms//os:macos": [
41-
":autobuilder",
42-
"//swift/extractor:pkg",
43-
],
44-
"@platforms//os:linux": [
45-
":autobuilder-incompatible-os",
46-
"//swift/extractor:pkg",
39+
name = "autobuilder",
40+
srcs = select_os(
41+
macos = [
42+
":autobuilder-files",
4743
],
48-
"@platforms//os:windows": [
44+
otherwise = [
4945
":autobuilder-incompatible-os",
5046
],
51-
}),
52-
prefix = "{CODEQL_PLATFORM}",
47+
),
48+
prefix = "tools/{CODEQL_PLATFORM}",
5349
)
5450

5551
pkg_filegroup(
5652
name = "tools",
57-
srcs = [
58-
":tools-arch",
59-
"//swift/tools",
60-
],
53+
srcs = ["//swift/tools"],
6154
prefix = "tools",
6255
)
6356

57+
pkg_filegroup(
58+
name = "extractor",
59+
srcs = select_os(
60+
posix = [
61+
"//swift/extractor:pkg",
62+
],
63+
),
64+
prefix = "tools/{CODEQL_PLATFORM}",
65+
)
66+
6467
codeql_pkg_files(
6568
name = "root-files",
6669
srcs = [
@@ -70,22 +73,46 @@ codeql_pkg_files(
7073
],
7174
)
7275

73-
codeql_pack(
74-
name = "swift",
75-
srcs = [
76-
":root-files",
77-
":tools",
78-
"//swift/downgrades",
79-
],
80-
zips = select({
81-
"@platforms//os:windows": {},
82-
"//conditions:default": {
83-
"//swift/third_party/resources:dir": "resource-dir/{CODEQL_PLATFORM}",
84-
},
85-
}),
86-
)
76+
zip_map = {
77+
"//swift/third_party/resources:dir": "resource-dir/{CODEQL_PLATFORM}",
78+
}
79+
80+
[
81+
codeql_pack(
82+
name = "swift-linux-included" if linux_included else "swift",
83+
srcs = [
84+
":autobuilder",
85+
":root-files",
86+
":tools",
87+
"//swift/downgrades",
88+
] + select_os(
89+
linux = [":extractor"] if linux_included else [],
90+
macos = [":extractor"],
91+
windows = [],
92+
),
93+
installer_alias = "install-linux" if linux_included else "install-other",
94+
pack_prefix = "swift",
95+
zips = select_os(
96+
linux = zip_map if linux_included else {},
97+
macos = zip_map,
98+
windows = {},
99+
),
100+
)
101+
for linux_included in [
102+
True,
103+
False,
104+
]
105+
]
87106

88107
alias(
89108
name = "create-extractor-pack",
90-
actual = ":swift-installer",
109+
actual = ":install",
110+
)
111+
112+
alias(
113+
name = "install",
114+
actual = select_os(
115+
linux = ":install-linux",
116+
otherwise = ":install-other",
117+
),
91118
)

0 commit comments

Comments
 (0)