Skip to content

Commit

Permalink
Merge branch 'main' into dev/qarni/refactorExpansion
Browse files Browse the repository at this point in the history
  • Loading branch information
qarni authored Jul 23, 2024
2 parents 3a935ab + bbc74d8 commit 9a6df6b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Improvements:

- Add `Unspecified` option for selecting a kit variant to allow CMake itself to select the build type. [#3821](https://github.com/microsoft/vscode-cmake-tools/issues/3821)
- Skip loading variants when using CMakePresets. [#3300](https://github.com/microsoft/vscode-cmake-tools/issues/3300)
- Add setting to only show the cmake log on target failure. [#3785](https://github.com/microsoft/vscode-cmake-tools/pull/3785) [@stepeos](https://github.com/stepeos)
- Preset expansion occurs on `CMakePresets.json` or `CMakeUserPresets.json` save, and if there are no errors the expanded presets are cached. The VS Developer Environment will only be applied to a preset if it is selected. Expansion errors will show in the problems panel and preset files with errors will be invalid, and any presets they contain cannot be used. [#3905](https://github.com/microsoft/vscode-cmake-tools/pull/3905)

Bug Fixes:
Expand All @@ -29,6 +30,7 @@ Bug Fixes:
- Fix localized file path for schema files. [#3872](https://github.com/microsoft/vscode-cmake-tools/issues/3872)
- Disable annoy and invalid extenion message about fix windows sdk for MSVC 2022. [#3837](https://github.com/microsoft/vscode-cmake-tools/pull/3837)
- Fix re-using a terminal for launching even when the environment has changed. [#3478](https://github.com/microsoft/vscode-cmake-tools/issues/3478)
- Don't require Ninja or Make on command line when checking for supported generators. [#3924](https://github.com/microsoft/vscode-cmake-tools/issues/3924)

## 1.18.43

Expand Down
2 changes: 1 addition & 1 deletion docs/cmake-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Options that support substitution, in the table below, allow variable references
| `cmake.copyCompileCommands`| If not `null`, copies the `compile_commands.json` file generated by CMake to the path specified by this setting whenever CMake successfully configures. | `null` (do not copy the file) | yes |
| `cmake.debugConfig`| The debug configuration to use when debugging a target | `null` (no values) | yes |
| `cmake.defaultVariants` | Override the default set of variants that will be supplied when no variants file is present. See [CMake variants](variants.md). | | no |
| `cmake.environment` | An object containing `key:value` pairs of environment variables, which will be available when configuring, building, debugging, running or testing with CTest. | `null` (no environment variables) | yes |
| `cmake.environment` | An object containing `key:value` pairs of environment variables, which will be available when configuring, building, or testing with CTest. | `null` (no environment variables) | yes |
| `cmake.generator` | Set to a string to override CMake Tools preferred generator logic. If set, CMake will unconditionally use it as the `-G` CMake generator command line argument. ||no|
| `cmake.installPrefix` | If specified, sets a value for `CMAKE_INSTALL_PREFIX` when running CMake configure. If not set, no value will be passed.</br>If `CMAKE_INSTALL_PREFIX` is set via `cmake.configureArgs` or `cmake.configureSettings`, `cmake.installPrefix` will be ignored.| `null` (no value specified) | yes |
| `cmake.loggingLevel` | A string setting that specifies how much output CMake Tools produces in its output channel. Set to one of `"trace"`, `"debug"`, `"info"`, `"note"`, `"warning"`, `"error"`, or `"fatal"`. `"trace"` is the most verbose.</br></br>Regardless of the logging level, CMake Tools writes all levels of logging to the CMake Tools log file. This file is useful if you need to [troubleshoot CMake Tools](troubleshoot.md) | `"info"` | no |
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3484,12 +3484,14 @@
"enum": [
"focus",
"always",
"never"
"never",
"error"
],
"enumDescriptions": [
"%cmake-tools.configuration.cmake.revealLog.focus.description%",
"%cmake-tools.configuration.cmake.revealLog.always.description%",
"%cmake-tools.configuration.cmake.revealLog.never.description%"
"%cmake-tools.configuration.cmake.revealLog.never.description%",
"%cmake-tools.configuration.cmake.revealLog.onError.description%"
],
"description": "%cmake-tools.configuration.cmake.revealLog.description%"
},
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
"cmake-tools.configuration.cmake.revealLog.focus.description": "The log appears and the output channel takes the cursor focus.",
"cmake-tools.configuration.cmake.revealLog.always.description": "The log appears but the output channel doesn't take the cursor focus.",
"cmake-tools.configuration.cmake.revealLog.never.description": "The log neither appears nor takes the focus.",
"cmake-tools.configuration.cmake.revealLog.onError.description": "The log appears only when the build or the configuration fails.",
"cmake-tools.configuration.cmake.exportCompileCommandsFile.description": "Enables exporting compile_commands.json. This only is used in Kits scenarios. In Presets scenarios, please set this by using CMakePresets.json",
"cmake-tools.configuration.cmake.useCMakePresets.description": "Use CMakePresets.json to configure drive CMake configure, build, and test. When using CMakePresets.json, kits, variants, and some settings in settings.json will be ignored.",
"cmake-tools.configuration.cmake.useVsDeveloperEnvironment.description": "When using CMake Presets on Windows, use the Visual Studio environment as the parent environment. Selecting auto will only apply the Visual Studio environment when we detect a supported compiler (cl, clang, clang-cl, clang-cpp, clang++), or the Ninja generator is being used.",
Expand Down
16 changes: 15 additions & 1 deletion src/cmakeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,8 @@ export class CMakeProject {
const result: ConfigureResult = await drv.configure(trigger, []);
if (result.result === 0) {
await this.refreshCompileDatabase(drv.expansionOptions);
} else {
log.showChannel(true);
}
await this.cTestController.refreshTests(drv);
this.onReconfiguredEmitter.fire();
Expand All @@ -1568,7 +1570,7 @@ export class CMakeProject {
return { result: -1, resultType: ConfigureResultType.NoCache };
}

return vscode.window.withProgress(
const res = await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Window,
title: localize('configuring.project', 'Configuring project'),
Expand Down Expand Up @@ -1646,6 +1648,7 @@ export class CMakeProject {
await enableFullFeatureSet(true);
await this.refreshCompileDatabase(drv.expansionOptions);
} else if (result.result !== 0 && (await this.getCMakeExecutable()).isDebuggerSupported && cmakeConfiguration.get(showDebuggerConfigurationString) && !forciblyCanceled && result.resultType === ConfigureResultType.NormalOperation) {
log.showChannel(true);
const yesButtonTitle: string = localize(
"yes.configureWithDebugger.button",
"Debug"
Expand Down Expand Up @@ -1695,6 +1698,11 @@ export class CMakeProject {
}
}
);
// check if the an error occured during the configuration
if (res.result !== 0) {
log.showChannel(true);
}
return res;
}

/**
Expand Down Expand Up @@ -1992,6 +2000,9 @@ export class CMakeProject {
buildLogger.info(localize('starting.build', 'Starting build'));
await setContextAndStore(isBuildingKey, true);
rc = await drv!.build(newTargets, taskConsumer, isBuildCommand);
if (rc !== 0) {
log.showChannel(true); // in case build has failed
}
await setContextAndStore(isBuildingKey, false);
if (rc === null) {
buildLogger.info(localize('build.was.terminated', 'Build was terminated'));
Expand Down Expand Up @@ -2022,6 +2033,9 @@ export class CMakeProject {
await setContextAndStore(isBuildingKey, true);
const rc = await drv!.build(newTargets, consumer, isBuildCommand);
await setContextAndStore(isBuildingKey, false);
if (rc !== 0) {
log.showChannel(true); // in case build has failed
}
if (rc === null) {
buildLogger.info(localize('build.was.terminated', 'Build was terminated'));
} else {
Expand Down
32 changes: 9 additions & 23 deletions src/drivers/cmakeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,25 +984,15 @@ export abstract class CMakeDriver implements vscode.Disposable {

for (const gen of preferredGenerators) {
const gen_name = gen.name;
const generator_present = await (async (): Promise<boolean> => {
if (gen_name === 'Ninja' || gen_name === 'Ninja Multi-Config') {
return await this.testHaveCommand('ninja') || this.testHaveCommand('ninja-build');
}
if (gen_name === 'MinGW Makefiles') {
return platform === 'win32' && this.testHaveCommand('mingw32-make');
}
if (gen_name === 'NMake Makefiles') {
return platform === 'win32' && this.testHaveCommand('nmake', ['/?']);
}
if (gen_name === 'Unix Makefiles') {
return this.testHaveCommand('make');
}
if (gen_name === 'MSYS Makefiles') {
return platform === 'win32' && this.testHaveCommand('make');
if (gen_name === 'Ninja' || gen_name === 'Ninja Multi-Config' ||
gen_name === 'Unix Makefiles') {
return gen;
} else if (gen_name === 'MinGW Makefiles' || gen_name === 'NMake Makefiles' ||
gen_name === 'MSYS Makefiles') {
if (platform === 'win32') {
return gen;
}
return false;
})();
if (!generator_present) {
} else {
const vsMatch = /^(Visual Studio \d{2} \d{4})($|\sWin64$|\sARM$)/.exec(gen.name);
if (platform === 'win32' && vsMatch) {
return {
Expand All @@ -1014,12 +1004,8 @@ export abstract class CMakeDriver implements vscode.Disposable {
if (gen.name.toLowerCase().startsWith('xcode') && platform === 'darwin') {
return gen;
}

// If the generator isn't found, move on to the next one
continue;
} else {
return gen;
}
// If the generator isn't supported on the current system, move on to the next one.
}
return null;
}
Expand Down
13 changes: 10 additions & 3 deletions src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum LogLevel {
Fatal,
}

type RevealLogKey = 'always' | 'never' | 'focus';
type RevealLogKey = 'always' | 'never' | 'focus' | 'error';

/**
* Get the name of a logging level
Expand Down Expand Up @@ -252,10 +252,17 @@ export class Logger {
SingletonLogger.instance().clearOutputChannel();
}

showChannel() {
showChannel(error_to_show?: boolean) {
const reveal_log = vscode.workspace.getConfiguration('cmake').get<RevealLogKey>('revealLog', 'always');

const should_show = (reveal_log !== 'never');
let should_show: boolean = false;
if (reveal_log === 'always') {
should_show = true;
}
// won't show if no target information
if (reveal_log === 'error' && error_to_show !== undefined) {
should_show = error_to_show;
}
const should_focus = (reveal_log === 'focus');

if (should_show) {
Expand Down

0 comments on commit 9a6df6b

Please sign in to comment.