diff --git a/example/qlt.conf.json b/example/qlt.conf.json index 26be63f..0071334 100644 --- a/example/qlt.conf.json +++ b/example/qlt.conf.json @@ -4,7 +4,14 @@ "CodeQLCLIBundle": "codeql-bundle-v2.15.5", "EnableCustomCodeQLBundles": true, "CodeQLStandardLibraryIdent": "codeql-cli_v2.15.5", - "ExportedCustomizationPacks" : [ - "qlt/cpp-customizations" + "CustomizationPacks" : [ + { + "Name": "qlt/cpp-customizations", + "Export" : true + }, + { + "Name": "qlt2/stuff2-tests", + "Export" : false + } ] } \ No newline at end of file diff --git a/src/CodeQLToolkit.Features/CodeQL/Commands/Targets/InstallCommand.cs b/src/CodeQLToolkit.Features/CodeQL/Commands/Targets/InstallCommand.cs index e649b41..8de989a 100644 --- a/src/CodeQLToolkit.Features/CodeQL/Commands/Targets/InstallCommand.cs +++ b/src/CodeQLToolkit.Features/CodeQL/Commands/Targets/InstallCommand.cs @@ -1,5 +1,6 @@ using CodeQLToolkit.Shared.CodeQL; using CodeQLToolkit.Shared.Types; +using CodeQLToolkit.Shared.Utils; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -26,7 +27,10 @@ public override void Run() if (Packs!=null && Packs.Length > 0) { Log.G().LogInformation($"Overriding Packs on the command line. The following Packs will be packaged:"); - installation.ExportedCustomizationPacks = Packs; + installation.CustomizationPacks = Packs.Select(p => new QLTCustomizationPack() + { + Name = p + }).ToArray(); } else { diff --git a/src/CodeQLToolkit.Features/Query/Commands/Targets/InstallQueryPacksCommandTarget.cs b/src/CodeQLToolkit.Features/Query/Commands/Targets/InstallQueryPacksCommandTarget.cs index 2f2e7df..f9aa111 100644 --- a/src/CodeQLToolkit.Features/Query/Commands/Targets/InstallQueryPacksCommandTarget.cs +++ b/src/CodeQLToolkit.Features/Query/Commands/Targets/InstallQueryPacksCommandTarget.cs @@ -41,12 +41,16 @@ public override void Run() Log.G().LogInformation("In bundle mode so filtering bundled packs..."); - foreach (var pack in config.ExportedCustomizationPacks) + foreach (var pack in config.CustomizationPacks) { - Log.G().LogInformation($"Pack {pack} will NOT installed because it is part of the bundle..."); + Log.G().LogInformation($"Pack {pack.Name} will NOT installed because it is part of the bundle..."); } - files = files.Where(f => !config.ExportedCustomizationPacks.Any(p => CodeQLPackReader.read(f).Name == p)).ToArray(); + files = files.Where(f => + // all things that are part of the customization pack must be excluded. + // if it is exported is not relevant here. + !config.CustomizationPacks.Any(p => CodeQLPackReader.read(f).Name == p.Name) + ).ToArray(); Log.G().LogInformation($"Got {files.Length} packs after filtering..."); diff --git a/src/CodeQLToolkit.Shared/CodeQL/CodeQLInstallation.cs b/src/CodeQLToolkit.Shared/CodeQL/CodeQLInstallation.cs index efaa90e..92cae6f 100644 --- a/src/CodeQLToolkit.Shared/CodeQL/CodeQLInstallation.cs +++ b/src/CodeQLToolkit.Shared/CodeQL/CodeQLInstallation.cs @@ -19,7 +19,7 @@ public class CodeQLInstallation public string CLIBundle { get; set; } public string StandardLibraryIdent { get; set; } public bool EnableCustomCodeQLBundles { get; set; } - public string[] ExportedCustomizationPacks { get; set; } + public QLTCustomizationPack[] CustomizationPacks { get; set; } public bool QuickBundle { get; set; } public string Base { get; set; } @@ -44,7 +44,7 @@ public static CodeQLInstallation LoadFromConfig(QLTConfig c) CLIBundle = config.CodeQLCLIBundle, StandardLibraryIdent = config.CodeQLStandardLibraryIdent, StandardLibraryVersion = config.CodeQLStandardLibrary, - ExportedCustomizationPacks = config.ExportedCustomizationPacks, + CustomizationPacks = config.CustomizationPacks, Base = config.Base }; @@ -53,9 +53,9 @@ public static CodeQLInstallation LoadFromConfig(QLTConfig c) public void LogPacksToBeBuilt() { - if(ExportedCustomizationPacks != null) + if(CustomizationPacks != null) { - foreach(var p in ExportedCustomizationPacks) + foreach(var p in CustomizationPacks) { Log.G().LogInformation($"Pack: {p}"); } @@ -274,14 +274,16 @@ private void CustomBundleInstall() var workingDirectory = Path.GetFullPath(Base); - if(ExportedCustomizationPacks == null || ExportedCustomizationPacks.Length == 0) + if(CustomizationPacks == null || CustomizationPacks.Length == 0) { throw new Exception("No packs are set to be exported. Please add at least one pack to export in your `qlt.conf.json` file under the property `ExportedCustomizationPacks`."); } Log.G().LogInformation($"Building custom bundle. This may take a while..."); - var packs = string.Join(" ", ExportedCustomizationPacks); + var packsToExport = CustomizationPacks.Where(p => p.Export == true).Select(p => p.Name).ToArray(); + + var packs = string.Join(" ", packsToExport); // next, we run the bundling tool. // typical command line: // codeql_bundle -b .\scratch\codeql-bundle-win64.tar.gz -o scratch\out -w .\tests\workspace\ --help diff --git a/src/CodeQLToolkit.Shared/Utils/QLTConfig.cs b/src/CodeQLToolkit.Shared/Utils/QLTConfig.cs index 2c0bba0..cb0b5dd 100644 --- a/src/CodeQLToolkit.Shared/Utils/QLTConfig.cs +++ b/src/CodeQLToolkit.Shared/Utils/QLTConfig.cs @@ -7,13 +7,19 @@ namespace CodeQLToolkit.Shared.Utils { + public class QLTCustomizationPack + { + public string Name { get; set; } + public bool Export { get; set; } + } + public class QLTConfig { public string CodeQLCLI { get; set; } public string CodeQLStandardLibrary { get; set; } public string CodeQLCLIBundle { get; set; } - public string[] ExportedCustomizationPacks { get; set; } + public QLTCustomizationPack[] CustomizationPacks { get; set; } public string CodeQLStandardLibraryIdent { get {