https://github.com/colcon/colcon-cargo
An extension for colcon-core to support Rust projects built with Cargo
https://github.com/colcon/colcon-cargo
cargo colcon
Last synced: about 1 year ago
JSON representation
An extension for colcon-core to support Rust projects built with Cargo
- Host: GitHub
- URL: https://github.com/colcon/colcon-cargo
- Owner: colcon
- License: apache-2.0
- Created: 2018-07-17T18:30:34.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2025-03-14T22:25:05.000Z (over 1 year ago)
- Last Synced: 2025-05-17T10:09:46.742Z (about 1 year ago)
- Topics: cargo, colcon
- Language: Python
- Homepage: http://colcon.readthedocs.io
- Size: 88.9 KB
- Stars: 36
- Watchers: 9
- Forks: 21
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# colcon-cargo
[](https://github.com/colcon/colcon-cargo/actions/workflows/ci.yaml?query=branch%3Amain+event%3Apush)
An extension for [colcon-core](https://github.com/colcon/colcon-core) to
support Rust projects built with Cargo.
## Install
```sh
$ pip3 install --user --upgrade git+https://github.com/colcon/colcon-cargo.git
```
## Usage / Minimal example
Build a sample workspace
```sh
$ mkdir ws/
$ cd ws/
$ cargo init hello_world
$ cargo init hello_world2
$ tree .
.
├── hello-world
│ ├── Cargo.toml
│ └── src
│ └── main.rs
└── hello-world2
├── Cargo.toml
└── src
└── main.rs
4 directories, 4 files
```
Verify that cargo detects the Rust packages:
```sh
$ colcon list
hello-world hello-world (cargo)
hello-world2 hello-world2 (cargo)
```
Build them with Cargo:
```sh
$ colcon build
Starting >>> hello_world
Starting >>> hello_world_2
Finished <<< hello_world_2 [1.84s]
Finished <<< hello_world [1.94s]
Summary: 2 packages finished [2.34s]
```
Source the generated `install/` directory and execute:
```sh
$ source install/setup.bash
$ hello-world
Hello, world!
$ hello-world2
Hello, world!
```
### Testing
Test the packages with cargo:
```sh
$ colcon test
Starting >>> hello_world_2
Starting >>> hello_world
Finished <<< hello_world [0.24s]
Finished <<< hello_world_2 [0.25s]
Summary: 2 packages finished [0.39s]
```
Inspect the test results (`cargo test` and `cargo fmt --check`).
They should all succeed for the empty templates:
```sh
$ colcon test-result --all
build/hello_world_2/cargo_test.xml: 2 tests, 0 errors, 0 failures, 0 skipped
build/hello_world/cargo_test.xml: 2 tests, 0 errors, 0 failures, 0 skipped
Summary: 4 tests, 0 errors, 0 failures, 0 skipped
```