Skip to content

Commit

Permalink
fix: problem matcher used in makefile tasks is undefined. [fixes #123]
Browse files Browse the repository at this point in the history
  • Loading branch information
spmeesseman committed Feb 6, 2021
1 parent f5a92fc commit cae79ea
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 70 deletions.
50 changes: 0 additions & 50 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,5 @@
"problemMatcher": [
"$tsc"
]
},
{
"label": "cmd1",
"type": "shell",
"command": "cmd",
"args": [
"/c",
"echo",
"hello1"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
}
},
{
"label": "cmd2",
"type": "shell",
"command": "cmd",
"args": [
"/c",
"echo",
"hello111112222"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
}
},
{
"label": "tetcmpx",
"detail": "",
"type": "shell",
"dependsOn": ["cmd1", "cmd2"],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": true
},
"promptOnClose": true,

}]
}
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,25 @@
}
}
}
],
"problemMatchers": [
{
"name": "gccte",
"owner": "cpp",
"label": "Task Explorer gcc",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
]
}
}
2 changes: 1 addition & 1 deletion src/taskProviderGrunt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,5 @@ function createGruntTask(target: string, cmd: string, folder: WorkspaceFolder, u

const execution = new ShellExecution("npx", args, options);

return new Task(kind, folder, target, "grunt", execution, undefined);
return new Task(kind, folder, target, "grunt", execution, "$msCompile");
}
2 changes: 1 addition & 1 deletion src/taskProviderGulp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,5 +372,5 @@ function createGulpTask(target: string, cmd: string, folder: WorkspaceFolder, ur

const execution = new ShellExecution("npx", args, options);

return new Task(kind, folder, target, "gulp", execution, undefined);
return new Task(kind, folder, target, "gulp", execution, "$msCompile");
}
31 changes: 14 additions & 17 deletions src/taskProviderMake.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import {
Task, TaskGroup, WorkspaceFolder, RelativePattern, ShellExecution, Uri,
workspace, TaskProvider, TaskDefinition
workspace, TaskProvider, TaskDefinition, ShellExecutionOptions, extensions
} from "vscode";
import * as path from "path";
import * as util from "./util";
Expand Down Expand Up @@ -229,8 +229,11 @@ async function findTargets(fsPath: string): Promise<StringMap>
// Don't include object targets
//
if (tgtName.indexOf("/") === -1 && tgtName.indexOf("=") === -1 && tgtName.indexOf("\\") === -1 &&
isNormalTarget(tgtName))
tgtName.indexOf("(") === -1 && tgtName.indexOf("$") === -1 && isNormalTarget(tgtName))
{
console.log(tgtName);
console.log(" " + dependsName);

scripts[tgtName] = "";
util.log(" found target");
util.logValue(" name", tgtName);
Expand Down Expand Up @@ -278,29 +281,23 @@ function createMakeTask(target: string, cmd: string, folder: WorkspaceFolder, ur
script: target,
path: getRelativePath(folder, uri),
fileName: path.basename(uri.path),
problemMatcher: "",
uri
};

const cwd = path.dirname(uri.fsPath);
const args = [target];
const options = {
const options: ShellExecutionOptions = {
cwd
};

const execution = new ShellExecution(getCommand(folder, cmd), args, options);
let problemMatcher = "$gccte";
let cPlusPlusExtension = extensions.getExtension("spmeesseman.vscode-taskexplorer");

This comment has been minimized.

Copy link
@yannickowow

yannickowow Feb 24, 2021

Did you mean here "ms-vscode.cpptools" ?
If I understand correctly your code, you define a default problemMatcher but you want to use gcc if you detect C/C++ Extension, am I right?

if (cPlusPlusExtension)
{
problemMatcher = "$gcc";
}

// const pm = {
// owner: "cpp",
// fileLocation: ["absolute"],
// pattern: {
// regexp: "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
// file: 1,
// line: 2,
// column: 3,
// severity: 4,
// message: 5
// }
// };

return new Task(kind, folder, target, "make", execution, "cpp");
return new Task(kind, folder, target, "make", execution, problemMatcher);
}
2 changes: 1 addition & 1 deletion src/taskProviderScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,5 +321,5 @@ function createScriptTask(scriptDef: any, folder: WorkspaceFolder, uri: Uri): Ta
// Create the shell execution object and task
//
const execution = new ShellExecution(exec, args, options);
return new Task(kind, folder, scriptDef.type !== "python" ? fileName : "build egg", scriptDef.type, execution, undefined);
return new Task(kind, folder, scriptDef.type !== "python" ? fileName : "build egg", scriptDef.type, execution, "$msCompile");
}

0 comments on commit cae79ea

Please sign in to comment.