mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Swift: fetch prebuilt swift and link against it
This is known to break linux integration in sembuild.
This commit is contained in:
@@ -2,6 +2,17 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
||||
|
||||
def codeql_workspace():
|
||||
for arch, repo_arch, sha256 in (
|
||||
("linux", "linux", "48e39228e49aa560f0c1e504c4f9d488e28278b31fedc8271ce4cf807d9f7791"),
|
||||
("darwin_x86_64", "macos-x86_64", "8f1e8e9cfb4391b3fbc0b90da548a7e660f302b1a8551e6640e8a944eb377028"),
|
||||
):
|
||||
http_archive(
|
||||
name = "swift_prebuilt_%s" % arch,
|
||||
url = "https://github.com/dsp-testing/codeql-swift-artifacts/releases/download/swift-5.6-RELEASE.42271.49/swift-prebuilt-%s.zip" % repo_arch,
|
||||
build_file = "@ql//swift/extractor:BUILD.swift-prebuilt.bazel",
|
||||
sha256 = sha256,
|
||||
)
|
||||
|
||||
maybe(
|
||||
repo_rule = http_archive,
|
||||
name = "rules_pkg",
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
alias(
|
||||
name = "swift-llvm-support",
|
||||
actual = select({
|
||||
"@bazel_tools//src/conditions:%s" % arch: "@swift_prebuilt_%s//:swift-llvm-support" % arch
|
||||
for arch in ("linux", "darwin_x86_64", "darwin_arm64")
|
||||
}),
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "extractor",
|
||||
srcs = ["main.cpp"],
|
||||
@@ -7,4 +15,5 @@ cc_binary(
|
||||
"//conditions:default": ["@platforms//:incompatible"],
|
||||
}),
|
||||
visibility = ["//swift:__pkg__"],
|
||||
deps = [":swift-llvm-support"],
|
||||
)
|
||||
|
||||
23
swift/extractor/BUILD.swift-prebuilt.bazel
Normal file
23
swift/extractor/BUILD.swift-prebuilt.bazel
Normal file
@@ -0,0 +1,23 @@
|
||||
cc_library(
|
||||
name = "swift-llvm-support",
|
||||
srcs = glob([
|
||||
"libswiftAndLlvmSupportReal.a",
|
||||
"libswiftAndLlvmSupportReal.so",
|
||||
]),
|
||||
hdrs = glob(["include/**/*"]),
|
||||
linkopts = [
|
||||
"-lm",
|
||||
"-lz",
|
||||
] + select({
|
||||
"@platforms//os:macos": ["-lcurses"],
|
||||
"@platforms//os:linux": [
|
||||
"-luuid",
|
||||
"-lrt",
|
||||
"-lpthread",
|
||||
"-ltinfo",
|
||||
"-ldl",
|
||||
],
|
||||
}),
|
||||
strip_include_prefix = "include",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@@ -2,7 +2,10 @@
|
||||
#include <iomanip>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
#include <swift/Basic/LLVMInitialize.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
PROGRAM_START(argc, argv);
|
||||
if (auto trapDir = getenv("CODEQL_EXTRACTOR_SWIFT_TRAP_DIR")) {
|
||||
std::string file = trapDir;
|
||||
file += "/my_first.trap";
|
||||
|
||||
Reference in New Issue
Block a user