Skip to content

Commit

Permalink
Support Omit Load Compile Command for Higher Performace Experience
Browse files Browse the repository at this point in the history
  • Loading branch information
FANG.Ge authored and xiaoyun94 committed Jul 6, 2022
1 parent 2e45107 commit 1397907
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion i18n/chs/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,6 @@
"cmake-tools.configuration.cmake.launchBehavior.description": "控制启动目标时启动终端将执行的操作。",
"cmake-tools.configuration.cmake.launchBehavior.reuseTerminal.description": "已重用启动终端实例,并且目标将在终端空闲时立即启动。",
"cmake-tools.configuration.cmake.launchBehavior.breakAndReuseTerminal.description": "已重用启动终端实例,并且将在启动目标之前发送中断命令以终止任何活动的前台进程。",
"cmake-tools.configuration.cmake.launchBehavior.newTerminal.description": "已创建新的终端实例,并且已在其中启动目标。系统不会自动清理现有终端。"
"cmake-tools.configuration.cmake.launchBehavior.newTerminal.description": "已创建新的终端实例,并且已在其中启动目标。系统不会自动清理现有终端。",
"cmake-tools.configuration.cmake.omitLoadCompileCommand.description" : "跳过加载 compile_commands.json, 牺牲部分功能以获取更高的性能体验。"
}
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,12 @@
"default": false,
"description": "%cmake-tools.configuration.cmake.ignoreCMakeListsMissing.description%",
"scope": "resource"
},
"cmake.omitLoadCompileCommand": {
"type": "boolean",
"default": false,
"description": "%cmake-tools.configuration.cmake.omitLoadCompileCommand.description%",
"scope": "resource"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,6 @@
"cmake-tools.configuration.cmake.launchBehavior.description": "Controls what happens with the launch terminal when you launch a target.",
"cmake-tools.configuration.cmake.launchBehavior.reuseTerminal.description": "The launch terminal instance is reused and the target will launch as soon as the terminal is idle.",
"cmake-tools.configuration.cmake.launchBehavior.breakAndReuseTerminal.description": "The launch terminal instance is reused and a break command is sent to terminate any active foreground process before launching the target.",
"cmake-tools.configuration.cmake.launchBehavior.newTerminal.description": "A new terminal instance is created and the target is launched in it. Existing terminals are not automatically cleaned up."
"cmake-tools.configuration.cmake.launchBehavior.newTerminal.description": "A new terminal instance is created and the target is launched in it. Existing terminals are not automatically cleaned up.",
"cmake-tools.configuration.cmake.omitLoadCompileCommand.description" : "Omit loading compile_commands.json, sacrifice some features for a higher performance experience."
}
5 changes: 3 additions & 2 deletions src/cmakeTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,9 @@ export class CMakeTools implements api.CMakeToolsAPI {
log.debug(localize('cannot.copy.compile.commands', 'Cannot copy {1} because it does not exist at {0}', compdbPath, 'compile_commands.json'));
}
}

if (compdbPaths.length > 0) {
if (this.workspaceContext.config.omitLoadCompileCommand) {
this.compilationDatabase = null;
} else if (compdbPaths.length > 0) {
// Read the compilation database, and update our db property
const newDB = await CompilationDatabase.fromFilePaths(compdbPaths);
this.compilationDatabase = newDB;
Expand Down
5 changes: 5 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export interface ExtensionConfigurationSettings {
emscriptenSearchDirs: string[];
mergedCompileCommands: string | null;
copyCompileCommands: string | null;
omitLoadCompileCommand: boolean;
configureOnOpen: boolean | null;
configureOnEdit: boolean;
skipConfigureIfCachePresent: boolean | null;
Expand Down Expand Up @@ -400,6 +401,9 @@ export class ConfigurationReader implements vscode.Disposable {
get copyCompileCommands(): string | null {
return this.configData.copyCompileCommands;
}
get omitLoadCompileCommand(): boolean {
return this.configData.omitLoadCompileCommand;
}
get showSystemKits(): boolean {
return this.configData.showSystemKits;
}
Expand Down Expand Up @@ -469,6 +473,7 @@ export class ConfigurationReader implements vscode.Disposable {
emscriptenSearchDirs: new vscode.EventEmitter<string[]>(),
mergedCompileCommands: new vscode.EventEmitter<string | null>(),
copyCompileCommands: new vscode.EventEmitter<string | null>(),
omitLoadCompileCommand: new vscode.EventEmitter<boolean>(),
configureOnOpen: new vscode.EventEmitter<boolean | null>(),
configureOnEdit: new vscode.EventEmitter<boolean>(),
skipConfigureIfCachePresent: new vscode.EventEmitter<boolean | null>(),
Expand Down
1 change: 1 addition & 0 deletions test/unit-tests/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function createConfig(conf: Partial<ExtensionConfigurationSettings>): Configurat
emscriptenSearchDirs: [],
mergedCompileCommands: null,
copyCompileCommands: null,
omitLoadCompileCommand: false,
configureOnOpen: null,
configureOnEdit: true,
skipConfigureIfCachePresent: null,
Expand Down

0 comments on commit 1397907

Please sign in to comment.