Skip to content

Commit

Permalink
Allow compatible CLIs to generate summary symbols file
Browse files Browse the repository at this point in the history
This should be much faster than generating it in the extension.
  • Loading branch information
nickrolfe committed Jul 5, 2024
1 parent 75ab23b commit fe79a9b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions extensions/ql-vscode/src/codeql-cli/cli-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface VersionResult {
export interface CliFeatures {
featuresInVersionResult?: boolean;
mrvaPackCreate?: boolean;
generateSummarySymbolMap?: boolean;
}

export interface VersionAndFeatures {
Expand Down
16 changes: 13 additions & 3 deletions extensions/ql-vscode/src/codeql-cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1211,13 +1211,19 @@ export class CodeQLCliServer implements Disposable {
outputPath: string,
endSummaryPath: string,
): Promise<string> {
const supportsGenerateSummarySymbolMap =
await this.cliConstraints.supportsGenerateSummarySymbolMap();
const subcommandArgs = [
"--format=text",
`--end-summary=${endSummaryPath}`,
"--sourcemap",
inputPath,
outputPath,
];
]
.concat(
supportsGenerateSummarySymbolMap
? ["--summary-symbol-map", "--minify-output"]
: [],
)
.concat([inputPath, outputPath]);
return await this.runCodeQlCliCommand(
["generate", "log-summary"],
subcommandArgs,
Expand Down Expand Up @@ -1953,4 +1959,8 @@ export class CliVersionConstraint {
async supportsMrvaPackCreate(): Promise<boolean> {
return (await this.cli.getFeatures()).mrvaPackCreate === true;
}

async supportsGenerateSummarySymbolMap(): Promise<boolean> {
return (await this.cli.getFeatures()).generateSummarySymbolMap === true;
}
}
11 changes: 9 additions & 2 deletions extensions/ql-vscode/src/run-queries-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,16 @@ export async function generateEvalLogSummaries(
await cliServer.generateJsonLogSummary(log, jsonSummary);

if (humanReadableSummary !== undefined) {
progress(progressUpdate(3, 3, "Generating summary symbols file"));
summarySymbols = outputDir.evalLogSummarySymbolsPath;
await generateSummarySymbolsFile(humanReadableSummary, summarySymbols);
if (
!(await cliServer.cliConstraints.supportsGenerateSummarySymbolMap())
) {
// We're using an old CLI that cannot generate the summary symbols file while generating the
// human-readable log summary. As a fallback, create it by parsing the human-readable
// summary.
progress(progressUpdate(3, 3, "Generating summary symbols file"));
await generateSummarySymbolsFile(humanReadableSummary, summarySymbols);
}
}
}

Expand Down

0 comments on commit fe79a9b

Please sign in to comment.