Colcon plugin¶
The colcon plugin manages the colcon build tool inside a part.
It supports projects that build with CMake and Python packages
that build with setup.py.
It stores build artifacts in the $CRAFT_PART_INSTALL path.
This plugin requires core24 or higher.
Keys¶
This plugin provides the following unique keys.
colcon-cmake-args¶
Type
list[str]
Description
Arguments to pass to CMake projects.
If an argument has the same name as a colcon argument, it must be prefixed with a space to avoid a collision. A space in an argument is made literal by wrapping the argument in double quotation marks (“).
colcon-packages¶
Type
list[str]
Description
The colcon packages to build.
If unset, all packages in the workspace will be built. If set to an empty list
([]), no packages will be built, which could be useful if you only want Debian
packages in the snap.
colcon-packages-ignore¶
Type
list[str]
Description
The packages for colcon to ignore.
Environment variables¶
The plugin sets:
AMENT_PYTHON_EXECUTABLEto “/usr/bin/python3”. This is required for ROS 2 packages.COLCON_PYTHON_EXECUTABLEto “/usr/bin/python3”.
Dependencies¶
The colcon plugin needs the colcon executable to build the source.
The colcon plugin needs the colcon-core package to start colcon,
gcc/g++ and cmake to build C/C++ packages.
Additionally, extensions like colcon-cmake,
colcon-package-selection,
colcon-python-setup-py and colcon-parallel-executor
are needed to support basic builds.
These dependencies are provided and handled by the plugin.
How it works¶
During the build step the plugin performs the following actions:
Source colcon workspaces present in any stage snaps, and on the system.
Call
colcon buildwith any colcon-specific keys set in the part, with--install-base $CRAFT_PART_INSTALLto install the built artifacts
The plugin injects -DCMAKE_BUILD_TYPE=Release and -DBUILD_TESTING=OFF
into the CMake arguments by default. Each argument can be overridden with its own entry
in the colcon-cmake-args key.
Example¶
The following snippet declares a part using the colcon plugin.
It fetches the GoogleTest source code from GitHub,
and builds only the gtest package.
It sets the CMAKE_BUILD_TYPE to RelWithDebInfo
to generate debug symbols from the build:
parts:
hello:
source: https://github.com/google/googletest.git
plugin: colcon
colcon-cmake-args:
- -DCMAKE_BUILD_TYPE=RelWithDebInfo
colcon-packages:
- gtest