File tree Expand file tree Collapse file tree 4 files changed +67
-2
lines changed Expand file tree Collapse file tree 4 files changed +67
-2
lines changed Original file line number Diff line number Diff line change 1
1
load ("@bazel_tools//tools/build_defs/repo:http.bzl" , "http_archive" )
2
2
load ("@bazel_tools//tools/build_defs/repo:utils.bzl" , "maybe" )
3
3
4
- def codeql_workspace ():
4
+ _swift_prebuilt_version = "swift-5.6-RELEASE.42271.54"
5
+ _swift_sha_map = {
6
+ "linux" : "92b26fbbc45f812b0581385cc81470ab636fed9cff460052aa2173de765ddef4" ,
7
+ "macos-x86_64" : "b24f609c7868c1709e1e552e3b394664014e6a7f1e097522db80deb359bbcd2f" ,
8
+ }
9
+
10
+ _swift_arch_map = {
11
+ "linux" : "linux" ,
12
+ "macos-x86_64" : "darwin_x86_64" ,
13
+ }
14
+
15
+ def codeql_workspace (repository_name = "codeql" ):
16
+ for repo_arch , arch in _swift_arch_map .items ():
17
+ sha256 = _swift_sha_map [repo_arch ]
18
+
19
+ http_archive (
20
+ name = "swift_prebuilt_%s" % arch ,
21
+ url = "https://github.com/dsp-testing/codeql-swift-artifacts/releases/download/%s/swift-prebuilt-%s.zip" % (
22
+ _swift_prebuilt_version ,
23
+ repo_arch ,
24
+ ),
25
+ build_file = "@%s//swift/extractor:BUILD.swift-prebuilt.bazel" % repository_name ,
26
+ sha256 = sha256 ,
27
+ )
28
+
5
29
maybe (
6
30
repo_rule = http_archive ,
7
31
name = "rules_pkg" ,
Original file line number Diff line number Diff line change
1
+ alias (
2
+ name = "swift-llvm-support" ,
3
+ actual = select ({
4
+ "@bazel_tools//src/conditions:%s" % arch : "@swift_prebuilt_%s//:swift-llvm-support" % arch
5
+ for arch in ("linux" , "darwin_x86_64" , "darwin_arm64" )
6
+ }),
7
+ )
8
+
1
9
cc_binary (
2
10
name = "extractor" ,
3
11
srcs = ["main.cpp" ],
@@ -7,4 +15,6 @@ cc_binary(
7
15
"//conditions:default" : ["@platforms//:incompatible" ],
8
16
}),
9
17
visibility = ["//swift:__pkg__" ],
18
+ deps = [":swift-llvm-support" ],
19
+ features = ["-universal_binaries" ],
10
20
)
Original file line number Diff line number Diff line change
1
+ cc_library(
2
+ name = "swift-llvm-support",
3
+ srcs = [
4
+ "libCodeQLSwiftFrontendTool.a",
5
+ ] + select({
6
+ "@platforms//os:linux": [
7
+ "libCodeQLSwiftFrontendTool.so",
8
+ ],
9
+ "@platforms//os:macos": [
10
+ "libCodeQLSwiftFrontendTool.dylib",
11
+ ],
12
+ }),
13
+ hdrs = glob(["include/**/*"]),
14
+ linkopts = [
15
+ "-lm",
16
+ "-lz",
17
+ ] + select({
18
+ "@platforms//os:linux": [
19
+ "-luuid",
20
+ "-lrt",
21
+ "-lpthread",
22
+ "-ldl",
23
+ ],
24
+ "//conditions:default": [],
25
+ }),
26
+ strip_include_prefix = "include",
27
+ visibility = ["//visibility:public"],
28
+ )
Original file line number Diff line number Diff line change 2
2
#include < iomanip>
3
3
#include < stdlib.h>
4
4
5
- int main () {
5
+ #include < swift/Basic/LLVMInitialize.h>
6
+
7
+ int main (int argc, char ** argv) {
8
+ PROGRAM_START (argc, argv);
6
9
if (auto trapDir = getenv (" CODEQL_EXTRACTOR_SWIFT_TRAP_DIR" )) {
7
10
std::string file = trapDir;
8
11
file += " /my_first.trap" ;
You can’t perform that action at this time.
0 commit comments