C#: Also inject /p:UseSharedCompilation=false to (x|ms)build.exe (Windows)

This commit is contained in:
Tom Hvitved
2022-08-31 09:03:12 +02:00
parent bf7437fd2e
commit 914b9680c0

View File

@@ -1,7 +1,9 @@
function RegisterExtractorPack(id) function RegisterExtractorPack(id)
local extractor = GetPlatformToolsDirectory() .. function Exify(path)
'Semmle.Extraction.CSharp.Driver' if OperatingSystem == 'windows' then return path .. '.exe' else return path end
if OperatingSystem == 'windows' then extractor = extractor .. '.exe' end end
local extractor = Exify(GetPlatformToolsDirectory() .. 'Semmle.Extraction.CSharp.Driver')
function DotnetMatcherBuild(compilerName, compilerPath, compilerArguments, function DotnetMatcherBuild(compilerName, compilerPath, compilerArguments,
_languageId) _languageId)
@@ -48,10 +50,29 @@ function RegisterExtractorPack(id)
return nil return nil
end end
function MsBuildMatcher(compilerName, compilerPath, compilerArguments, _languageId)
if MatchCompilerName('^' .. Exify('msbuild') .. '$', compilerName, compilerPath,
compilerArguments) or
MatchCompilerName('^' .. Exify('xbuild') .. '$', compilerName, compilerPath,
compilerArguments) then
return {
order = ORDER_REPLACE,
invocation = BuildExtractorInvocation(id, compilerPath,
compilerPath,
compilerArguments,
nil, {
'/p:UseSharedCompilation=false'
})
}
end
end
local windowsMatchers = { local windowsMatchers = {
DotnetMatcherBuild, DotnetMatcherBuild,
MsBuildMatcher,
CreatePatternMatcher({ '^csc.*%.exe$' }, MatchCompilerName, extractor, { CreatePatternMatcher({ '^csc.*%.exe$' }, MatchCompilerName, extractor, {
prepend = {'--compiler', '"${compiler}"' }, prepend = { '--compiler', '"${compiler}"' },
order = ORDER_BEFORE order = ORDER_BEFORE
}), }),
CreatePatternMatcher({ '^fakes.*%.exe$', 'moles.*%.exe' }, CreatePatternMatcher({ '^fakes.*%.exe$', 'moles.*%.exe' },
@@ -94,23 +115,9 @@ function RegisterExtractorPack(id)
extractor, { extractor, {
prepend = { '--compiler', '"${compiler}"' }, prepend = { '--compiler', '"${compiler}"' },
order = ORDER_BEFORE order = ORDER_BEFORE
}), function(compilerName, compilerPath, compilerArguments, _languageId) }),
if MatchCompilerName('^msbuild$', compilerName, compilerPath, MsBuildMatcher,
compilerArguments) or function(compilerName, compilerPath, compilerArguments, _languageId)
MatchCompilerName('^xbuild$', compilerName, compilerPath,
compilerArguments) then
return {
order = ORDER_REPLACE,
invocation = BuildExtractorInvocation(id, compilerPath,
compilerPath,
compilerArguments,
nil, {
'/p:UseSharedCompilation=false'
})
}
end
end, function(compilerName, compilerPath, compilerArguments, _languageId)
-- handle cases like `dotnet exec csc.dll <args>` and `mono(-sgen64) csc.exe <args>` -- handle cases like `dotnet exec csc.dll <args>` and `mono(-sgen64) csc.exe <args>`
if compilerName ~= 'dotnet' and not compilerName:match('^mono') then if compilerName ~= 'dotnet' and not compilerName:match('^mono') then
return nil return nil