@@ -182,16 +182,16 @@ export class CustomBuildTaskTerminal implements vscode.Pseudoterminal, proc.Outp
182
182
await this . runConfigTask ( ) ;
183
183
break ;
184
184
case CommandType . build :
185
- await this . runBuildTask ( ) ;
185
+ await this . runBuildTask ( CommandType . build ) ;
186
186
break ;
187
187
case CommandType . install :
188
- await this . runInstallTask ( ) ;
188
+ await this . runBuildTask ( CommandType . install ) ;
189
189
break ;
190
190
case CommandType . test :
191
191
await this . runTestTask ( ) ;
192
192
break ;
193
193
case CommandType . clean :
194
- await this . runCleanTask ( ) ;
194
+ await this . runBuildTask ( CommandType . clean ) ;
195
195
break ;
196
196
case CommandType . cleanRebuild :
197
197
await this . runCleanRebuildTask ( ) ;
@@ -272,7 +272,7 @@ export class CustomBuildTaskTerminal implements vscode.Pseudoterminal, proc.Outp
272
272
273
273
this . preset = await this . resolvePresetName ( this . preset , cmakeTools . useCMakePresets , CommandType . config ) ;
274
274
const configPreset : preset . ConfigurePreset | undefined = await cmakeTools ?. expandConfigPresetbyName ( this . preset ) ;
275
- const result = await cmakeDriver . configure ( ConfigureTrigger . taskProvider , [ ] , this , false , false , configPreset ) ;
275
+ const result = await cmakeDriver . configure ( ConfigureTrigger . taskProvider , [ ] , this , false , false , configPreset , this . options ) ;
276
276
if ( result === undefined || result === null ) {
277
277
this . writeEmitter . fire ( localize ( 'configure.terminated' , 'Configure was terminated' ) + endOfLine ) ;
278
278
this . closeEmitter . fire ( - 1 ) ;
@@ -287,7 +287,16 @@ export class CustomBuildTaskTerminal implements vscode.Pseudoterminal, proc.Outp
287
287
}
288
288
}
289
289
290
- private async runBuildTask ( ) : Promise < any > {
290
+ private async runBuildTask ( commandType : CommandType ) : Promise < any > {
291
+ let targets = this . targets ;
292
+ const taskName : string = localizeCommandType ( commandType ) ;
293
+ if ( commandType === CommandType . install ) {
294
+ this . checkTargets ( true ) ;
295
+ targets = [ 'install' ] ;
296
+ } else if ( commandType === CommandType . clean ) {
297
+ this . checkTargets ( true ) ;
298
+ targets = [ 'clean' ] ;
299
+ }
291
300
let fullCommand : proc . BuildCommand | null ;
292
301
let args : string [ ] = [ ] ;
293
302
const cmakeTools : CMakeTools | undefined = this . getCMakeTools ( ) ;
@@ -306,18 +315,18 @@ export class CustomBuildTaskTerminal implements vscode.Pseudoterminal, proc.Outp
306
315
const buildPreset : preset . BuildPreset | undefined = await cmakeTools ?. expandBuildPresetbyName ( this . preset ) ;
307
316
if ( ! buildPreset ) {
308
317
log . debug ( localize ( "build.preset.not.found" , 'Build preset not found.' ) ) ;
309
- this . writeEmitter . fire ( localize ( "build.failed" , "Build preset {0} not found. Build failed." , this . preset ) + endOfLine ) ;
318
+ this . writeEmitter . fire ( localize ( "build.failed" , "Build preset {0} not found. {1} failed." , this . preset , taskName ) + endOfLine ) ;
310
319
this . closeEmitter . fire ( - 1 ) ;
311
320
return ;
312
321
}
313
- fullCommand = await cmakeDriver . generateBuildCommandFromPreset ( buildPreset , this . targets ) ;
322
+ fullCommand = await cmakeDriver . generateBuildCommandFromPreset ( buildPreset , targets ) ;
314
323
if ( fullCommand ) {
315
324
cmakePath = fullCommand . command ;
316
325
args = fullCommand . args || [ ] ;
317
326
this . options . environment = EnvironmentUtils . merge ( [ fullCommand . build_env , this . options . environment ] , { preserveNull : true } ) ;
318
327
}
319
328
} else {
320
- fullCommand = await cmakeDriver . generateBuildCommandFromSettings ( this . targets ) ;
329
+ fullCommand = await cmakeDriver . generateBuildCommandFromSettings ( targets ) ;
321
330
if ( fullCommand ) {
322
331
cmakePath = fullCommand . command ;
323
332
args = fullCommand . args ? fullCommand . args : [ ] ;
@@ -326,44 +335,27 @@ export class CustomBuildTaskTerminal implements vscode.Pseudoterminal, proc.Outp
326
335
}
327
336
} else {
328
337
log . debug ( localize ( "cmake.driver.not.found" , 'CMake driver not found.' ) ) ;
329
- this . writeEmitter . fire ( localize ( "build.failed" , "Build failed." ) + endOfLine ) ;
338
+ this . writeEmitter . fire ( localize ( "build.failed" , "{0} failed." , taskName ) + endOfLine ) ;
330
339
this . closeEmitter . fire ( - 1 ) ;
331
340
return ;
332
341
}
333
- this . writeEmitter . fire ( localize ( "build.started" , "Build task started...." ) + endOfLine ) ;
342
+ this . writeEmitter . fire ( localize ( "build.started" , "{0} task started...." , taskName ) + endOfLine ) ;
334
343
this . writeEmitter . fire ( proc . buildCmdStr ( cmakePath , args ) + endOfLine ) ;
335
344
try {
336
345
const result : proc . ExecutionResult = await proc . execute ( cmakePath , args , this , this . options ) . result ;
337
346
if ( result . retc ) {
338
- this . writeEmitter . fire ( localize ( "build.finished.with.error" , "Build finished with error(s)." ) + endOfLine ) ;
347
+ this . writeEmitter . fire ( localize ( "build.finished.with.error" , "{0} finished with error(s)." , taskName ) + endOfLine ) ;
339
348
} else if ( result . stderr && ! result . stdout ) {
340
- this . writeEmitter . fire ( localize ( "build.finished.with.warnings" , "Build finished with warning(s)." ) + endOfLine ) ;
349
+ this . writeEmitter . fire ( localize ( "build.finished.with.warnings" , "{0} finished with warning(s)." , taskName ) + endOfLine ) ;
341
350
} else if ( result . stdout && result . stdout . includes ( "warning" ) ) {
342
- this . writeEmitter . fire ( localize ( "build.finished.with.warnings" , "Build finished with warning(s)." ) + endOfLine ) ;
351
+ this . writeEmitter . fire ( localize ( "build.finished.with.warnings" , "{0} finished with warning(s)." , taskName ) + endOfLine ) ;
343
352
} else {
344
- this . writeEmitter . fire ( localize ( "build.finished.successfully" , "Build finished successfully." ) + endOfLine ) ;
353
+ this . writeEmitter . fire ( localize ( "build.finished.successfully" , "{0} finished successfully." , taskName ) + endOfLine ) ;
345
354
}
346
355
this . closeEmitter . fire ( 0 ) ;
347
356
} catch {
348
- this . writeEmitter . fire ( localize ( "build.finished.with.error" , "Build finished with error(s)." ) + endOfLine ) ;
349
- this . closeEmitter . fire ( - 1 ) ;
350
- }
351
- }
352
-
353
- private async runInstallTask ( ) : Promise < any > {
354
- this . writeEmitter . fire ( localize ( "install.started" , "Install task started..." ) + endOfLine ) ;
355
- this . checkTargets ( true ) ;
356
- const cmakeTools : CMakeTools | undefined = this . getCMakeTools ( ) ;
357
- if ( ! cmakeTools ) {
358
- return ;
359
- }
360
- const result : number | undefined = await cmakeTools . runBuild ( [ 'install' ] , false , this ) ;
361
- if ( result === undefined ) {
362
- this . writeEmitter . fire ( localize ( 'install.terminated' , 'Install was terminated' ) + endOfLine ) ;
357
+ this . writeEmitter . fire ( localize ( "build.finished.with.error" , "{0} finished with error(s)." , taskName ) + endOfLine ) ;
363
358
this . closeEmitter . fire ( - 1 ) ;
364
- } else {
365
- this . writeEmitter . fire ( localize ( 'install.finished.with.code' , 'Install finished with return code {0}' , result ) + endOfLine ) ;
366
- this . closeEmitter . fire ( result ) ;
367
359
}
368
360
}
369
361
@@ -402,28 +394,10 @@ export class CustomBuildTaskTerminal implements vscode.Pseudoterminal, proc.Outp
402
394
}
403
395
}
404
396
405
- private async runCleanTask ( ignoreTargets : boolean = true ) : Promise < any > {
406
- this . writeEmitter . fire ( localize ( "clean.started" , "Clean task started..." ) + endOfLine ) ;
407
- this . checkTargets ( ignoreTargets ) ;
408
- const cmakeTools : CMakeTools | undefined = this . getCMakeTools ( ) ;
409
- if ( ! cmakeTools ) {
410
- return ;
411
- }
412
- const result : number | undefined = await cmakeTools . runBuild ( [ 'clean' ] , false , this ) ;
413
- if ( result === undefined || result !== 0 ) {
414
- this . writeEmitter . fire ( localize ( "clean.failed" , "Clean task failed." ) + endOfLine ) ;
415
- this . closeEmitter . fire ( - 1 ) ;
416
- } else {
417
- this . writeEmitter . fire ( localize ( "clean.finished.with.code" , "Clean finished with return code {0}" , result ) + endOfLine ) ;
418
- this . closeEmitter . fire ( result ) ;
419
- }
420
- return result ;
421
- }
422
-
423
397
private async runCleanRebuildTask ( ) : Promise < any > {
424
- const cleanResult = await this . runCleanTask ( false ) ;
398
+ const cleanResult = await this . runBuildTask ( CommandType . clean ) ;
425
399
if ( cleanResult === 0 ) {
426
- await this . runBuildTask ( ) ;
400
+ await this . runBuildTask ( CommandType . build ) ;
427
401
}
428
402
}
429
403
}
0 commit comments