Skip to content

Commit

Permalink
Merge branch 'main' into dev/sanore/activeFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
gcampbell-msft authored Oct 10, 2024
2 parents ceed341 + 81316ee commit b038e18
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-vsix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- name: Build the VSIX
run: |
yarn install
yarn run compile-production
yarn run package
- name: Upload Build Artifacts
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ 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)
- Add support to configure default folder in workspace setting. [#1078](https://github.com/microsoft/vscode-cmake-tools/issues/1078)

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:

- 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

Improvements:
Expand Down
2 changes: 1 addition & 1 deletion src/cpptools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
41 changes: 20 additions & 21 deletions src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
8 changes: 4 additions & 4 deletions src/presetsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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));
Expand Down
19 changes: 18 additions & 1 deletion src/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export interface ExecutionResult {

export interface ExecutionOptions {
environment?: Environment;
shell?: boolean;
shell?: boolean | string;
silent?: boolean;
cwd?: string;
encoding?: BufferEncoding;
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b038e18

Please sign in to comment.