Skip to content

Commit

Permalink
Introduce extractor option for binlog
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasvajk committed Jun 4, 2024
1 parent a9dee1c commit 339b2f0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions csharp/autobuilder/Semmle.Autobuild.CSharp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ codeql_csharp_binary(
"//csharp/autobuilder/Semmle.Autobuild.Shared",
"//csharp/extractor/Semmle.Extraction.CSharp",
"//csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching",
"//csharp/extractor/Semmle.Extraction.CSharp.Driver:bin/Semmle.Extraction.CSharp.Driver",
"//csharp/extractor/Semmle.Extraction.CSharp.Standalone:bin/Semmle.Extraction.CSharp.Standalone",
"//csharp/extractor/Semmle.Util",
"@paket.main//microsoft.build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class CSharpAutobuildOptions : AutobuildOptionsShared
private const string extractorOptionPrefix = "CODEQL_EXTRACTOR_CSHARP_OPTION_";

public bool Buildless { get; }
public string? Binlog { get; }

public override Language Language => Language.CSharp;

Expand All @@ -29,7 +30,7 @@ public CSharpAutobuildOptions(IBuildActions actions) : base(actions)
actions.GetEnvironmentVariable(extractorOptionPrefix + "BUILDLESS").AsBool("buildless", false) ||
actions.GetEnvironmentVariable(buildModeEnvironmentVariable)?.ToLower() == "none";


Binlog = actions.GetEnvironmentVariable(extractorOptionPrefix + "BINLOG");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ProjectReference Include="..\..\extractor\Semmle.Util\Semmle.Util.csproj" />
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp\Semmle.Extraction.CSharp.csproj" />
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp.Standalone\Semmle.Extraction.CSharp.Standalone.csproj" />
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp.Driver\Semmle.Extraction.CSharp.Driver.csproj" />
<ProjectReference Include="..\..\extractor\Semmle.Extraction.CSharp.DependencyFetching\Semmle.Extraction.CSharp.DependencyFetching.csproj" />
<ProjectReference Include="..\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ internal class StandaloneBuildRule : IBuildRule<CSharpAutobuildOptions>
{
public BuildScript Analyse(IAutobuilder<CSharpAutobuildOptions> builder, bool auto)
{
return BuildScript.Create(_ => Semmle.Extraction.CSharp.Standalone.Program.Main([]));
return builder.Options.Binlog is string binlog
? BuildScript.Create(_ => Semmle.Extraction.CSharp.Driver.Main(["--binlog", binlog]))
: BuildScript.Create(_ => Semmle.Extraction.CSharp.Standalone.Program.Main([]));
}
}
}
6 changes: 6 additions & 0 deletions csharp/codeql-extractor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ options:
- progress+++
type: string
pattern: "^(off|errors|warnings|(info|progress)|(debug|progress\\+)|(trace|progress\\+\\+)|progress\\+\\+\\+)$"
binlog:
title: Binlog
description: >
EXPERIMENTAL. The value is a path to the MsBuild binary log file that should be extracted.
This option only works when `--build-mode none` is also specified.
type: string
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ codeql_csharp_binary(
"*.cs",
"Properties/*.cs",
]),
visibility = ["//csharp:__pkg__"],
visibility = ["//csharp:__subpackages__"],
deps = [
"//csharp/extractor/Semmle.Extraction.CSharp",
],
Expand Down

0 comments on commit 339b2f0

Please sign in to comment.