Skip to content

Commit ed85696

Browse files
committed
bundle integration; quick bundles as well as correct processing from configuration file.
1 parent ff30e7c commit ed85696

File tree

18 files changed

+175
-52
lines changed

18 files changed

+175
-52
lines changed

src/CodeQLToolkit.Core/Main.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static async Task<int> Main(string[] args)
2929
rootCommand.AddGlobalOption(Globals.BasePathOption);
3030
rootCommand.AddGlobalOption(Globals.AutomationTypeOption);
3131
rootCommand.AddGlobalOption(Globals.Development);
32+
rootCommand.AddGlobalOption(Globals.UseBundle);
3233

3334
var versionCommand = new Command("version", "Get the current tool version.");
3435
rootCommand.Add(versionCommand);

src/CodeQLToolkit.Features/Bundle/Lifecycle/BundleLifecycleFeature.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ public override LanguageType[] SupportedLangauges
3232

3333
public void Register(Command parentCommand)
3434
{
35-
Log<BundleLifecycleFeature>.G().LogInformation("Registering lifecycle submodule.");
35+
//Log<BundleLifecycleFeature>.G().LogInformation("Registering lifecycle submodule.");
3636

3737
var setCommand = new Command("set", "Functions pertaining to setting variables related to custom CodeQL bundles.");
38-
parentCommand.Add(setCommand);
38+
//parentCommand.Add(setCommand);
3939

4040
var enableCommand = new Command("enable-custom-bundles", "Enables custom CodeQL Bundles.");
41-
setCommand.Add(enableCommand);
41+
//setCommand.Add(enableCommand);
4242

4343
var disableCommand = new Command("disable-custom-bundles", "Disables custom CodeQL Bundles.");
44-
setCommand.Add(disableCommand);
44+
//setCommand.Add(disableCommand);
4545

4646
var getCommand = new Command("get", "Functions pertaining to getting variables related to CodeQL Bundles.");
47-
parentCommand.Add(getCommand);
47+
//parentCommand.Add(getCommand);
4848

4949
var getEnabledCommand = new Command("enabled", "Determines if custom CodeQL Bundles are enabled.");
50-
getCommand.Add(getEnabledCommand);
50+
//getCommand.Add(getEnabledCommand);
5151

5252
{
5353
enableCommand.SetHandler((basePath) =>

src/CodeQLToolkit.Features/Bundle/Lifecycle/Targets/GetEnabledCustomCodeQLBundlesLifecycleTarget.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ override public void Run()
2222
var config = c.FromFile();
2323

2424
Console.WriteLine($"---------current settings---------");
25-
Console.WriteLine($"CodeQL Custom Bundles Enabled: {config.EnableCustomCodeQLBundles}");
25+
//Console.WriteLine($"CodeQL Custom Bundles Enabled: {config.EnableCustomCodeQLBundles}");
2626
Console.WriteLine($"----------------------------------");
2727
Console.WriteLine("(hint: use `qlt bundle set` to modify these values.)");
2828

src/CodeQLToolkit.Features/Bundle/Lifecycle/Targets/SetDisableCustomCodeQLBundlesLifecycleTarget.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ override public void Run()
2121

2222
var config = c.FromFile();
2323

24-
config.EnableCustomCodeQLBundles = false;
24+
//config.EnableCustomCodeQLBundles = false;
2525

2626
config.ToFile();
2727

src/CodeQLToolkit.Features/Bundle/Lifecycle/Targets/SetEnableCustomCodeQLBundlesLifecycleTarget.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ override public void Run()
2121

2222
var config = c.FromFile();
2323

24-
config.EnableCustomCodeQLBundles = true;
24+
//config.EnableCustomCodeQLBundles = true;
2525

2626
config.ToFile();
2727

src/CodeQLToolkit.Features/CodeQL/Commands/CodeQLCommandFeature.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,31 @@ public void Register(Command parentCommand)
3939
parentCommand.Add(runCommand);
4040

4141
var installCommand = new Command("install", "Installs CodeQL (bundle or release distribution) locally.");
42-
//var useCommand = new Command("use", "Switches tooling to use a different CodeQL version and updates the paths accordingly.");
43-
//var listCommand = new Command("list", "Lists versions of CodeQL available locally.");
42+
var customBundleOption = new Option<bool>("--custom-bundle", () => false, "Build a custom bundle and compile the bundle.") { IsRequired = true};
43+
var quickBundleOption = new Option<bool>("--quick-bundle", () => false, "Build a custom bundle and DO NOT compile the bundle.") { IsRequired = true};
44+
var packsOption = new Option<string[]>("--packs", "When creating bundles, this specifies the packs to include, Example `pack1 pack2 pack3`. You may specify also as `--pack pack1 --pack2 --pack3`") { IsRequired = false, AllowMultipleArgumentsPerToken = true };
4445

45-
runCommand.Add(installCommand);
46-
//runCommand.Add(useCommand);
47-
//runCommand.Add(listCommand);
46+
installCommand.Add(customBundleOption);
47+
installCommand.Add(quickBundleOption);
48+
installCommand.Add(packsOption);
4849

49-
50-
installCommand.SetHandler((basePath, automationType) =>
50+
runCommand.Add(installCommand);
51+
52+
installCommand.SetHandler((basePath, automationType, customBundleOption, quickBundleOption, packs) =>
5153
{
5254
Log<CodeQLCommandFeature>.G().LogInformation("Executing install command...");
5355

5456
new InstallCommand()
5557
{
5658
Base = basePath,
5759
AutomationTarget = automationType,
60+
CustomBundles = customBundleOption,
61+
QuickBundles = quickBundleOption,
62+
Packs = packs
5863
}.Run();
5964

6065

61-
}, Globals.BasePathOption, Globals.AutomationTypeOption);
66+
}, Globals.BasePathOption, Globals.AutomationTypeOption, customBundleOption, quickBundleOption, packsOption);
6267
}
6368

6469
public int Run()

src/CodeQLToolkit.Features/CodeQL/Commands/Targets/InstallCommand.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,33 @@ namespace CodeQLToolkit.Features.CodeQL.Commands.Targets
1111
{
1212
public class InstallCommand : CommandTarget
1313
{
14-
14+
public bool CustomBundles { get; set; }
15+
public bool QuickBundles { get; set; }
16+
public string[] Packs { get; set; }
1517
public override void Run()
1618
{
1719
Log<InstallCommand>.G().LogInformation($"Running Install command");
1820

1921
// First, check if CodeQL is installed.
2022
var installation = CodeQLInstallation.LoadFromConfig(Base);
23+
if(CustomBundles || QuickBundles)
24+
{
25+
installation.EnableCustomCodeQLBundles = true;
26+
if (Packs!=null && Packs.Length > 0)
27+
{
28+
Log<InstallCommand>.G().LogInformation($"Overriding Packs on the command line. The following Packs will be packaged:");
29+
installation.ExportedCustomizationPacks = Packs;
30+
}
31+
else
32+
{
33+
Log<InstallCommand>.G().LogInformation($"Using `qlt.conf.json` to build list of packs to bundle. The following Packs will be packaged:");
34+
}
35+
36+
installation.LogPacksToBeBuilt();
37+
38+
39+
installation.QuickBundle = QuickBundles;
40+
}
2141

2242
Log<InstallCommand>.G().LogInformation($"Checking for installation...");
2343

@@ -32,7 +52,6 @@ public override void Run()
3252
Log<InstallCommand>.G().LogInformation($"Installing CodeQL...");
3353
installation.Install();
3454

35-
3655
// set the environment variable
3756
Log<InstallCommand>.G().LogInformation($"Setting QLT_CODEQL_HOME to {installation.CodeQLHome}...");
3857
Log<InstallCommand>.G().LogInformation($"Setting QLT_CODEQL_PATH to {installation.CodeQLToolBinary}...");

src/CodeQLToolkit.Features/Query/Commands/QueryCommandFeature.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public void Register(Command parentCommand)
3030

3131
runCommand.Add(installPacksQueryCommand);
3232

33-
installPacksQueryCommand.SetHandler((basePath) => new InstallQueryPacksCommandTarget() { Base = basePath }.Run(), Globals.BasePathOption);
33+
installPacksQueryCommand.SetHandler(
34+
(basePath, useBundle) => new InstallQueryPacksCommandTarget() { Base = basePath, UseBundle = useBundle}.Run(), Globals.BasePathOption, Globals.UseBundle);
3435

3536
}
3637

src/CodeQLToolkit.Features/Query/Commands/Targets/InstallQueryPacksCommandTarget.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using CodeQLToolkit.Shared.CodeQL;
2+
using Microsoft.VisualBasic;
23
using System;
34
using System.Collections.Generic;
45
using System.Diagnostics;
@@ -23,6 +24,10 @@ public override void Run()
2324
var installation = CodeQLInstallation.LoadFromConfig(Base);
2425

2526

27+
installation.EnableCustomCodeQLBundles = UseBundle;
28+
29+
installation.IsInstalledOrDie();
30+
2631
foreach ( string file in files )
2732
{
2833
Log<InstallQueryPacksCommandTarget>.G().LogInformation($"Installing qlpack {file}...");

src/CodeQLToolkit.Features/Test/Commands/Targets/Actions/ExecuteUnitTestsCommandTarget.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,9 @@ public override void Run()
7575
// Get A Copy of the installation
7676
var installation = CodeQLInstallation.LoadFromConfig(Base);
7777

78-
if(!installation.IsInstalled())
79-
{
80-
DieWithError($"Requested CodeQL Version ({CLIVersion}) Not Installed. Run `qlt codeql run install` before running this step.");
81-
}
78+
installation.EnableCustomCodeQLBundles = UseBundle;
8279

80+
installation.IsInstalledOrDie();
8381

8482
using (Process process = new Process())
8583
{

0 commit comments

Comments
 (0)