From 339b2f070ecd0822fae6b6e7250fb3fd7ba0cc0e Mon Sep 17 00:00:00 2001 From: Tamas Vajk Date: Fri, 24 May 2024 14:41:23 +0200 Subject: [PATCH] Introduce extractor option for binlog --- csharp/autobuilder/Semmle.Autobuild.CSharp/BUILD.bazel | 1 + .../Semmle.Autobuild.CSharp/CSharpAutobuilder.cs | 3 ++- .../Semmle.Autobuild.CSharp/Semmle.Autobuild.CSharp.csproj | 1 + .../Semmle.Autobuild.CSharp/StandaloneBuildRule.cs | 4 +++- csharp/codeql-extractor.yml | 6 ++++++ .../extractor/Semmle.Extraction.CSharp.Driver/BUILD.bazel | 2 +- 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/csharp/autobuilder/Semmle.Autobuild.CSharp/BUILD.bazel b/csharp/autobuilder/Semmle.Autobuild.CSharp/BUILD.bazel index 904edb3ca5596..b1143162a6464 100644 --- a/csharp/autobuilder/Semmle.Autobuild.CSharp/BUILD.bazel +++ b/csharp/autobuilder/Semmle.Autobuild.CSharp/BUILD.bazel @@ -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", diff --git a/csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpAutobuilder.cs b/csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpAutobuilder.cs index dafda9a8f2ab6..577eed2a0c8cf 100644 --- a/csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpAutobuilder.cs +++ b/csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpAutobuilder.cs @@ -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; @@ -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"); } } diff --git a/csharp/autobuilder/Semmle.Autobuild.CSharp/Semmle.Autobuild.CSharp.csproj b/csharp/autobuilder/Semmle.Autobuild.CSharp/Semmle.Autobuild.CSharp.csproj index 7c4f1d6817730..515fecd5bec69 100644 --- a/csharp/autobuilder/Semmle.Autobuild.CSharp/Semmle.Autobuild.CSharp.csproj +++ b/csharp/autobuilder/Semmle.Autobuild.CSharp/Semmle.Autobuild.CSharp.csproj @@ -6,6 +6,7 @@ + diff --git a/csharp/autobuilder/Semmle.Autobuild.CSharp/StandaloneBuildRule.cs b/csharp/autobuilder/Semmle.Autobuild.CSharp/StandaloneBuildRule.cs index 5b844e6cf6c84..e0e40213895fc 100644 --- a/csharp/autobuilder/Semmle.Autobuild.CSharp/StandaloneBuildRule.cs +++ b/csharp/autobuilder/Semmle.Autobuild.CSharp/StandaloneBuildRule.cs @@ -10,7 +10,9 @@ internal class StandaloneBuildRule : IBuildRule { public BuildScript Analyse(IAutobuilder 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([])); } } } diff --git a/csharp/codeql-extractor.yml b/csharp/codeql-extractor.yml index 6c3285c412b92..27e64e6e75b0e 100644 --- a/csharp/codeql-extractor.yml +++ b/csharp/codeql-extractor.yml @@ -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 diff --git a/csharp/extractor/Semmle.Extraction.CSharp.Driver/BUILD.bazel b/csharp/extractor/Semmle.Extraction.CSharp.Driver/BUILD.bazel index a32dc3a376502..c5e34f7977660 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.Driver/BUILD.bazel +++ b/csharp/extractor/Semmle.Extraction.CSharp.Driver/BUILD.bazel @@ -9,7 +9,7 @@ codeql_csharp_binary( "*.cs", "Properties/*.cs", ]), - visibility = ["//csharp:__pkg__"], + visibility = ["//csharp:__subpackages__"], deps = [ "//csharp/extractor/Semmle.Extraction.CSharp", ],