colcon-recursive-crawl

0.2.3 · active · verified Fri Apr 17

colcon-recursive-crawl is an extension for colcon, the build tool for ROS and other package-based systems, enabling it to recursively discover packages within a specified directory structure. As of version 0.2.3, it enhances colcon's package discovery capabilities without requiring manual listing. Releases are infrequent, tied to specific feature additions or compatibility updates with `colcon-core`.

Common errors

Warnings

Install

Quickstart

This quickstart demonstrates how to use `colcon-recursive-crawl` to build packages found in a nested directory structure. The extension adds the `--recursive-crawl` argument to standard colcon verbs like `build`, `test`, or `install`. This example sets up a simple `src` directory with two dummy packages for testing.

# Assuming you have colcon-core installed and a 'src' directory with ROS packages
# Create some dummy package structure for demonstration
import os
import shutil

# Clean up previous run if any
if os.path.exists('src'):
    shutil.rmtree('src')
if os.path.exists('build'):
    shutil.rmtree('build')
if os.path.exists('install'):
    shutil.rmtree('install')
if os.path.exists('log'):
    shutil.rmtree('log')

# Create dummy package directories and package.xml files
os.makedirs('src/my_pkg_a', exist_ok=True)
os.makedirs('src/my_pkg_b/src', exist_ok=True)

with open('src/my_pkg_a/package.xml', 'w') as f:
    f.write('<package><name>my_pkg_a</name><version>0.0.0</version><description>Test A</description><maintainer email="a@example.com">a</maintainer><license>Apache 2.0</license></package>')

with open('src/my_pkg_b/package.xml', 'w') as f:
    f.write('<package><name>my_pkg_b</name><version>0.0.0</version><description>Test B</description><maintainer email="b@example.com">b</maintainer><license>Apache 2.0</license><depend>my_pkg_a</depend></package>')

print("Dummy package structure created in 'src/'")
print("Now, run colcon build with recursive crawl:")
print("colcon build --recursive-crawl src")

# To actually run the colcon command, you would execute this in a shell:
# import subprocess
# try:
#     subprocess.run(['colcon', 'build', '--recursive-crawl', 'src'], check=True)
#     print("colcon build --recursive-crawl src completed successfully.")
# except subprocess.CalledProcessError as e:
#     print(f"colcon command failed: {e}")
# except FileNotFoundError:
#     print("Error: 'colcon' command not found. Please ensure colcon-core is installed and in your PATH.")

view raw JSON →