Skip to content

Commit

Permalink
Normalize drive letter on windows for presets expanision (#2665)
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielmelody authored Sep 23, 2022
1 parent aa08f65 commit 07fd17c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Improvements:
- Add a setting to disable reading `compile_commands.json`. [#2586](https://github.com/microsoft/vscode-cmake-tools/issues/2586) [@xiaoyun94](https://github.com/xiaoyun94)
- Preset in CMakeUserPresets.json using "condition" does not appear in configure preset selection. [#2749](https://github.com/microsoft/vscode-cmake-tools/issues/2749)
- Resolve workspace variables in `cmake-kits.json`. [#2737](https://github.com/microsoft/vscode-cmake-tools/issues/2737)
- Use upper case drive letters on Windows for `cmake.sourceDirectory`. [PR #2665](https://github.com/microsoft/vscode-cmake-tools/pull/2665) [@Danielmelody](https://github.com/Danielmelody)

## 1.12.27
Bug Fixes:
Expand Down
7 changes: 5 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { platform } from 'os';

import { DebuggerEnvironmentVariable, execute } from '@cmt/proc';
import rollbar from '@cmt/rollbar';
Expand Down Expand Up @@ -704,6 +703,10 @@ export function isWorkspaceFolder(x?: any): boolean {

export async function normalizeAndVerifySourceDir(sourceDir: string): Promise<string> {
let result = lightNormalizePath(sourceDir);
if (process.platform === 'win32' && result.length > 1 && result.charCodeAt(0) > 97 && result.charCodeAt(0) <= 122 && result[1] === ':') {
// Windows drive letter should be uppercase, for consistency with other tools like Visual Studio.
result = result[0].toUpperCase() + result.slice(1);
}
if (path.basename(result).toLocaleLowerCase() === "cmakelists.txt") {
// Don't fail if CMakeLists.txt was accidentally appended to the sourceDirectory.
result = path.dirname(result);
Expand Down Expand Up @@ -767,7 +770,7 @@ export function isSupportedCompiler(compilerName: string | undefined): string |
}

async function getHostSystemName(): Promise<string> {
if (platform() === "win32") {
if (process.platform === 'win32') {
return "Windows";
} else {
const result = await execute('uname', ['-s']).result;
Expand Down

0 comments on commit 07fd17c

Please sign in to comment.