Skip to content

Commit

Permalink
Add colconExe and installType properties
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Lelchuk <[email protected]>
  • Loading branch information
Felix-El committed Jul 25, 2021
1 parent ff97826 commit 0daf8b6
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,23 @@
"default": "cmd",
"scope": "resource",
"description": "Type of shell being used for process colcon tasks."
},
"colcon.colconExe": {
"type": "string",
"default": "colcon",
"scope": "resource",
"description": "Path to colcon executable."
},
"colcon.installType": {
"type": "string",
"enum": [
"isolated",
"symlinked",
"merged"
],
"default": "isolated",
"scope": "resource",
"description": "Type of installation to perform."
}
}
}
Expand Down
27 changes: 26 additions & 1 deletion src/colcon_config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from 'vscode';
import * as path from 'path';
import { colcon_ns, extName } from './common';
import { colcon_exec, colcon_ns, def_install_type, extName } from './common';

const envProperty = "env";
const globalSetupProperty = "globalSetup";
Expand All @@ -25,12 +25,19 @@ const defaultEnvsProperty = "defaultEnvironment";
const rosInstallPathProperty = "rosInstallPath";
const shellProperty = "shell";
const shellTypeProperty = "shellType";
const colconExeProperty = "colconExe";
const installTypeProperty = "installType";

/**
* Recognizable shell types
*/
type ShellType = 'cmd' | 'powershell' | 'bash' | 'zsh';

/**
* Recognizable installation types
*/
type InstallType = 'isolated' | 'symlinked' | 'merged';

enum OutputLevel {
Info = 0,
Warning = 1,
Expand Down Expand Up @@ -63,6 +70,9 @@ export class Config {
globalSetup: string[] = [];
workspaceSetup: string[] = [];
colconCwd: string;
colconExe: string;
installType: string;
installTypeArgs: string[] = [];
currentWsFolder: vscode.WorkspaceFolder;

refreshOnStart: boolean;
Expand Down Expand Up @@ -166,6 +176,21 @@ export class Config {
// leave undefined if there is no envs defined
this.defaultEnvs = envs;
}

this.colconExe = this.resolvePath(this.resConf.get(colconExeProperty, colcon_exec));
this.installType = this.resConf.get(installTypeProperty, def_install_type);
switch (this.installType)
{
case "symlinked":
this.installTypeArgs.push('--symlink-install');
break;
case "merged":
this.installTypeArgs.push('--merge-install');
break;
default:
// isolated install is the default case
break;
}
}

// NOTE: forceConsole will be used for extension debug purposes since console.log()
Expand Down
2 changes: 1 addition & 1 deletion src/colcon_task_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function createColconTaskProvider() {
definition.name ?? _task.name,
definition.type,
new vscode.ProcessExecution(
definition.command ?? colcon_exec,
definition.command ?? config.colconExe,
definition.args ?? [],
execOptions),
[]
Expand Down
1 change: 1 addition & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const colcon_exec = 'colcon';
export const colcon_ns = colcon_exec;
export const def_install_type = 'isolated'
export const extName = "Colcon Tasks";

export const ros2launch = 'ros2 launch';
2 changes: 1 addition & 1 deletion src/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class PackageInfo implements vscode.QuickPickItem {
}

export function getAllPackages(folder: vscode.WorkspaceFolder): PackageInfo[] {
let cmd = [colcon_exec].concat('list');
let cmd = [config.colconExe].concat('list');

var joinedCmd = cmd.join(' ');
config.log("Get package list with: " + joinedCmd);
Expand Down
8 changes: 4 additions & 4 deletions src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function getBuildTaskForPackage(packageName: string | string[]): vscode.T

return makeColconTask(
`build ${descriptor}`,
[buildCmd, '--symlink-install', '--packages-select'].concat(packageName),
[buildCmd].concat(config.installTypeArgs).concat('--packages-select', packageName),
vscode.TaskGroup.Build);
}

Expand All @@ -40,7 +40,7 @@ export function getBuildTaskForPackagesUpTo(packageName: string | string[]): vsc

return makeColconTask(
`build ${descriptor}`,
[buildCmd, '--symlink-install', '--packages-up-to'].concat(packageName),
[buildCmd].concat(config.installTypeArgs).concat('--packages-up-to', packageName),
vscode.TaskGroup.Build);
}

Expand Down Expand Up @@ -85,7 +85,7 @@ let makeColconTask = (
args: string[],
group: vscode.TaskGroup | undefined = undefined
) => {
return makeTask(colcon_exec, taskName, args, group);
return makeTask(config.colconExe, taskName, args, group);
}

// Get all possible colcon tasks
Expand Down Expand Up @@ -132,7 +132,7 @@ export function getColconTasks(wsFolder: vscode.WorkspaceFolder) {
}
}

pushIfNotUndefined(makeColconTask('build', [buildCmd, '--symlink-install'], vscode.TaskGroup.Build));
pushIfNotUndefined(makeColconTask('build', [buildCmd].concat(config.installTypeArgs), vscode.TaskGroup.Build));
pushIfNotUndefined(makeColconTask('test', [testCmd], vscode.TaskGroup.Test));
pushIfNotUndefined(makeColconTask('test-result', [testResultCmd, '--verbose']));

Expand Down

0 comments on commit 0daf8b6

Please sign in to comment.