Skip to content

Commit

Permalink
Re-merge two PR's (#2176)
Browse files Browse the repository at this point in the history
Co-authored-by: Andreea Isac <[email protected]>
  • Loading branch information
bobbrow and andreeis authored Oct 14, 2021
1 parent 0470334 commit bb88432
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/cmake-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1408,25 +1408,13 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
*/
async runBuild(targets_?: string[], showCommandOnly?: boolean): Promise<number> {
log.info(localize('run.build', 'Building folder: {0}', this.folderName), (targets_ && targets_.length > 0) ? targets_.join(', ') : '');
let targets = targets_;
let targetName: string;
const defaultBuildTargets = await this.getDefaultBuildTargets();
if (this.useCMakePresets) {
targets = (targets && targets.length > 0) ? targets : defaultBuildTargets;
targetName = `${this.buildPreset?.displayName || this.buildPreset?.name || ''}${targets ? (': ' + targets.join(', ')) : ''}`;
targetName = targetName || this.buildPreset?.displayName || this.buildPreset?.name || '';
} else {
targets = (targets && targets.length > 0) ? targets : defaultBuildTargets!;
targetName = targets.join(', ');
}

let drv: CMakeDriver | null;
if (showCommandOnly) {
drv = await this.getCMakeDriverInstance();
if (!drv) {
throw new Error(localize('failed.to.get.cmake.driver', 'Failed to get CMake driver'));
}
const buildCmd = await drv.getCMakeBuildCommand(targets);
const buildCmd = await drv.getCMakeBuildCommand(targets_);
if (buildCmd) {
log.showChannel();
log.info(buildCmdStr(buildCmd.command, buildCmd.args));
Expand All @@ -1446,6 +1434,18 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
if (!drv) {
throw new Error(localize('driver.died.after.successful.configure', 'CMake driver died immediately after successful configure'));
}
let targets = targets_;
let targetName: string;
const defaultBuildTargets = await this.getDefaultBuildTargets();
if (this.useCMakePresets) {
targets = (targets && targets.length > 0) ? targets : defaultBuildTargets;
targetName = `${this.buildPreset?.displayName || this.buildPreset?.name || ''}${targets ? (': ' + targets.join(', ')) : ''}`;
targetName = targetName || this.buildPreset?.displayName || this.buildPreset?.name || '';
} else {
targets = (targets && targets.length > 0) ? targets : defaultBuildTargets!;
targetName = targets.join(', ');
}

this.updateDriverAndTargetsInTaskProvider(drv, targets);
const consumer = new CMakeBuildConsumer(BUILD_LOGGER, drv.config);
const IS_BUILDING_KEY = 'cmake:isBuilding';
Expand Down

0 comments on commit bb88432

Please sign in to comment.