File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11load ("@bazel_tools//tools/build_defs/repo:http.bzl" , "http_archive" )
22load ("@bazel_tools//tools/build_defs/repo:utils.bzl" , "maybe" )
33
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+
529 maybe (
630 repo_rule = http_archive ,
731 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+
19cc_binary (
210 name = "extractor" ,
311 srcs = ["main.cpp" ],
@@ -7,4 +15,6 @@ cc_binary(
715 "//conditions:default" : ["@platforms//:incompatible" ],
816 }),
917 visibility = ["//swift:__pkg__" ],
18+ deps = [":swift-llvm-support" ],
19+ features = ["-universal_binaries" ],
1020)
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 22#include < iomanip>
33#include < stdlib.h>
44
5- int main () {
5+ #include < swift/Basic/LLVMInitialize.h>
6+
7+ int main (int argc, char ** argv) {
8+ PROGRAM_START (argc, argv);
69 if (auto trapDir = getenv (" CODEQL_EXTRACTOR_SWIFT_TRAP_DIR" )) {
710 std::string file = trapDir;
811 file += " /my_first.trap" ;
You can’t perform that action at this time.
0 commit comments