Skip to content

Commit 3832029

Browse files
author
Elaheh Rashedi
authored
don't overwrite options and args (#6374)
* dont overwrite options and args * linter error * update changelog
1 parent 61ab30f commit 3832029

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Extension/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* Fix issue with compiler querying not handling various clang command line options correctly. [6359](https://github.com/microsoft/vscode-cpptools/issues/6356)
2424
* Fix issue where std change warnings were not generated if IntelliSense mode was not set.
2525
* Fix issue macOS Framework search to only parse the "Current" framework folder when the "Headers" folder is not found. [#2046](https://github.com/microsoft/vscode-cpptools/issues/2046)
26+
* Fix issue to not overwrite the compiler options and args when building from a custom defined task. [#6366](https://github.com/microsoft/vscode-cpptools/issues/6366)
2627

2728
## Version 1.1.0-insiders2: October 15, 2020
2829
### Bug Fixes

Extension/src/LanguageServer/cppBuildTaskProvider.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,26 +154,25 @@ export class CppBuildTaskProvider implements TaskProvider {
154154
}
155155

156156
private getTask: (compilerPath: string, appendSourceToName: boolean, compilerArgs?: string[], definition?: CppBuildTaskDefinition) => Task = (compilerPath: string, appendSourceToName: boolean, compilerArgs?: string[], definition?: CppBuildTaskDefinition) => {
157-
const filePath: string = path.join('${fileDirname}', '${fileBasenameNoExtension}');
158157
const compilerPathBase: string = path.basename(compilerPath);
159158
const taskLabel: string = ((appendSourceToName && !compilerPathBase.startsWith(CppBuildTaskProvider.CppBuildSourceStr)) ?
160159
CppBuildTaskProvider.CppBuildSourceStr + ": " : "") + compilerPathBase + " build active file";
161160
const isCl: boolean = compilerPathBase === "cl.exe";
162-
const isWindows: boolean = os.platform() === 'win32';
163-
const cwd: string = isCl ? "${workspaceFolder}" : path.dirname(compilerPath);
164-
let args: string[] = isCl ? ['/Zi', '/EHsc', '/Fe:', filePath + '.exe', '${file}'] : ['-g', '${file}', '-o', filePath + (isWindows ? '.exe' : '')];
165-
if (!definition && compilerArgs && compilerArgs.length > 0) {
166-
args = args.concat(compilerArgs);
167-
}
168-
const options: cp.ExecOptions | undefined = { cwd: cwd };
169-
170161
// Double-quote the command if it is not already double-quoted.
171162
let resolvedcompilerPath: string = isCl ? compilerPathBase : compilerPath;
172163
if (resolvedcompilerPath && !resolvedcompilerPath.startsWith("\"") && resolvedcompilerPath.includes(" ")) {
173164
resolvedcompilerPath = "\"" + resolvedcompilerPath + "\"";
174165
}
175166

176167
if (!definition) {
168+
const filePath: string = path.join('${fileDirname}', '${fileBasenameNoExtension}');
169+
const isWindows: boolean = os.platform() === 'win32';
170+
let args: string[] = isCl ? ['/Zi', '/EHsc', '/Fe:', filePath + '.exe', '${file}'] : ['-g', '${file}', '-o', filePath + (isWindows ? '.exe' : '')];
171+
if (compilerArgs && compilerArgs.length > 0) {
172+
args = args.concat(compilerArgs);
173+
}
174+
const cwd: string = isCl ? "${workspaceFolder}" : path.dirname(compilerPath);
175+
const options: cp.ExecOptions | undefined = { cwd: cwd };
177176
definition = {
178177
type: CppBuildTaskProvider.CppBuildScriptType,
179178
label: taskLabel,
@@ -196,7 +195,7 @@ export class CppBuildTaskProvider implements TaskProvider {
196195
const task: CppBuildTask = new Task(definition, scope, taskLabel, CppBuildTaskProvider.CppBuildSourceStr,
197196
new CustomExecution(async (): Promise<Pseudoterminal> =>
198197
// When the task is executed, this callback will run. Here, we setup for running the task.
199-
new CustomBuildTaskTerminal(resolvedcompilerPath, args, options)
198+
new CustomBuildTaskTerminal(resolvedcompilerPath, definition ? definition.args : [], definition ? definition.options : undefined)
200199
), isCl ? '$msCompile' : '$gcc');
201200

202201
task.group = TaskGroup.Build;

0 commit comments

Comments
 (0)