mirror of
https://github.com/github/codeql.git
synced 2025-12-20 18:56:32 +01:00
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using System.Linq;
|
|
using Semmle.Autobuild.Shared;
|
|
|
|
namespace Semmle.Autobuild.CSharp
|
|
{
|
|
/// <summary>
|
|
/// Build using standalone extraction.
|
|
/// </summary>
|
|
internal class StandaloneBuildRule : IBuildRule<CSharpAutobuildOptions>
|
|
{
|
|
private readonly string? dotNetPath;
|
|
|
|
internal StandaloneBuildRule(string? dotNetPath)
|
|
{
|
|
this.dotNetPath = dotNetPath;
|
|
}
|
|
|
|
public BuildScript Analyse(IAutobuilder<CSharpAutobuildOptions> builder, bool auto)
|
|
{
|
|
BuildScript GetCommand(string? solution)
|
|
{
|
|
string standalone;
|
|
if (builder.CodeQLExtractorLangRoot is not null && builder.CodeQlPlatform is not null)
|
|
{
|
|
standalone = builder.Actions.PathCombine(builder.CodeQLExtractorLangRoot, "tools", builder.CodeQlPlatform, "Semmle.Extraction.CSharp.Standalone");
|
|
}
|
|
else
|
|
{
|
|
return BuildScript.Failure;
|
|
}
|
|
|
|
var cmd = new CommandBuilder(builder.Actions);
|
|
cmd.RunCommand(standalone);
|
|
|
|
if (solution is not null)
|
|
cmd.QuoteArgument(solution);
|
|
|
|
if (!builder.Options.NugetRestore)
|
|
{
|
|
cmd.Argument("--skip-nuget");
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(this.dotNetPath))
|
|
{
|
|
cmd.Argument("--dotnet");
|
|
cmd.QuoteArgument(this.dotNetPath);
|
|
}
|
|
|
|
return cmd.Script;
|
|
}
|
|
|
|
if (!builder.Options.Buildless)
|
|
return BuildScript.Failure;
|
|
|
|
if (!builder.Options.Solution.Any())
|
|
return GetCommand(null);
|
|
|
|
var script = BuildScript.Success;
|
|
foreach (var solution in builder.Options.Solution)
|
|
script &= GetCommand(solution);
|
|
|
|
return script;
|
|
}
|
|
}
|
|
}
|