forked from ajshort/vscode-ros
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow customization of build tool tasks
Add `args` parameter to all build tool tasks that allows customization in the workspaces's tasks.json by users Implement generic task of `ros` type Add `roscore` and `roslaunch` commands using `ros` task that allows user to run and customize them in `tasks.json` Add `roscore and `roslaunch` problem matchers that allow corresponding tasks to run in background
- Loading branch information
1 parent
5889eb9
commit b0dcf8d
Showing
7 changed files
with
194 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import * as vscode from "vscode"; | ||
|
||
import * as extension from "../extension"; | ||
|
||
export interface RosTaskDefinition extends vscode.TaskDefinition { | ||
command: string; | ||
args?: string[]; | ||
} | ||
|
||
export class RosShellTaskProvider implements vscode.TaskProvider { | ||
public provideTasks(token?: vscode.CancellationToken): vscode.ProviderResult<vscode.Task[]> { | ||
return this.defaultRosTasks(); | ||
} | ||
|
||
public defaultRosTasks(): vscode.Task[] { | ||
const rosCore = make({type: 'ros', command: 'roscore'}, 'roscore'); | ||
rosCore.isBackground = true; | ||
rosCore.problemMatchers = ['$roscore']; | ||
|
||
const rosLaunch = make({type: 'ros', command: 'roslaunch', args: ['package_name', 'launch_file.launch']}, 'roslaunch'); | ||
rosLaunch.isBackground = true; | ||
rosLaunch.problemMatchers = ['$roslaunch']; | ||
|
||
return [rosCore, rosLaunch]; | ||
} | ||
|
||
public resolveTask(task: vscode.Task, token?: vscode.CancellationToken): vscode.ProviderResult<vscode.Task> { | ||
return resolve(task); | ||
} | ||
} | ||
|
||
export function registerRosShellTaskProvider(): vscode.Disposable[] { | ||
return [ | ||
vscode.tasks.registerTaskProvider('ros', new RosShellTaskProvider()), | ||
]; | ||
} | ||
|
||
export function resolve(task: vscode.Task): vscode.Task { | ||
const resolvedTask = make(task.definition as RosTaskDefinition); | ||
|
||
resolvedTask.isBackground = task.isBackground; | ||
resolvedTask.problemMatchers = task.problemMatchers; | ||
return resolvedTask; | ||
} | ||
|
||
export function make(definition: RosTaskDefinition, category?: string): vscode.Task { | ||
definition.command = definition.command || definition.type; // Command can be missing in build tasks that have type==command | ||
|
||
const args = definition.args || []; | ||
const name = category ? category : args.join(' '); | ||
const task = new vscode.Task(definition, vscode.TaskScope.Workspace, name, definition.command); | ||
|
||
task.execution = new vscode.ShellExecution(definition.command, args, { | ||
env: extension.env, | ||
}); | ||
return task; | ||
} |
Oops, something went wrong.