Skip to content

Commit 914b968

Browse files
committed
C#: Also inject /p:UseSharedCompilation=false to (x|ms)build.exe (Windows)
1 parent bf7437f commit 914b968

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

csharp/tools/tracing-config.lua

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
function RegisterExtractorPack(id)
2-
local extractor = GetPlatformToolsDirectory() ..
3-
'Semmle.Extraction.CSharp.Driver'
4-
if OperatingSystem == 'windows' then extractor = extractor .. '.exe' end
2+
function Exify(path)
3+
if OperatingSystem == 'windows' then return path .. '.exe' else return path end
4+
end
5+
6+
local extractor = Exify(GetPlatformToolsDirectory() .. 'Semmle.Extraction.CSharp.Driver')
57

68
function DotnetMatcherBuild(compilerName, compilerPath, compilerArguments,
79
_languageId)
@@ -48,10 +50,29 @@ function RegisterExtractorPack(id)
4850
return nil
4951
end
5052

53+
function MsBuildMatcher(compilerName, compilerPath, compilerArguments, _languageId)
54+
if MatchCompilerName('^' .. Exify('msbuild') .. '$', compilerName, compilerPath,
55+
compilerArguments) or
56+
MatchCompilerName('^' .. Exify('xbuild') .. '$', compilerName, compilerPath,
57+
compilerArguments) then
58+
return {
59+
order = ORDER_REPLACE,
60+
invocation = BuildExtractorInvocation(id, compilerPath,
61+
compilerPath,
62+
compilerArguments,
63+
nil, {
64+
'/p:UseSharedCompilation=false'
65+
})
66+
67+
}
68+
end
69+
end
70+
5171
local windowsMatchers = {
5272
DotnetMatcherBuild,
73+
MsBuildMatcher,
5374
CreatePatternMatcher({ '^csc.*%.exe$' }, MatchCompilerName, extractor, {
54-
prepend = {'--compiler', '"${compiler}"' },
75+
prepend = { '--compiler', '"${compiler}"' },
5576
order = ORDER_BEFORE
5677
}),
5778
CreatePatternMatcher({ '^fakes.*%.exe$', 'moles.*%.exe' },
@@ -94,23 +115,9 @@ function RegisterExtractorPack(id)
94115
extractor, {
95116
prepend = { '--compiler', '"${compiler}"' },
96117
order = ORDER_BEFORE
97-
}), function(compilerName, compilerPath, compilerArguments, _languageId)
98-
if MatchCompilerName('^msbuild$', compilerName, compilerPath,
99-
compilerArguments) or
100-
MatchCompilerName('^xbuild$', compilerName, compilerPath,
101-
compilerArguments) then
102-
return {
103-
order = ORDER_REPLACE,
104-
invocation = BuildExtractorInvocation(id, compilerPath,
105-
compilerPath,
106-
compilerArguments,
107-
nil, {
108-
'/p:UseSharedCompilation=false'
109-
})
110-
111-
}
112-
end
113-
end, function(compilerName, compilerPath, compilerArguments, _languageId)
118+
}),
119+
MsBuildMatcher,
120+
function(compilerName, compilerPath, compilerArguments, _languageId)
114121
-- handle cases like `dotnet exec csc.dll <args>` and `mono(-sgen64) csc.exe <args>`
115122
if compilerName ~= 'dotnet' and not compilerName:match('^mono') then
116123
return nil

0 commit comments

Comments
 (0)