Skip to content

Commit d652b95

Browse files
authored
Merge pull request #4011 from hvitved/csharp/asp-extraction-pre-finalize
C#: Move ASP extraction from auto builder to `pre-finalize.{sh,cmd}`
2 parents 03e20ee + 8de57c7 commit d652b95

File tree

10 files changed

+34
-134
lines changed

10 files changed

+34
-134
lines changed

csharp/autobuilder/Semmle.Autobuild.CSharp.Tests/BuildScripts.cs

Lines changed: 17 additions & 52 deletions
Large diffs are not rendered by default.

csharp/autobuilder/Semmle.Autobuild.CSharp/AspBuildRule.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpAutobuilder.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ BuildScript IntermediateAttempt(BuildScript s) =>
8585
break;
8686
}
8787

88-
return
89-
attempt &
90-
(() => new AspBuildRule().Analyse(this, false)) &
91-
(() => new XmlBuildRule().Analyse(this, false));
88+
return attempt;
9289
}
9390

9491
/// <summary>

csharp/autobuilder/Semmle.Autobuild.CSharp/XmlBuildRule.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

csharp/autobuilder/Semmle.Autobuild.Shared/AutobuildOptions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public class AutobuildOptions
2929
public readonly bool NugetRestore;
3030

3131
public readonly Language Language;
32-
public readonly bool Indexing;
3332

3433
/// <summary>
3534
/// Reads options from environment variables.
@@ -54,8 +53,6 @@ public AutobuildOptions(IBuildActions actions, Language language)
5453
NugetRestore = actions.GetEnvironmentVariable(prefix + "NUGET_RESTORE").AsBool("nuget_restore", true);
5554

5655
Language = language;
57-
58-
Indexing = !actions.GetEnvironmentVariable($"CODEQL_AUTOBUILDER_{Language.UpperCaseName}_NO_INDEXING").AsBool("no_indexing", false);
5956
}
6057
}
6158

csharp/autobuilder/Semmle.Autobuild.Shared/Autobuilder.cs

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Semmle.Util.Logging;
1+
using Semmle.Util.Logging;
22
using System;
33
using System.Collections.Generic;
44
using System.IO;
@@ -190,21 +190,10 @@ public Autobuilder(IBuildActions actions, AutobuildOptions options)
190190
});
191191

192192
CodeQLExtractorLangRoot = Actions.GetEnvironmentVariable($"CODEQL_EXTRACTOR_{this.Options.Language.UpperCaseName}_ROOT");
193-
SemmleDist = Actions.GetEnvironmentVariable("SEMMLE_DIST");
194193
SemmlePlatformTools = Actions.GetEnvironmentVariable("SEMMLE_PLATFORM_TOOLS");
195194

196195
CodeQlPlatform = Actions.GetEnvironmentVariable("CODEQL_PLATFORM");
197196

198-
JavaHome =
199-
Actions.GetEnvironmentVariable("CODEQL_JAVA_HOME") ??
200-
Actions.GetEnvironmentVariable("SEMMLE_JAVA_HOME") ??
201-
throw new InvalidEnvironmentException("The environment variable CODEQL_JAVA_HOME or SEMMLE_JAVA_HOME has not been set.");
202-
203-
Distribution =
204-
CodeQLExtractorLangRoot ??
205-
SemmleDist ??
206-
throw new InvalidEnvironmentException($"The environment variable CODEQL_EXTRACTOR_{this.Options.Language.UpperCaseName}_ROOT or SEMMLE_DIST has not been set.");
207-
208197
TrapDir =
209198
Actions.GetEnvironmentVariable($"CODEQL_EXTRACTOR_{this.Options.Language.UpperCaseName}_TRAP_DIR") ??
210199
Actions.GetEnvironmentVariable("TRAP_FOLDER") ??
@@ -275,15 +264,6 @@ protected BuildScript AutobuildFailure() =>
275264
/// </summary>
276265
public string? CodeQLExtractorLangRoot { get; }
277266

