diff --git a/package.json b/package.json index 8264f6c..bfc385a 100644 --- a/package.json +++ b/package.json @@ -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." } } } diff --git a/src/colcon_config.ts b/src/colcon_config.ts index 5d39e09..9253455 100644 --- a/src/colcon_config.ts +++ b/src/colcon_config.ts @@ -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"; @@ -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, @@ -63,6 +70,9 @@ export class Config { globalSetup: string[] = []; workspaceSetup: string[] = []; colconCwd: string; + colconExe: string; + installType: string; + installTypeArgs: string[] = []; currentWsFolder: vscode.WorkspaceFolder; refreshOnStart: boolean; @@ -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() diff --git a/src/colcon_task_provider.ts b/src/colcon_task_provider.ts index 61692b4..d6233a7 100644 --- a/src/colcon_task_provider.ts +++ b/src/colcon_task_provider.ts @@ -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), [] diff --git a/src/common.ts b/src/common.ts index d1c9235..ce7b091 100644 --- a/src/common.ts +++ b/src/common.ts @@ -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'; diff --git a/src/packages.ts b/src/packages.ts index b1efa53..37c2b98 100644 --- a/src/packages.ts +++ b/src/packages.ts @@ -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); diff --git a/src/tasks.ts b/src/tasks.ts index c4df56f..bd89abc 100644 --- a/src/tasks.ts +++ b/src/tasks.ts @@ -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); } @@ -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); } @@ -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 @@ -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']));