Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift: remove linux from standard pack #18282

Merged
merged 2 commits into from
Dec 13, 2024
Merged
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
18 changes: 18 additions & 0 deletions misc/bazel/utils.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def select_os(linux = None, macos = None, windows = None, posix = None, otherwise = []):
selection = {}
if posix != None:
if linux != None or macos != None:
fail("select_os: cannot specify both posix and linux or macos")
selection["@platforms//os:linux"] = posix
selection["@platforms//os:macos"] = posix
if linux != None:
selection["@platforms//os:linux"] = linux
if macos != None:
selection["@platforms//os:macos"] = macos
if windows != None:
selection["@platforms//os:windows"] = windows
if len(selection) < 3:
selection["//conditions:default"] = otherwise
elif otherwise != []:
fail("select_os: cannot specify all three OSes and an otherwise")
return select(selection)
91 changes: 59 additions & 32 deletions swift/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load(
"codeql_pkg_files",
"codeql_pkg_runfiles",
)
load("//misc/bazel:utils.bzl", "select_os")

filegroup(
name = "schema",
Expand All @@ -30,37 +31,39 @@ codeql_pkg_files(
)

codeql_pkg_runfiles(
name = "autobuilder",
name = "autobuilder-files",
exes = ["//swift/swift-autobuilder"],
)

pkg_filegroup(
name = "tools-arch",
srcs = select({
"@platforms//os:macos": [
":autobuilder",
"//swift/extractor:pkg",
],
"@platforms//os:linux": [
":autobuilder-incompatible-os",
"//swift/extractor:pkg",
name = "autobuilder",
srcs = select_os(
macos = [
":autobuilder-files",
],
"@platforms//os:windows": [
otherwise = [
":autobuilder-incompatible-os",
],
}),
prefix = "{CODEQL_PLATFORM}",
),
prefix = "tools/{CODEQL_PLATFORM}",
)

pkg_filegroup(
name = "tools",
srcs = [
":tools-arch",
"//swift/tools",
],
srcs = ["//swift/tools"],
prefix = "tools",
)

pkg_filegroup(
name = "extractor",
srcs = select_os(
posix = [
"//swift/extractor:pkg",
],
),
prefix = "tools/{CODEQL_PLATFORM}",
)

codeql_pkg_files(
name = "root-files",
srcs = [
Expand All @@ -70,22 +73,46 @@ codeql_pkg_files(
],
)

codeql_pack(
name = "swift",
srcs = [
":root-files",
":tools",
"//swift/downgrades",
],
zips = select({
"@platforms//os:windows": {},
"//conditions:default": {
"//swift/third_party/resources:dir": "resource-dir/{CODEQL_PLATFORM}",
},
}),
)
zip_map = {
"//swift/third_party/resources:dir": "resource-dir/{CODEQL_PLATFORM}",
}

[
codeql_pack(
name = "swift-linux-included" if linux_included else "swift",
srcs = [
":autobuilder",
":root-files",
":tools",
"//swift/downgrades",
] + select_os(
linux = [":extractor"] if linux_included else [],
macos = [":extractor"],
windows = [],
),
installer_alias = "install-linux" if linux_included else "install-other",
pack_prefix = "swift",
zips = select_os(
linux = zip_map if linux_included else {},
macos = zip_map,
windows = {},
),
)
for linux_included in [
True,
False,
]
]

alias(
name = "create-extractor-pack",
actual = ":swift-installer",
actual = ":install",
)

alias(
name = "install",
actual = select_os(
linux = ":install-linux",
otherwise = ":install-other",
),
)
Loading