From 2c3b07f3336de6122958990054d9eca99fcdf3f1 Mon Sep 17 00:00:00 2001 From: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com> Date: Thu, 10 Oct 2024 09:13:08 -0400 Subject: [PATCH 1/5] fix dropdown entries (#4106) --- CHANGELOG.md | 4 ++++ src/presetsController.ts | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14bd31689..1ae00875c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Features: - Add support for Presets v9, which enables more macro expansion for the `include` field. [#3946](https://github.com/microsoft/vscode-cmake-tools/issues/3946) +Bug Fixes: + +- Fix issue where duplicate presets are being listed in dropdown. [#4104](https://github.com/microsoft/vscode-cmake-tools/issues/4104) + ## 1.19.52 Improvements: diff --git a/src/presetsController.ts b/src/presetsController.ts index fc892da55..20b27eff7 100644 --- a/src/presetsController.ts +++ b/src/presetsController.ts @@ -1142,7 +1142,7 @@ export class PresetsController implements vscode.Disposable { preset.expandConfigurePresetForPresets(this.folderPath, 'build'); - const allPresets = preset.buildPresets(this.folderPath).concat(preset.userBuildPresets(this.folderPath)); + const allPresets = await this.getAllBuildPresets(); const presets = allPresets.filter(_preset => this.checkCompatibility(selectedConfigurePreset, _preset).buildPresetCompatible); presets.push(preset.defaultBuildPreset); @@ -1300,7 +1300,7 @@ export class PresetsController implements vscode.Disposable { preset.expandConfigurePresetForPresets(this.folderPath, 'test'); - const allPresets = preset.testPresets(this.folderPath).concat(preset.userTestPresets(this.folderPath)); + const allPresets = await this.getAllTestPresets(); const presets = allPresets.filter(_preset => this.checkCompatibility(selectedConfigurePreset, selectedBuildPreset, _preset).testPresetCompatible); presets.push(preset.defaultTestPreset); @@ -1392,7 +1392,7 @@ export class PresetsController implements vscode.Disposable { preset.expandConfigurePresetForPresets(this.folderPath, 'package'); - const allPresets = preset.packagePresets(this.folderPath).concat(preset.userPackagePresets(this.folderPath)); + const allPresets = await this.getAllPackagePresets(); const presets = allPresets.filter(_preset => this.checkCompatibility(selectedConfigurePreset, selectedBuildPreset, this.project.testPreset, _preset).packagePresetCompatible); presets.push(preset.defaultPackagePreset); @@ -1474,7 +1474,7 @@ export class PresetsController implements vscode.Disposable { preset.expandConfigurePresetForPresets(this.folderPath, 'workflow'); - const allPresets = preset.workflowPresets(this.folderPath).concat(preset.userWorkflowPresets(this.folderPath)); + const allPresets = await this.getAllWorkflowPresets(); allPresets.push(preset.defaultWorkflowPreset); log.debug(localize('start.selection.of.workflow.presets', 'Start selection of workflow presets. Found {0} presets.', allPresets.length)); From 1818a7ea522b48d791c6a83016b152b0a63ea2b7 Mon Sep 17 00:00:00 2001 From: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com> Date: Thu, 10 Oct 2024 09:44:26 -0400 Subject: [PATCH 2/5] only set isUserPreset to rue if it's defined in a user presets file (#4081) --- CHANGELOG.md | 1 + src/preset.ts | 41 ++++++++++++++++++++--------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ae00875c..60ce90126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Features: Bug Fixes: +- Fix our setting of `isUserPreset` for presets, only set it to `true` if it's defined in a user presets file. [#4059](https://github.com/microsoft/vscode-cmake-tools/issues/4059) - Fix issue where duplicate presets are being listed in dropdown. [#4104](https://github.com/microsoft/vscode-cmake-tools/issues/4104) ## 1.19.52 diff --git a/src/preset.ts b/src/preset.ts index bfa0abac6..4d87c79e5 100644 --- a/src/preset.ts +++ b/src/preset.ts @@ -467,24 +467,39 @@ export function setPresetsPlusIncluded(folder: string, presets: PresetsFile | un presetsPlusIncluded.set(folder, presets); } -export function setUserPresetsPlusIncluded(folder: string, presets: PresetsFile | undefined) { +export function setUserPresetsHelper(presets: PresetsFile | undefined) { if (presets) { + // for each condition of `isUserPreset`, if we don't find file.path, then we default to true like before. if (presets.configurePresets) { for (const configPreset of presets.configurePresets) { - configPreset.isUserPreset = true; + configPreset.isUserPreset = configPreset.__file?.__path?.endsWith("CMakeUserPresets.json") ?? true; } } if (presets.buildPresets) { for (const buildPreset of presets.buildPresets) { - buildPreset.isUserPreset = true; + buildPreset.isUserPreset = buildPreset.__file?.__path?.endsWith("CMakeUserPresets.json") ?? true; } } if (presets.testPresets) { for (const testPreset of presets.testPresets) { - testPreset.isUserPreset = true; + testPreset.isUserPreset = testPreset.__file?.__path?.endsWith("CMakeUserPresets.json") ?? true; + } + } + if (presets.packagePresets) { + for (const packagePreset of presets.packagePresets) { + packagePreset.isUserPreset = packagePreset.__file?.__path?.endsWith("CMakeUserPresets.json") ?? true; + } + } + if (presets.workflowPresets) { + for (const workflowPreset of presets.workflowPresets) { + workflowPreset.isUserPreset = workflowPreset.__file?.__path?.endsWith("CMakeUserPresets.json") ?? true; } } } +} + +export function setUserPresetsPlusIncluded(folder: string, presets: PresetsFile | undefined) { + setUserPresetsHelper(presets); userPresetsPlusIncluded.set(folder, presets); } @@ -544,23 +559,7 @@ function updateCachedExpandedPresethelper(cache: PresetsFile | undefined, preset } export function setExpandedUserPresetsFile(folder: string, presets: PresetsFile | undefined) { - if (presets) { - if (presets.configurePresets) { - for (const configPreset of presets.configurePresets) { - configPreset.isUserPreset = true; - } - } - if (presets.buildPresets) { - for (const buildPreset of presets.buildPresets) { - buildPreset.isUserPreset = true; - } - } - if (presets.testPresets) { - for (const testPreset of presets.testPresets) { - testPreset.isUserPreset = true; - } - } - } + setUserPresetsHelper(presets); expandedUserPresets.set(folder, presets); } From 0786aa8259472c74703f048e7a0140c0fc8febd5 Mon Sep 17 00:00:00 2001 From: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:23:17 -0400 Subject: [PATCH 3/5] determine shell for .cmd, .bat, .ps1 (#4044) * determine shell for .cmd, .bat, .ps1 * update changelog * only apply fix on windows, as necessary * undefined -> false * use concrete if statement * update changelog and change if statement order * nit: remove extra space --- CHANGELOG.md | 4 ++++ src/proc.ts | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60ce90126..48814d8ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Features: - Add support for Presets v9, which enables more macro expansion for the `include` field. [#3946](https://github.com/microsoft/vscode-cmake-tools/issues/3946) +Improvements: + +- Ensure that any uses of `proc.spawn` work, especially for .bat and .cmd files, due to VS Code updating to Node 20. [#4037](https://github.com/microsoft/vscode-cmake-tools/issues/4037) + Bug Fixes: - Fix our setting of `isUserPreset` for presets, only set it to `true` if it's defined in a user presets file. [#4059](https://github.com/microsoft/vscode-cmake-tools/issues/4059) diff --git a/src/proc.ts b/src/proc.ts index fb4bf0973..1c042412c 100644 --- a/src/proc.ts +++ b/src/proc.ts @@ -95,7 +95,7 @@ export interface ExecutionResult { export interface ExecutionOptions { environment?: Environment; - shell?: boolean; + shell?: boolean | string; silent?: boolean; cwd?: string; encoding?: BufferEncoding; @@ -113,6 +113,18 @@ export function buildCmdStr(command: string, args?: string[]): string { return cmdarr.map(a => /[ \n\r\f;\t]/.test(a) ? `"${a}"` : a).join(' '); } +export function determineShell(command: string): string | boolean { + if (command.endsWith('.cmd') || command.endsWith('.bat')) { + return 'cmd'; + } + + if (command.endsWith('.ps1')) { + return 'powershell'; + } + + return false; +} + /** * Execute a command and return the result * @param command The binary to execute @@ -146,6 +158,11 @@ export function execute(command: string, args?: string[], outputConsumer?: Outpu log.debug(localize('execution.environment', ' with environment: {0}', JSON.stringify(final_env))); } } + + if (process.platform === "win32" && options.shell === undefined) { + options.shell = determineShell(command); + } + const spawn_opts: proc.SpawnOptions = { env: final_env, shell: !!options.shell From caca06d89f9ae981a7fbb348d2e8e5b641034666 Mon Sep 17 00:00:00 2001 From: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:33:45 -0400 Subject: [PATCH 4/5] fix the issue (#4111) --- CHANGELOG.md | 1 + src/cpptools.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48814d8ae..1969a885c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Features: Improvements: +- Fix "Unable to resolve configuration with compilerPath" issue for Swift. [#4097](https://github.com/microsoft/vscode-cmake-tools/issues/4097) - Ensure that any uses of `proc.spawn` work, especially for .bat and .cmd files, due to VS Code updating to Node 20. [#4037](https://github.com/microsoft/vscode-cmake-tools/issues/4037) Bug Fixes: diff --git a/src/cpptools.ts b/src/cpptools.ts index d86bdfbe2..121c0c190 100644 --- a/src/cpptools.ts +++ b/src/cpptools.ts @@ -431,7 +431,7 @@ export class CppConfigurationProvider implements cpptools.CustomConfigurationPro // For CppTools V6 and above, build the compilerFragments data, otherwise build compilerArgs data const useFragments: boolean = this.cpptoolsVersion >= cpptools.Version.v6; // If the file didn't have a language, default to C++ - const lang = fileGroup.language === "RC" ? undefined : fileGroup.language; + const lang = fileGroup.language === "RC" || fileGroup.language === "Swift" ? undefined : fileGroup.language; // First try to get toolchain values directly reported by CMake. Check the // group's language compiler, then the C++ compiler, then the C compiler. let compilerToolchains: CodeModelToolchain | undefined; From 81316ee4971e4291023d845ce224816d6304ad56 Mon Sep 17 00:00:00 2001 From: Garrett Campbell <86264750+gcampbell-msft@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:35:37 -0400 Subject: [PATCH 5/5] fix build vsix workflow (#4119) --- .github/workflows/build-vsix.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-vsix.yml b/.github/workflows/build-vsix.yml index 3f5cb5baf..7a0e6b944 100644 --- a/.github/workflows/build-vsix.yml +++ b/.github/workflows/build-vsix.yml @@ -36,6 +36,7 @@ jobs: - name: Build the VSIX run: | yarn install + yarn run compile-production yarn run package - name: Upload Build Artifacts