Skip to content

Commit 48b4729

Browse files
authored
cmakeDriver: Fixes getCompilerVersion by using compilerPath instead of compilerName (#4647)
* Dump stackTrace for failed proc::execute It's for easily locate where failed when doing proc::execute * cmakeDriver: Fixes getCompilerVersion by using compilerPath instead of compilerName Closes: #3063 Signed-off-by: Yonggang Luo <[email protected]> --------- Signed-off-by: Yonggang Luo <[email protected]>
1 parent 95e8e26 commit 48b4729

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Features:
88
Bug Fixes:
99

1010
- Fix user-level tasks defined in `~/.config/Code/User/tasks.json` causing infinite spinner. [#4659](https://github.com/microsoft/vscode-cmake-tools/pull/4659)
11+
- cmakeDriver: Fixes getCompilerVersion by using compilerPath instead of compilerName. [#4647](https://github.com/microsoft/vscode-cmake-tools/pull/4647) [@lygstate](https://github.com/lygstate)
1112

1213
## 1.22
1314

src/drivers/cmakeDriver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
13561356
// since some compilers can output their version without a specific switch.
13571357
let version;
13581358
if (compiler?.versionOutputRegexp) {
1359-
version = await this.testCompilerVersion(compilerName, compilerDir, compiler?.versionSwitch, RegExp(compiler.versionOutputRegexp, "mgi"), compiler.captureGroup) || "unknown";
1359+
version = await this.testCompilerVersion(compilerPath, compilerDir, compiler?.versionSwitch, RegExp(compiler.versionOutputRegexp, "mgi"), compiler.captureGroup) || "unknown";
13601360
} else {
13611361
version = "unknown";
13621362
}

src/proc.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ export function execute(command: string, args?: string[], outputConsumer?: Outpu
166166
options.environment,
167167
options.overrideLocale ? localeOverride : {}]);
168168

169+
const stackTrace = new Error().stack;
170+
169171
const cmdstr = buildCmdStr(command, args);
170172
if (options && options.silent !== true) {
171173
log.info(// We do simple quoting of arguments with spaces.
@@ -234,23 +236,23 @@ export function execute(command: string, args?: string[], outputConsumer?: Outpu
234236
let stderr_acc = '';
235237
let stderr_line_acc = '';
236238
child?.on('error', err => {
237-
log.warning(localize({key: 'process.error', comment: ['The space before and after all placeholders should be preserved.']}, 'The command: {0} failed with error: {1}', `${cmdstr}`, `${err}`));
239+
log.warning(localize({key: 'process.error', comment: ['The space before and after all placeholders should be preserved.']}, 'The command: {0} failed with error: {1} stack: {2}', `${cmdstr}`, `${err}`, `${stackTrace}`));
238240
});
239241
child?.on('exit', (code, signal) => {
240242
if (code !== 0) {
241243
if (signal !== null && signal !== undefined) {
242-
log.warning(localize({key: 'process.exit.with.signal', comment: ['The space before and after all placeholders should be preserved.']}, 'The command: {0} exited with code: {1} and signal: {2}', `${cmdstr}`, `${code}`, `${signal}`));
244+
log.warning(localize({key: 'process.exit.with.signal', comment: ['The space before and after all placeholders should be preserved.']}, 'The command: {0} exited with code: {1} and signal: {2} stack: {3}', `${cmdstr}`, `${code}`, `${signal}`, `${stackTrace}`));
243245
} else {
244-
log.warning(localize({key: 'process.exit', comment: ['The space before and after all placeholders should be preserved.']}, 'The command: {0} exited with code: {1}', `${cmdstr}`, `${code}`));
246+
log.warning(localize({key: 'process.exit', comment: ['The space before and after all placeholders should be preserved.']}, 'The command: {0} exited with code: {1} stack: {2}', `${cmdstr}`, `${code}`, `${stackTrace}`));
245247
}
246248
if (options?.showOutputOnError) {
247249
if (stdout_acc) {
248250
const output = stdout_acc.trimEnd().replace(/\n/g, '\n\t');
249-
log.warning(localize('process.exit.stdout', 'Command output on standard out: {0}', `${output}`));
251+
log.warning(localize('process.exit.stdout', 'Command output on standard out: {0} stack: {1}', `${output}`, `${stackTrace}`));
250252
}
251253
if (stderr_acc) {
252254
const output = stderr_acc.trimEnd().replace(/\n/g, '\n\t');
253-
log.warning(localize('process.exit.stderr', 'Command output on standard error: {0}', `${output}`));
255+
log.warning(localize('process.exit.stderr', 'Command output on standard error: {0} stack: {1}', `${output}`, `${stackTrace}`));
254256
}
255257
}
256258
}

0 commit comments

Comments
 (0)