From e59d576e754907fcd3e6d1398483c8fc55e885d6 Mon Sep 17 00:00:00 2001 From: Kathy and Lou <95253123+polyhobbyist@users.noreply.github.com> Date: Mon, 8 Jan 2024 14:26:19 -0800 Subject: [PATCH] Add support for Debug builds (#1253) Co-authored-by: Lou Amadio --- src/build-tool/catkin-tools.ts | 8 ++++---- src/build-tool/catkin.ts | 12 ++++++------ src/build-tool/colcon.ts | 17 +++++++++++------ src/build-tool/ros-shell.ts | 10 +++++----- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/build-tool/catkin-tools.ts b/src/build-tool/catkin-tools.ts index 35a80919..d27d2576 100644 --- a/src/build-tool/catkin-tools.ts +++ b/src/build-tool/catkin-tools.ts @@ -7,8 +7,8 @@ import * as extension from "../extension"; import * as common from "./common"; import * as rosShell from "./ros-shell"; -function makeCatkin(command: string, args: string[], category?: string): vscode.Task { - const task = rosShell.make({type: command, command, args: ['--workspace', vscode.workspace.rootPath, ...args]}, category) +function makeCatkin(name: string, command: string, args: string[], category?: string): vscode.Task { + const task = rosShell.make(name, {type: command, command, args: ['--workspace', vscode.workspace.rootPath, ...args]}, category) task.problemMatchers = ["$catkin-gcc"]; return task; @@ -19,10 +19,10 @@ function makeCatkin(command: string, args: string[], category?: string): vscode. */ export class CatkinToolsProvider implements vscode.TaskProvider { public provideTasks(token?: vscode.CancellationToken): vscode.ProviderResult { - const make = makeCatkin('catkin', [], 'build'); + const make = makeCatkin('Catkin Tools - Build', 'catkin', [], 'build'); make.group = vscode.TaskGroup.Build; - const test = makeCatkin('catkin', ['--catkin-make-args', 'run_tests'], 'run_tests'); + const test = makeCatkin('Catkin Tools - Test', 'catkin', ['--catkin-make-args', 'run_tests'], 'run_tests'); test.group = vscode.TaskGroup.Test; return [make, test]; diff --git a/src/build-tool/catkin.ts b/src/build-tool/catkin.ts index 5a06c523..28a2ba92 100644 --- a/src/build-tool/catkin.ts +++ b/src/build-tool/catkin.ts @@ -7,8 +7,8 @@ import * as extension from "../extension"; import * as common from "./common"; import * as rosShell from "./ros-shell"; -function makeCatkin(command: string, args: string[], category?: string): vscode.Task { - const task = rosShell.make({type: command, command, args: ['--directory', vscode.workspace.rootPath, '-DCMAKE_BUILD_TYPE=RelWithDebInfo',...args]}, category) +function makeCatkin(name: string, command: string, args: string[], category?: string): vscode.Task { + const task = rosShell.make(name, {type: command, command, args: ['--directory', vscode.workspace.rootPath, '-DCMAKE_BUILD_TYPE=RelWithDebInfo',...args]}, category) task.problemMatchers = ["$catkin-gcc"]; return task; @@ -18,10 +18,10 @@ function makeCatkin(command: string, args: string[], category?: string): vscode. */ export class CatkinMakeProvider implements vscode.TaskProvider { public provideTasks(token?: vscode.CancellationToken): vscode.ProviderResult { - const make = makeCatkin('catkin_make', [], 'build'); + const make = makeCatkin('Catkin Build', 'catkin_make', [], 'build'); make.group = vscode.TaskGroup.Build; - const test = makeCatkin('catkin_make', ['run_tests'], 'run_tests'); + const test = makeCatkin('Catkin Test', 'catkin_make', ['run_tests'], 'run_tests'); test.group = vscode.TaskGroup.Test; return [make, test]; @@ -36,10 +36,10 @@ export class CatkinMakeProvider implements vscode.TaskProvider { */ export class CatkinMakeIsolatedProvider implements vscode.TaskProvider { public provideTasks(token?: vscode.CancellationToken): vscode.ProviderResult { - const make = makeCatkin('catkin_make_isolated', [], 'build'); + const make = makeCatkin('Catkin Build Isolated', 'catkin_make_isolated', [], 'build'); make.group = vscode.TaskGroup.Build; - const test = makeCatkin('catkin_make_isolated', ['--catkin-make-args', 'run_tests'], 'run_tests'); + const test = makeCatkin('Catkin Test Isolated', 'catkin_make_isolated', ['--catkin-make-args', 'run_tests'], 'run_tests'); test.group = vscode.TaskGroup.Test; return [make, test]; diff --git a/src/build-tool/colcon.ts b/src/build-tool/colcon.ts index 3a7dd6b1..0023a0fa 100644 --- a/src/build-tool/colcon.ts +++ b/src/build-tool/colcon.ts @@ -10,7 +10,7 @@ import * as common from "./common"; import * as rosShell from "./ros-shell"; import { env } from "process"; -function makeColcon(command: string, verb: string, args: string[], category?: string): vscode.Task { +function makeColcon(name: string, command: string, verb: string, args: string[], category?: string): vscode.Task { let installType = '--symlink-install'; if (process.platform === "win32") { @@ -18,8 +18,7 @@ function makeColcon(command: string, verb: string, args: string[], category?: st installType = '--merge-install'; } - const task = rosShell.make({type: command, command, args: [verb, installType, '--event-handlers', 'console_cohesion+', '--base-paths', vscode.workspace.rootPath, `--cmake-args`, `-DCMAKE_BUILD_TYPE=RelWithDebInfo`,...args]}, - category) + const task = rosShell.make(name, {type: command, command, args: [verb, installType, '--event-handlers', 'console_cohesion+', '--base-paths', vscode.workspace.rootPath, `--cmake-args`, ...args]}, category) task.problemMatchers = ["$catkin-gcc"]; return task; @@ -30,13 +29,19 @@ function makeColcon(command: string, verb: string, args: string[], category?: st */ export class ColconProvider implements vscode.TaskProvider { public provideTasks(token?: vscode.CancellationToken): vscode.ProviderResult { - const make = makeColcon('colcon', 'build', [], 'build'); + const make = makeColcon('Colcon Build Release', 'colcon', 'build', [`-DCMAKE_BUILD_TYPE=RelWithDebInfo`], 'build'); make.group = vscode.TaskGroup.Build; - const test = makeColcon('colcon', 'test', [], 'test'); + const makeDebug = makeColcon('Colcon Build Debug', 'colcon', 'build', [`-DCMAKE_BUILD_TYPE=Debug`], 'build'); + makeDebug.group = vscode.TaskGroup.Build; + + const test = makeColcon('Colcon Build Test Release', 'colcon', 'test', [`-DCMAKE_BUILD_TYPE=RelWithDebInfo`], 'test'); test.group = vscode.TaskGroup.Test; - return [make, test]; + const testDebug = makeColcon('Colcon Build Test Debug', 'colcon', 'test', [`-DCMAKE_BUILD_TYPE=Debug`], 'test'); + test.group = vscode.TaskGroup.Test; + + return [make, makeDebug, test, testDebug]; } public resolveTask(task: vscode.Task, token?: vscode.CancellationToken): vscode.ProviderResult { diff --git a/src/build-tool/ros-shell.ts b/src/build-tool/ros-shell.ts index b5c24c2d..182e801a 100644 --- a/src/build-tool/ros-shell.ts +++ b/src/build-tool/ros-shell.ts @@ -16,11 +16,11 @@ export class RosShellTaskProvider implements vscode.TaskProvider { } public defaultRosTasks(): vscode.Task[] { - const rosCore = make({type: 'ros', command: 'roscore'}, 'roscore'); + const rosCore = make('ros core', {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'); + const rosLaunch = make('ros launch', {type: 'ros', command: 'roslaunch', args: ['package_name', 'launch_file.launch']}, 'roslaunch'); rosLaunch.isBackground = true; rosLaunch.problemMatchers = ['$roslaunch']; @@ -39,18 +39,18 @@ export function registerRosShellTaskProvider(): vscode.Disposable[] { } export function resolve(task: vscode.Task): vscode.Task { - const resolvedTask = make(task.definition as RosTaskDefinition); + let definition = task.definition as RosTaskDefinition + const resolvedTask = make(definition.command, definition); resolvedTask.isBackground = task.isBackground; resolvedTask.problemMatchers = task.problemMatchers; return resolvedTask; } -export function make(definition: RosTaskDefinition, category?: string): vscode.Task { +export function make(name: string, 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, {