Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cpptools",
"displayName": "C/C++",
"description": "C/C++ IntelliSense, debugging, and code browsing.",
"version": "0.28.1-master",
"version": "0.28.2-master",
"publisher": "ms-vscode",
"preview": true,
"icon": "LanguageCCPP_color_128x.png",
Expand Down
6 changes: 3 additions & 3 deletions Extension/src/Debugger/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
* Returns a list of initial debug configurations based on contextual information, e.g. package.json or folder.
*/
async provideDebugConfigurations(folder?: vscode.WorkspaceFolder, token?: vscode.CancellationToken): Promise<vscode.DebugConfiguration[]> {
let buildTasks: vscode.Task[] = await getBuildTasks(true);
let buildTasks: vscode.Task[] = await getBuildTasks(true, true);
if (buildTasks.length === 0) {
return Promise.resolve(this.provider.getInitialConfigurations(this.type));
}
Expand All @@ -119,11 +119,11 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider {
// Filter out build tasks that don't match the currently selected debug configuration type.
buildTasks = buildTasks.filter((task: vscode.Task) => {
if (defaultConfig.name.startsWith("(Windows) ")) {
if (task.name.startsWith("cl.exe")) {
if (task.name.startsWith("C/C++: cl.exe")) {
return true;
}
} else {
if (!task.name.startsWith("cl.exe")) {
if (!task.name.startsWith("C/C++: cl.exe")) {
return true;
}
}
Expand Down
17 changes: 9 additions & 8 deletions Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ let realActivationOccurred: boolean = false;
let tempCommands: vscode.Disposable[] = [];
let activatedPreviously: PersistentWorkspaceState<boolean>;
let buildInfoCache: BuildInfo | undefined;
const taskSourceStr: string = "shell";
const taskTypeStr: string = "shell";
const taskSourceStr: string = "C/C++";
const cppInstallVsixStr: string = 'C/C++: Install vsix -- ';
let taskProvider: vscode.Disposable;
let codeActionProvider: vscode.Disposable;
Expand Down Expand Up @@ -171,8 +172,8 @@ export function activate(activationEventOccurred: boolean): void {
return;
}

taskProvider = vscode.tasks.registerTaskProvider(taskSourceStr, {
provideTasks: () => getBuildTasks(false),
taskProvider = vscode.tasks.registerTaskProvider(taskTypeStr, {
provideTasks: () => getBuildTasks(false, false),
resolveTask(task: vscode.Task): vscode.Task | undefined {
// Currently cannot implement because VS Code does not call this. Can implement custom output file directory when enabled.
return undefined;
Expand Down Expand Up @@ -243,7 +244,7 @@ export interface BuildTaskDefinition extends vscode.TaskDefinition {
/**
* Generate tasks to build the current file based on the user's detected compilers, the user's compilerPath setting, and the current file's extension.
*/
export async function getBuildTasks(returnCompilerPath: boolean): Promise<vscode.Task[]> {
export async function getBuildTasks(returnCompilerPath: boolean, appendSourceToName: boolean): Promise<vscode.Task[]> {
const editor: vscode.TextEditor | undefined = vscode.window.activeTextEditor;
if (!editor) {
return [];
Expand Down Expand Up @@ -345,20 +346,20 @@ export async function getBuildTasks(returnCompilerPath: boolean): Promise<vscode
let createTask: (compilerPath: string, compilerArgs?: string []) => vscode.Task = (compilerPath: string, compilerArgs?: string []) => {
const filePath: string = path.join('${fileDirname}', '${fileBasenameNoExtension}');
const compilerPathBase: string = path.basename(compilerPath);
const taskName: string = compilerPathBase + " build active file";
const taskName: string = (appendSourceToName ? taskSourceStr + ": " : "") + compilerPathBase + " build active file";
const isCl: boolean = compilerPathBase === "cl.exe";
const cwd: string = isCl ? "" : path.dirname(compilerPath);
const cwd: string = "${workspaceFolder}";
let args: string[] = isCl ? ['/Zi', '/EHsc', '/Fe:', filePath + '.exe', '${file}'] : ['-g', '${file}', '-o', filePath + (isWindows ? '.exe' : '')];
if (compilerArgs && compilerArgs.length > 0) {
args = args.concat(compilerArgs);
}

let kind: vscode.TaskDefinition = {
type: 'shell',
type: taskTypeStr,
label: taskName,
command: isCl ? compilerPathBase : compilerPath,
args: args,
options: isCl ? undefined : {"cwd": cwd}
options: { "cwd": cwd }
};

if (returnCompilerPath) {
Expand Down
9 changes: 7 additions & 2 deletions Extension/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function ensureBuildTaskExists(taskName: string): Promise<void> {
return;
}

const buildTasks: vscode.Task[] = await getBuildTasks(false);
const buildTasks: vscode.Task[] = await getBuildTasks(false, true);
selectedTask = buildTasks.find(task => task.name === taskName);
console.assert(selectedTask);
if (!selectedTask) {
Expand All @@ -107,7 +107,12 @@ export async function ensureBuildTaskExists(taskName: string): Promise<void> {

let selectedTask2: vscode.Task = selectedTask;
if (!rawTasksJson.tasks.find((task: any) => task.label === selectedTask2.definition.label)) {
rawTasksJson.tasks.push(selectedTask2.definition);
let task: any = {
...selectedTask2.definition,
problemMatcher: selectedTask2.problemMatchers,
group: { kind: "build", "isDefault": true }
};
rawTasksJson.tasks.push(task);
}

// TODO: It's dangerous to overwrite this file. We could be wiping out comments.
Expand Down