Skip to content

Commit

Permalink
Merge pull request #18282 from github/redsun82/swift-remove-linux
Browse files Browse the repository at this point in the history
Swift: remove linux from standard pack
  • Loading branch information
redsun82 authored Dec 13, 2024
2 parents 906c517 + a8238b1 commit 0c5e260
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 32 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)
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",
),
)

0 comments on commit 0c5e260

Please sign in to comment.