Skip to content

Commit 73196fd

Browse files
authored
Merge pull request #11669 from github/redsun82/swift-wrapper
Swift: wrap extractor with shell script
2 parents 557a5b4 + 0dc717f commit 73196fd

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

swift/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ pkg_filegroup(
3939
visibility = ["//visibility:public"],
4040
)
4141

42-
pkg_runfiles(
42+
pkg_filegroup(
4343
name = "extractor",
44-
srcs = ["//swift/extractor"],
44+
srcs = ["//swift/extractor:pkg"],
4545
prefix = "tools/" + codeql_platform,
4646
)
4747

swift/extractor/BUILD.bazel

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
load("//swift:rules.bzl", "swift_cc_binary")
22
load("//misc/bazel/cmake:cmake.bzl", "generate_cmake")
3+
load("//misc/bazel:pkg_runfiles.bzl", "pkg_runfiles")
34

45
swift_cc_binary(
5-
name = "extractor",
6+
name = "extractor.real",
67
srcs = glob([
78
"*.h",
89
"*.cpp",
910
]),
10-
visibility = ["//swift:__pkg__"],
1111
deps = [
1212
"//swift/extractor/infra",
1313
"//swift/extractor/invocation",
@@ -19,6 +19,19 @@ swift_cc_binary(
1919

2020
generate_cmake(
2121
name = "cmake",
22-
targets = [":extractor"],
22+
targets = [":extractor.real"],
2323
visibility = ["//visibility:public"],
2424
)
25+
26+
sh_binary(
27+
name = "extractor",
28+
srcs = ["extractor.sh"],
29+
data = [":extractor.real"],
30+
)
31+
32+
pkg_runfiles(
33+
name = "pkg",
34+
srcs = [":extractor"],
35+
excludes = ["extractor.sh"], # script gets copied as "extractor", no need for the original .sh file
36+
visibility = ["//swift:__pkg__"],
37+
)

swift/extractor/extractor.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
if [[ "$(uname)" == Darwin ]]; then
4+
export DYLD_FALLBACK_LIBRARY_PATH=$(dirname "$0")
5+
else
6+
export LD_LIBRARY_PATH=$(dirname "$0")
7+
fi
8+
9+
exec -a "$0" "$0.real" "$@"

swift/tools/qltest.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ mkdir -p "$CODEQL_EXTRACTOR_SWIFT_TRAP_DIR"
44

55
QLTEST_LOG="$CODEQL_EXTRACTOR_SWIFT_LOG_DIR"/qltest.log
66

7-
export LD_LIBRARY_PATH="$CODEQL_EXTRACTOR_SWIFT_ROOT/tools/$CODEQL_PLATFORM"
8-
97
EXTRACTOR="$CODEQL_EXTRACTOR_SWIFT_ROOT/tools/$CODEQL_PLATFORM/extractor"
108
SDK="$CODEQL_EXTRACTOR_SWIFT_ROOT/qltest/$CODEQL_PLATFORM/sdk"
119

0 commit comments

Comments
 (0)