Skip to content

Commit 5ea1c95

Browse files
authored
Add rosidl_rust to a sourced overlay in the docker image (#494)
* Add rosidl_rust in an overlay sourced in the dev container via an entrypoint. Move any logic that will change between distros into shell scripts for more flexibility. * Install the latest colcon-cargo and colcon-ros-cargo * trigger ci * trigger ci
1 parent b40f96a commit 5ea1c95

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

Dockerfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ RUN apt-get update && apt-get install -y \
1515
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.75.0 -y
1616
ENV PATH=/root/.cargo/bin:$PATH
1717

18-
# Install the colcon-cargo and colcon-ros-cargo plugins
19-
RUN if [ "$ROS_DISTRO" = "humble" ] ; \
20-
then pip install --upgrade pytest && pip install colcon-ros-cargo ; \
21-
else pip install --break-system-packages pytest colcon-ros-cargo ; fi
18+
COPY src/ros2_rust/docker/install_colcon_plugins.sh /
19+
RUN ./install_colcon_plugins.sh
20+
21+
COPY src/ros2_rust/docker/rosidl_rust_setup.sh /
22+
RUN ./rosidl_rust_setup.sh
2223

2324
RUN mkdir -p /workspace && echo "Did you forget to mount the repository into the Docker container?" > /workspace/HELLO.txt
2425
WORKDIR /workspace
26+
27+
COPY src/ros2_rust/docker/rosidl_rust_entrypoint.sh /
28+
ENTRYPOINT ["/rosidl_rust_entrypoint.sh"]
29+
CMD ["/bin/bash"]

docker/install_colcon_plugins.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
if [ "$ROS_DISTRO" = "humble" ]; then
4+
pip install --upgrade pytest
5+
pip install \
6+
git+https://github.com/colcon/colcon-cargo.git \
7+
git+https://github.com/colcon/colcon-ros-cargo.git
8+
else
9+
pip install --break-system-packages pytest \
10+
git+https://github.com/colcon/colcon-cargo.git \
11+
git+https://github.com/colcon/colcon-ros-cargo.git
12+
fi

docker/rosidl_rust_entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# setup ros2 environment
5+
source "/opt/ros/$ROS_DISTRO/setup.bash" --
6+
7+
# If we're a distro that needs the overlay built, then source it
8+
if [ -f "/tmp/rosidl_rust_overlay/install/setup.bash" ]; then
9+
source /tmp/rosidl_rust_overlay/install/setup.bash --
10+
fi
11+
12+
exec "$@"

docker/rosidl_rust_setup.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# Depending on the ROS_DISTRO, make sure we've got rosidl_generator_rs
4+
# sourced and available in working directory workspace
5+
6+
if [ "$ROS_DISTRO" = "rolling" ]; then
7+
apt-get update && apt-get install -y ros-$ROS_DISTRO-rosidl-generator-rs
8+
else
9+
# Temporarily add `rosidl_rust` to an overlay, build, and source it.
10+
mkdir -p /tmp/rosidl_rust_overlay/src
11+
git clone https://github.com/ros2-rust/rosidl_rust /tmp/rosidl_rust_overlay/src
12+
13+
cd /tmp/rosidl_rust_overlay
14+
15+
. /opt/ros/$ROS_DISTRO/setup.sh
16+
colcon build
17+
fi

0 commit comments

Comments
 (0)