278-
/// <summary>
279-
/// Value of SEMMLE_DIST environment variable.
280-
/// </summary>
281-
private string? SemmleDist { get; }
282-
283-
public string Distribution { get; }
284-
285-
public string JavaHome { get; }
286-
287267
/// <summary>
288268
/// Value of SEMMLE_PLATFORM_TOOLS environment variable.
289269
/// </summary>
@@ -298,13 +278,20 @@ protected BuildScript AutobuildFailure() =>
298278
/// The absolute path of the odasa executable.
299279
/// null if we are running in CodeQL.
300280
/// </summary>
301-
public string? Odasa => SemmleDist is null ? null : Actions.PathCombine(SemmleDist, "tools", "odasa");
281+
public string? Odasa
282+
{
283+
get
284+
{
285+
var semmleDist = Actions.GetEnvironmentVariable("SEMMLE_DIST");
286+
return semmleDist is null ? null : Actions.PathCombine(semmleDist, "tools", "odasa");
287+
}
288+
}
302289

303290
/// <summary>
304291
/// Construct a command that executed the given <paramref name="cmd"/> wrapped in
305292
/// an <code>odasa --index</code>, unless indexing has been disabled, in which case
306293
/// <paramref name="cmd"/> is run directly.
307294
/// </summary>
308-
public CommandBuilder MaybeIndex(CommandBuilder builder, string cmd) => Options.Indexing && !(Odasa is null) ? builder.IndexCommand(Odasa, cmd) : builder.RunCommand(cmd);
295+
public CommandBuilder MaybeIndex(CommandBuilder builder, string cmd) => Odasa is null ? builder.RunCommand(cmd) : builder.IndexCommand(Odasa, cmd);
309296
}
310297
}

csharp/tools/autobuild.cmd

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
@echo off
22

3-
rem The autobuilder is already being traced
4-
set CODEQL_AUTOBUILDER_CSHARP_NO_INDEXING=true
5-
63
type NUL && "%CODEQL_EXTRACTOR_CSHARP_ROOT%/tools/%CODEQL_PLATFORM%/Semmle.Autobuild.CSharp.exe"
74
exit /b %ERRORLEVEL%

csharp/tools/autobuild.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,4 @@ if [ "$CODEQL_PLATFORM" != "linux64" ] && [ "$CODEQL_PLATFORM" != "osx64" ] ; th
77
exit 1
88
fi
99

10-
# The autobuilder is already being traced
11-
CODEQL_AUTOBUILDER_CSHARP_NO_INDEXING="true"
12-
export CODEQL_AUTOBUILDER_CSHARP_NO_INDEXING
13-
1410
"$CODEQL_EXTRACTOR_CSHARP_ROOT/tools/$CODEQL_PLATFORM/Semmle.Autobuild.CSharp" || exit $?

csharp/tools/pre-finalize.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ type NUL && "%CODEQL_DIST%\codeql" database index-files ^
99
--language xml ^
1010
-- ^
1111
"%CODEQL_EXTRACTOR_CSHARP_WIP_DATABASE%"
12+
IF %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%
13+
14+
type NUL && "%CODEQL_JAVA_HOME%\bin\java.exe" -jar "%CODEQL_EXTRACTOR_CSHARP_ROOT%\tools\extractor-asp.jar" .
1215
exit /b %ERRORLEVEL%

csharp/tools/pre-finalize.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ set -eu
1010
--size-limit 10m \
1111
--language xml \
1212
-- \
13-
"$CODEQL_EXTRACTOR_CSHARP_WIP_DATABASE"
13+
"$CODEQL_EXTRACTOR_CSHARP_WIP_DATABASE"
14+
15+
"$CODEQL_JAVA_HOME/bin/java" -jar "$CODEQL_EXTRACTOR_CSHARP_ROOT/tools/extractor-asp.jar" .

0 commit comments

Comments
 (0)