Skip to content

Add rosidl_rust to a sourced overlay in the docker image #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ RUN apt-get update && apt-get install -y \
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.75.0 -y
ENV PATH=/root/.cargo/bin:$PATH

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

COPY src/ros2_rust/docker/rosidl_rust_setup.sh /
RUN ./rosidl_rust_setup.sh

RUN mkdir -p /workspace && echo "Did you forget to mount the repository into the Docker container?" > /workspace/HELLO.txt
WORKDIR /workspace

COPY src/ros2_rust/docker/rosidl_rust_entrypoint.sh /
ENTRYPOINT ["/rosidl_rust_entrypoint.sh"]
CMD ["/bin/bash"]
8 changes: 8 additions & 0 deletions docker/install_colcon_plugins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if [ "$ROS_DISTRO" = "humble" ]; then
pip install --upgrade pytest
pip install colcon-ros-cargo
else
pip install --break-system-packages pytest colcon-ros-cargo
fi
12 changes: 12 additions & 0 deletions docker/rosidl_rust_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

# setup ros2 environment
source "/opt/ros/$ROS_DISTRO/setup.bash" --

# If we're a distro that needs the overlay built, then source it
if [ -f "/tmp/rosidl_rust_overlay/install/setup.bash" ]; then
source /tmp/rosidl_rust_overlay/install/setup.bash --
fi

exec "$@"
17 changes: 17 additions & 0 deletions docker/rosidl_rust_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Depending on the ROS_DISTRO, make sure we've got rosidl_generator_rs
# sourced and available in working directory workspace

if [ "$ROS_DISTRO" = "rolling" ]; then
apt-get update && apt-get install -y ros-$ROS_DISTRO-rosidl-generator-rs
else
# Temporarily add `rosidl_rust` to an overlay, build, and source it.
mkdir -p /tmp/rosidl_rust_overlay/src
git clone https://github.com/ros2-rust/rosidl_rust /tmp/rosidl_rust_overlay/src

cd /tmp/rosidl_rust_overlay

. /opt/ros/$ROS_DISTRO/setup.sh
colcon build
fi
Loading