mirror of
https://github.com/github/codeql.git
synced 2025-12-16 08:43:11 +01:00
This is a necessary preparation for moving the C# dependency management to `paket`, which in turn is a necessary preparation for moving the C# build to bazel. As we discovered in https://github.com/github/codeql/pull/16376, `paket` tries to restore all projects recursively from the root folder. If we support building C# code under both `ql/csharp` and `ql/cpp`, we need to have a single lockfile under `ql`, as both codebases share the same set of dependencies (and utilities from `ql/csharp/extractor`). Then, `paket` will also try to restore things that look like "C# projects" in other languages' folders, which is not what we want. Therefore, we address this by moving all C# code into a common root directory, `ql/csharp`. This needs an internal PR to adjust the buildsystem to look for the autobuilder in the new location.
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using Semmle.Autobuild.Shared;
|
|
using Semmle.Util;
|
|
|
|
namespace Semmle.Autobuild.Cpp
|
|
{
|
|
/// <summary>
|
|
/// Encapsulates C++ build options.
|
|
/// </summary>
|
|
public class CppAutobuildOptions : AutobuildOptionsShared
|
|
{
|
|
public override Language Language => Language.Cpp;
|
|
|
|
|
|
/// <summary>
|
|
/// Reads options from environment variables.
|
|
/// Throws ArgumentOutOfRangeException for invalid arguments.
|
|
/// </summary>
|
|
public CppAutobuildOptions(IBuildActions actions) : base(actions)
|
|
{
|
|
}
|
|
}
|
|
|
|
public class CppAutobuilder : Autobuilder<CppAutobuildOptions>
|
|
{
|
|
public CppAutobuilder(IBuildActions actions, CppAutobuildOptions options) : base(actions, options, new DiagnosticClassifier()) { }
|
|
|
|
public override BuildScript GetBuildScript()
|
|
{
|
|
return
|
|
// First try MSBuild
|
|
new MsBuildRule().Analyse(this, true) |
|
|
// Then look for a script that might be a build script
|
|
(() => new BuildCommandAutoRule((_, f) => f(null)).Analyse(this, true)) |
|
|
// All attempts failed: print message
|
|
AutobuildFailure();
|
|
}
|
|
}
|
|
}
|