Skip to content

Commit 9237335

Browse files
committed
Support overlay modes for "codeql database init"
1 parent 8c69433 commit 9237335

File tree

6 files changed

+42
-4
lines changed

6 files changed

+42
-4
lines changed

lib/codeql.js

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codeql.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import assert from "assert";
12
import * as fs from "fs";
23
import * as path from "path";
34

@@ -585,6 +586,18 @@ export async function getCodeQLForCmd(
585586
extraArgs.push(`--qlconfig-file=${qlconfigFile}`);
586587
}
587588

589+
let dbLocation = config.dbLocation;
590+
const overlayDatabaseEnv = process.env["CODEQL_OVERLAY_DATABASE_INIT"];
591+
if (overlayDatabaseEnv === "overlay") {
592+
assert(config.buildMode === BuildMode.None);
593+
extraArgs.push("--overlay");
594+
assert(config.languages.length === 1);
595+
dbLocation = path.join(dbLocation, config.languages[0]);
596+
} else if (overlayDatabaseEnv === "overlay-base") {
597+
assert(config.buildMode === BuildMode.None);
598+
extraArgs.push("--overlay-base");
599+
}
600+
588601
const overwriteFlag = isSupportedToolsFeature(
589602
await this.getVersion(),
590603
ToolsFeature.ForceOverwrite,
@@ -599,7 +612,7 @@ export async function getCodeQLForCmd(
599612
"init",
600613
overwriteFlag,
601614
"--db-cluster",
602-
config.dbLocation,
615+
dbLocation,
603616
`--source-root=${sourceRoot}`,
604617
"--calculate-language-specific-baseline",
605618
"--extractor-include-aliases",

src/init.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ export function cleanupDatabaseClusterDirectory(
163163
// for testing.
164164
rmSync = fs.rmSync,
165165
): void {
166+
const overlayDatabaseEnv = process.env["CODEQL_OVERLAY_DATABASE_INIT"];
167+
if (overlayDatabaseEnv === "overlay") {
168+
return;
169+
}
170+
166171
if (
167172
fs.existsSync(config.dbLocation) &&
168173
(fs.statSync(config.dbLocation).isFile() ||

0 commit comments

Comments
 (0)