Skip to content

Commit

Permalink
Swift: remove linux from standard pack
Browse files Browse the repository at this point in the history
This still defines a pack with linux included for development.
`//swift:install` will still also include linux.
  • Loading branch information
Paolo Tranquilli committed Dec 13, 2024
1 parent 2cbb072 commit a75f5fa
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 28 deletions.
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)
82 changes: 54 additions & 28 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,35 +31,31 @@ 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",
],
prefix = "tools",
name = "extractor",
srcs = select_os(
posix = [
"//swift/extractor:pkg",
],
),
prefix = "tools/{CODEQL_PLATFORM}",
)

codeql_pkg_files(
Expand All @@ -70,22 +67,51 @@ codeql_pkg_files(
],
)

codeql_pack(
name = "swift",
pkg_filegroup(
name = "common",
srcs = [
":autobuilder",
":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 = [
":common",
] + select_os(
linux = [":extractor"] if linux_included else [],
macos = [":extractor"],
windows = [],
),
installer_alias = "install-linux" if linux_included else "install-other",
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",
)

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

0 comments on commit a75f5fa

Please sign in to comment.