Skip to content

Commit 5b75b4d

Browse files
committed
Swift: add tracer config
1 parent 4a03976 commit 5b75b4d

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

swift/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ pkg_files(
1717
prefix = "tools",
1818
)
1919

20+
pkg_files(
21+
name = "tracing-config",
22+
srcs = ["tools/tracing-config.lua"],
23+
prefix = "tools",
24+
)
25+
2026
pkg_files(
2127
name = "manifest",
2228
srcs = ["codeql-extractor.yml"],
@@ -28,6 +34,7 @@ pkg_filegroup(
2834
":dbscheme",
2935
":manifest",
3036
":qltest",
37+
":tracing-config",
3138
],
3239
visibility = ["//visibility:public"],
3340
)

swift/tools/tracing-config.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
function RegisterExtractorPack(id)
2+
local extractorDirectory = GetPlatformToolsDirectory()
3+
local relativeSwiftExtractor = extractorDirectory .. 'extractor'
4+
local swiftExtractor = AbsolutifyExtractorPath(id, relativeSwiftExtractor)
5+
6+
function SwiftMatcher(compilerName, compilerPath, compilerArguments, lang)
7+
-- Only match binaries names `swift-frontend`
8+
if compilerName ~= 'swift-frontend' then return nil end
9+
-- Skip the invocation in case it's not called in `-frontend` mode
10+
if compilerArguments.argv[1] ~= '-frontend' then return nil end
11+
12+
-- Drop the `-frontend` argument
13+
table.remove(compilerArguments.argv, 1)
14+
15+
-- Skip "info" queries in case there is nothing to extract
16+
if compilerArguments.argv[1] == '-print-target-info' then return nil end
17+
if compilerArguments.argv[1] == '-emit-supported-features' then return nil end
18+
19+
-- Skip actions in which we cannot extract anything
20+
if compilerArguments.argv[1] == '-merge-modules' then return nil end
21+
22+
return {
23+
trace = true,
24+
replace = false,
25+
invocations = {{path = swiftExtractor, arguments = compilerArguments}}
26+
}
27+
end
28+
return { SwiftMatcher }
29+
end
30+
31+
-- Return a list of minimum supported versions of the configuration file format
32+
-- return one entry per supported major version.
33+
function GetCompatibleVersions() return {'1.0.0'} end

0 commit comments

Comments
 (0)