Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ common --lockfile_mode=off
# Build release binaries by default, can be overwritten to in local.bazelrc and set to `fastbuild` or `dbg`
build --compilation_mode opt

# Preserve CodeQL's placeholder during rules_pkg variable substitution.
build --define=CODEQL_PLATFORM={CODEQL_PLATFORM}

# when building from this repository in isolation, the internal repository will not be found at ..
# where `MODULE.bazel` looks for it. The following will get us past the module loading phase, so
# that we can build things that do not rely on that
Expand Down
3 changes: 3 additions & 0 deletions .bazelrc.internal
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# this file should contain bazel settings required to build things from `semmle-code`

# Preserve CodeQL's placeholder during rules_pkg variable substitution.
build --define=CODEQL_PLATFORM={CODEQL_PLATFORM}

common --registry=file:///%workspace%/ql/misc/bazel/registry
common --registry=https://bcr.bazel.build

Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bazel_dep(name = "platforms", version = "1.1.0")
bazel_dep(name = "rules_cc", version = "0.2.27")
bazel_dep(name = "rules_go", version = "0.65.0")
bazel_dep(name = "rules_java", version = "9.9.0")
bazel_dep(name = "rules_pkg", version = "1.2.0")
bazel_dep(name = "rules_pkg", version = "1.3.0")
bazel_dep(name = "rules_nodejs", version = "6.7.7")
bazel_dep(name = "rules_python", version = "2.4.6")
bazel_dep(name = "rules_shell", version = "0.8.0")
Expand Down
18 changes: 16 additions & 2 deletions swift/extractor/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load("//misc/bazel:pkg.bzl", "codeql_pkg_files", "codeql_pkg_runfiles")
load("//misc/bazel:pkg.bzl", "codeql_pkg_files", "codeql_pkg_files_overlay", "codeql_pkg_runfiles")
load("//swift:rules.bzl", "swift_cc_binary")

swift_cc_binary(
Expand Down Expand Up @@ -31,9 +31,23 @@ sh_binary(
)

codeql_pkg_runfiles(
name = "pkg",
name = "extractor-files",
excludes = ["extractor.sh"], # script gets copied as "extractor", no need for the original .sh file
exes = [":extractor"],
)

codeql_pkg_files(
name = "shared-libraries",
exes = ["//swift/third_party/resources:shared-libraries"],
)

# Use original libraries: _solib artifacts can have owners that do not match their runfiles repository.
codeql_pkg_files_overlay(
name = "pkg",
srcs = [
":extractor-files",
":shared-libraries",
],
visibility = ["//swift:__pkg__"],
)

Expand Down
21 changes: 3 additions & 18 deletions swift/third_party/BUILD.swift-llvm-support.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,20 @@ cc_library(
"include",
"stdlib/public/SwiftShims",
],
visibility = ["//visibility:public"],
deps = [
"@zstd",
],
)

cc_library(
name = "swift-llvm-support",
filegroup(
name = "swift-llvm-support-shared",
srcs = glob(
[
"*.so",
"*.dylib",
],
allow_empty = True, # Either *.so or *.dylib will be empty
),
linkopts = [
"-lm",
"-lz",
] + select({
"@platforms//os:linux": [
"-luuid",
"-lrt",
"-lpthread",
"-ldl",
],
"@platforms//os:macos": [
"-L/usr/lib/swift",
],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [":swift-llvm-support-static"],
)
30 changes: 29 additions & 1 deletion swift/third_party/resources/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load("//misc/bazel:os.bzl", "os_select")

_oses = ("linux", "macos")

Expand All @@ -13,13 +15,39 @@ alias(
)

alias(
name = "shared-libraries",
actual = select({"@platforms//os:" + os: "@swift-prebuilt-%s//:swift-llvm-support-shared" % os for os in _oses}),
target_compatible_with = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//swift/extractor:__pkg__"],
)

cc_library(
name = "prebuilt",
actual = select({"@platforms//os:" + os: "@swift-prebuilt-%s//:swift-llvm-support" % os for os in _oses}),
srcs = [":shared-libraries"],
linkopts = [
"-lm",
"-lz",
] + os_select(
default = [],
linux = [
"-luuid",
"-lrt",
"-lpthread",
"-ldl",
],
macos = [
"-L/usr/lib/swift",
],
),
target_compatible_with = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = select({"@platforms//os:" + os: ["@swift-prebuilt-%s//:swift-llvm-support-static" % os] for os in _oses}),
)

[
Expand Down
Loading