Skip to content

Commit

Permalink
HBMK2 provider, added build current file
Browse files Browse the repository at this point in the history
  • Loading branch information
APerricone committed Mar 8, 2020
1 parent 5ee3025 commit b117c48
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 27 deletions.
7 changes: 6 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{
"name": "harbour",
"owner": "harbour",
"fileLocation": "relative",
"fileLocation": "autoDetect",
"pattern": {
"regexp": "^(?:([^\\(]*)\\((\\d+)\\)\\s+)(Warning|Error)\\s+(.*)$",
"file": 1,
Expand Down Expand Up @@ -364,6 +364,11 @@
"default": "${file}",
"description": "%harbour.task.HBMK2.input%"
},
"output": {
"type": "string",
"default": "${file}",
"description": "%harbour.task.HBMK2.output%"
},
"extraArgs": {
"type": "array",
"items": {
Expand Down
82 changes: 56 additions & 26 deletions client/src/taskProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,19 @@ class HRBTask {
var file_cwd = path.dirname(textDocument.fileName);
retValue.push(new vscode.Task({
"type": "Harbour",
"input": "${file}",
"output": "portable"
}, localize("harbour.task.portableName"),"Harbour",
new vscode.ShellExecution(section.compilerExecutable,args.concat(["-gh"]),{
cwd: file_cwd
}),"$harbour"));
retValue.push(new vscode.Task({
"type": "Harbour",
"input": "${file}",
"output": "C code",
"c-type": "compact"
}, localize("harbour.task.cCodeName"),"Harbour",
new vscode.ShellExecution(section.compilerExecutable,args.concat(["-gc"]),{
new vscode.ShellExecution(section.compilerExecutable,args.concat(["-gc0"]),{
cwd: file_cwd
}),"$harbour"));
}
Expand All @@ -103,9 +105,15 @@ class HRBTask {
var retTask = new vscode.Task(task.definition,"build "+input ,"Harbour");

var args = this.GetArgs(input);
if(task.definition.output=="C code")
args = args.concat(["-gc"]);
else
if(task.definition.output=="C code") {
if("c-type" in task.definition) {
var id = ["compact","normal",
"verbose","real C Code"].indexOf(task.definition["c-type"]);
if(id>=0) {
args = args.concat(["-gc"+id]);
} else args = args.concat(["-gc"]);
} else args = args.concat(["-gc"]);
} else
args = args.concat(["-gh"]);
var file_cwd = path.dirname(vscode.window.activeTextEditor.document.fileName);
var section = vscode.workspace.getConfiguration('harbour');
Expand Down Expand Up @@ -329,6 +337,27 @@ class HBMK2Task {
return [];
var HBMK2This = this;
return new Promise((resolve,reject)=> {
var retValue=[];
var textDocument = undefined;
if(vscode && vscode.window && vscode.window.activeTextEditor && vscode.window.activeTextEditor.document)
textDocument =vscode.window.activeTextEditor.document;
if(textDocument && textDocument.languageId == 'harbour' ) {
var task = new vscode.Task({
"type": "HBMK2",
"input": "${file}"
}, localize("harbour.task.HBMK2.provideName",path.basename(textDocument.fileName)) ,"HBMK2");
task.execution = new vscode.CustomExecution(getTerminalFn(task));
task.problemMatchers = ["$harbour","$msCompile"];
var task2 = new vscode.Task({
"type": "HBMK2",
"input": "${file}",
"debugSymbols": true,
"output": "${fileBasenameNoExtension}_dbg"
}, localize("harbour.task.HBMK2.provideName",path.basename(textDocument.fileName)+" debug") ,"HBMK2");
task2.execution = new vscode.CustomExecution(getTerminalFn(task));
task2.problemMatchers = ["$harbour","$msCompile"];
retValue.push(task,task2);
}
/** @type{Array<Promise>} */
var promises = [];
for(let d=0;d<vscode.workspace.workspaceFolders.length;d++) {
Expand All @@ -352,31 +381,32 @@ class HBMK2Task {
});
promises.push(r);
}
Promise.all(promises).then((values)=>{
if(token.isCancellationRequested) {
reject(token);
return;
}
var retValue=[];
for(let j=0;j<values.length;j++) {
let ff = values[j];
for(let i=0;i<ff.length;++i) {
if(!ff[i].isFile()) continue;
var ext = path.extname(ff[i].name).toLowerCase();
if(ext==".hbp") {
var task = new vscode.Task({
"type": "HBMK2",
"input": ff[i].name
//"c-type": "compact"
}, localize("harbour.task.HBMK2.provideName",path.basename(ff[i].name)) ,"HBMK2");
task.execution = new vscode.CustomExecution(getTerminalFn(task));
task.problemMatchers = ["$harbour","$msCompile"];
retValue.push(task);
if(promises.length>0) {
Promise.all(promises).then((values)=>{
if(token.isCancellationRequested) {
reject(token);
return;
}
for(let j=0;j<values.length;j++) {
let ff = values[j];
for(let i=0;i<ff.length;++i) {
if(!ff[i].isFile()) continue;
var ext = path.extname(ff[i].name).toLowerCase();
if(ext==".hbp") {
var task = new vscode.Task({
"type": "HBMK2",
"input": ff[i].name
}, localize("harbour.task.HBMK2.provideName",path.basename(ff[i].name)) ,"HBMK2");
task.execution = new vscode.CustomExecution(getTerminalFn(task));
task.problemMatchers = ["$harbour","$msCompile"];
retValue.push(task);
}
}
}
}
resolve(retValue);
});
} else
resolve(retValue);
});
});
}

Expand Down

0 comments on commit b117c48

Please sign in to comment.