Skip to content

Commit

Permalink
Improve library finding + custom profile name + updated readme
Browse files Browse the repository at this point in the history
Improves library finding by pretending to compile a c file (dummy.c
must exist).

Now that rust-lang/cargo#6988 is in stable, use "colcon" as a custom
profile name. Closes #2.

Use of IDL_PACKAGE_FILTER exemplified in README.md. Closes #3
  • Loading branch information
m-dahl committed Jan 16, 2023
1 parent f15e51f commit f28835e
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 86 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
r2r_minimal_node/target

# colcon stuff
build/
install/
log/
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ cargo clean can be invoked by passing `-DCARGO_CLEAN=ON` to cmake, eg.
colcon build --cmake-args -DCARGO_CLEAN=ON
```

To keep builds performed by colcon separate, `r2r_cargo` *expects a custom profile called `colcon` to exist*. See <https://github.com/m-dahl/r2r_minimal_node/blob/master/r2r_minimal_node/Cargo.toml> for an example.

## Building using only cargo

Another option is to build the message package first, then sourcing the resulting workspace. When `r2r_minimal_node_msgs` is sourced, the r2r build script will automatically pick up the custom messages (it defaults to building everything).

To avoid building everything, it is possible to declare only the messages needed using the environment variable `IDL_PACKAGE_FILTER`. Setting this can be done in `.cargo/config.toml` for convenience, e.g. <https://github.com/m-dahl/r2r_minimal_node/blob/master/r2r_minimal_node/.cargo/config.toml>

``` sh
mkdir src
cd src
Expand Down
4 changes: 1 addition & 3 deletions r2r_minimal_node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ r2r_cargo(std_msgs # just to test that it works
rcl # we need the c ros2 api
rcl_action # as of r2r 0.1.0, we also need the action api
r2r_minimal_node_msgs # our custom message types
rmw_fastrtps_cpp # (needed to build with RMW_IMPLEMENTATION=rmw_fastrtps_cpp)
FastRTPS # (needed to build with RMW_IMPLEMENTATION=rmw_fastrtps_cpp)
)

# install binaries
install(PROGRAMS
${CMAKE_SOURCE_DIR}/target/release/${PROJECT_NAME}
${CMAKE_SOURCE_DIR}/target/colcon/${PROJECT_NAME}
DESTINATION lib/${PROJECT_NAME}
)

Expand Down
100 changes: 50 additions & 50 deletions r2r_minimal_node/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion r2r_minimal_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ version = "0.1.0"
authors = ["Martin Dahl <martin.dahl@gmail.com>"]
edition = "2021"

# We use a custom profile to keep colcon
# separate from "normal" rust building.
[profile.colcon]
inherits = "release"

[dependencies]
r2r = "0.6.3"
r2r = "0.6.4"
futures = "0.3.15"
tokio = { version = "1", features = ["full"] }
Empty file added r2r_minimal_node/dummy.c
Empty file.

0 comments on commit f28835e

Please sign in to comment.