Swift: add tracer config

This commit is contained in:
Alex Denisov
2022-04-28 13:17:35 +02:00
parent 4a03976a15
commit 5b75b4db79
2 changed files with 40 additions and 0 deletions

View File

@@ -17,6 +17,12 @@ pkg_files(
prefix = "tools",
)
pkg_files(
name = "tracing-config",
srcs = ["tools/tracing-config.lua"],
prefix = "tools",
)
pkg_files(
name = "manifest",
srcs = ["codeql-extractor.yml"],
@@ -28,6 +34,7 @@ pkg_filegroup(
":dbscheme",
":manifest",
":qltest",
":tracing-config",
],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,33 @@
function RegisterExtractorPack(id)
local extractorDirectory = GetPlatformToolsDirectory()
local relativeSwiftExtractor = extractorDirectory .. 'extractor'
local swiftExtractor = AbsolutifyExtractorPath(id, relativeSwiftExtractor)
function SwiftMatcher(compilerName, compilerPath, compilerArguments, lang)
-- Only match binaries names `swift-frontend`
if compilerName ~= 'swift-frontend' then return nil end
-- Skip the invocation in case it's not called in `-frontend` mode
if compilerArguments.argv[1] ~= '-frontend' then return nil end
-- Drop the `-frontend` argument
table.remove(compilerArguments.argv, 1)
-- Skip "info" queries in case there is nothing to extract
if compilerArguments.argv[1] == '-print-target-info' then return nil end
if compilerArguments.argv[1] == '-emit-supported-features' then return nil end
-- Skip actions in which we cannot extract anything
if compilerArguments.argv[1] == '-merge-modules' then return nil end
return {
trace = true,
replace = false,
invocations = {{path = swiftExtractor, arguments = compilerArguments}}
}
end
return { SwiftMatcher }
end
-- Return a list of minimum supported versions of the configuration file format
-- return one entry per supported major version.
function GetCompatibleVersions() return {'1.0.0'} end