@@ -2,29 +2,75 @@ function RegisterExtractorPack(id)
2
2
local extractor = GetPlatformToolsDirectory () ..
3
3
' Semmle.Extraction.CSharp.Driver'
4
4
if OperatingSystem == ' windows' then extractor = extractor .. ' .exe' end
5
+
6
+ function DotnetMatcherBuild (compilerName , compilerPath , compilerArguments ,
7
+ _languageId )
8
+ if compilerName ~= ' dotnet' and compilerName ~= ' dotnet.exe' then
9
+ return nil
10
+ end
11
+
12
+ -- The dotnet CLI has the following usage instructions:
13
+ -- dotnet [sdk-options] [command] [command-options] [arguments]
14
+ -- we are interested in dotnet build, which has the following usage instructions:
15
+ -- dotnet [options] build [<PROJECT | SOLUTION>...]
16
+ -- For now, parse the command line as follows:
17
+ -- Everything that starts with `-` (or `/`) will be ignored.
18
+ -- The first non-option argument is treated as the command.
19
+ -- if that's `build`, we append `/p:UseSharedCompilation=false` to the command line,
20
+ -- otherwise we do nothing.
21
+ local match = false
22
+ local argv = compilerArguments .argv
23
+ if OperatingSystem == ' windows' then
24
+ -- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
25
+ -- or, at least, that it is close enough
26
+ argv =
27
+ NativeArgumentsToArgv (compilerArguments .nativeArgumentPointer )
28
+ end
29
+ for i , arg in ipairs (argv ) do
30
+ -- dotnet options start with either - or / (both are legal)
31
+ local firstCharacter = string.sub (arg , 1 , 1 )
32
+ if not (firstCharacter == ' -' ) and not (firstCharacter == ' /' ) then
33
+ Log (1 , ' Dotnet subcommand detected: %s' , arg )
34
+ if arg == ' build' then match = true end
35
+ break
36
+ end
37
+ end
38
+ if match then
39
+ return {
40
+ order = ORDER_REPLACE ,
41
+ invocation = BuildExtractorInvocation (id , compilerPath ,
42
+ compilerPath ,
43
+ compilerArguments , nil , {
44
+ ' /p:UseSharedCompilation=false'
45
+ })
46
+ }
47
+ end
48
+ return nil
49
+ end
50
+
5
51
local windowsMatchers = {
52
+ DotnetMatcherBuild ,
6
53
CreatePatternMatcher ({' ^dotnet%.exe$' }, MatchCompilerName , extractor , {
7
54
prepend = {' --dotnetexec' , ' --cil' },
8
55
order = ORDER_BEFORE
9
56
}),
10
57
CreatePatternMatcher ({' ^csc.*%.exe$' }, MatchCompilerName , extractor , {
11
58
prepend = {' --compiler' , ' "${compiler}"' , ' --cil' },
12
59
order = ORDER_BEFORE
13
-
14
60
}),
15
61
CreatePatternMatcher ({' ^fakes.*%.exe$' , ' moles.*%.exe' },
16
62
MatchCompilerName , nil , {trace = false })
17
63
}
18
64
local posixMatchers = {
19
- CreatePatternMatcher ({' ^mcs%.exe$' , ' ^csc%.exe$' }, MatchCompilerName ,
65
+ DotnetMatcherBuild ,
66
+ CreatePatternMatcher ({' ^mono' , ' ^dotnet$' }, MatchCompilerName ,
20
67
extractor , {
21
- prepend = {' --compiler ' , ' "${compiler}" ' , ' --cil' },
68
+ prepend = {' --dotnetexec ' , ' --cil' },
22
69
order = ORDER_BEFORE
23
-
24
70
}),
25
- CreatePatternMatcher ({' ^mono ' , ' ^dotnet $' }, MatchCompilerName ,
71
+ CreatePatternMatcher ({' ^mcs%.exe$ ' , ' ^csc%.exe $' }, MatchCompilerName ,
26
72
extractor , {
27
- prepend = {' --dotnetexec ' , ' --cil' },
73
+ prepend = {' --compiler ' , ' "${compiler}" ' , ' --cil' },
28
74
order = ORDER_BEFORE
29
75
}), function (compilerName , compilerPath , compilerArguments , _languageId )
30
76
if MatchCompilerName (' ^msbuild$' , compilerName , compilerPath ,
@@ -49,7 +95,6 @@ function RegisterExtractorPack(id)
49
95
else
50
96
return posixMatchers
51
97
end
52
-
53
98
end
54
99
55
100
-- Return a list of minimum supported versions of the configuration file format
0 commit comments