Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions example/qlt.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -26,7 +27,10 @@ public override void Run()
if (Packs!=null && Packs.Length > 0)
{
Log<InstallCommand>.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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ public override void Run()
Log<InstallQueryPacksCommandTarget>.G().LogInformation("In bundle mode so filtering bundled packs...");


foreach (var pack in config.ExportedCustomizationPacks)
foreach (var pack in config.CustomizationPacks)
{
Log<InstallQueryPacksCommandTarget>.G().LogInformation($"Pack {pack} will NOT installed because it is part of the bundle...");
Log<InstallQueryPacksCommandTarget>.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<InstallQueryPacksCommandTarget>.G().LogInformation($"Got {files.Length} packs after filtering...");

Expand Down
14 changes: 8 additions & 6 deletions src/CodeQLToolkit.Shared/CodeQL/CodeQLInstallation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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
};

Expand All @@ -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<CodeQLInstallation>.G().LogInformation($"Pack: {p}");
}
Expand Down Expand Up @@ -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<CodeQLInstallation>.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
Expand Down
8 changes: 7 additions & 1 deletion src/CodeQLToolkit.Shared/Utils/QLTConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down