Skip to content

Commit a75f5fa

Browse files
author
Paolo Tranquilli
committed
Swift: remove linux from standard pack
This still defines a pack with linux included for development. `//swift:install` will still also include linux.
1 parent 2cbb072 commit a75f5fa

File tree

2 files changed

+72
-28
lines changed

2 files changed

+72
-28
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: 54 additions & 28 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,35 +31,31 @@ 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(
56-
name = "tools",
57-
srcs = [
58-
":tools-arch",
59-
"//swift/tools",
60-
],
61-
prefix = "tools",
52+
name = "extractor",
53+
srcs = select_os(
54+
posix = [
55+
"//swift/extractor:pkg",
56+
],
57+
),
58+
prefix = "tools/{CODEQL_PLATFORM}",
6259
)
6360

6461
codeql_pkg_files(
@@ -70,22 +67,51 @@ codeql_pkg_files(
7067
],
7168
)
7269

73-
codeql_pack(
74-
name = "swift",
70+
pkg_filegroup(
71+
name = "common",
7572
srcs = [
73+
":autobuilder",
7674
":root-files",
77-
":tools",
7875
"//swift/downgrades",
7976
],
80-
zips = select({
81-
"@platforms//os:windows": {},
82-
"//conditions:default": {
83-
"//swift/third_party/resources:dir": "resource-dir/{CODEQL_PLATFORM}",
84-
},
85-
}),
8677
)
8778

79+
zip_map = {
80+
"//swift/third_party/resources:dir": "resource-dir/{CODEQL_PLATFORM}",
81+
}
82+
83+
[
84+
codeql_pack(
85+
name = "swift-linux-included" if linux_included else "swift",
86+
srcs = [
87+
":common",
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+
zips = select_os(
95+
linux = zip_map if linux_included else {},
96+
macos = zip_map,
97+
windows = {},
98+
),
99+
)
100+
for linux_included in [
101+
True,
102+
False,
103+
]
104+
]
105+
88106
alias(
89107
name = "create-extractor-pack",
90108
actual = ":swift-installer",
91109
)
110+
111+
alias(
112+
name = "install",
113+
actual = select_os(
114+
linux = ":install-linux",
115+
otherwise = ":install-other",
116+
),
117+
)

0 commit comments

Comments
 (0)