Skip to content

Commit

Permalink
Updated scripts to support ROS-independent builds
Browse files Browse the repository at this point in the history
  • Loading branch information
marip8 committed Mar 2, 2023
1 parent d462896 commit f5e1e7c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions industrial_ci/src/isolation/docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ PYLINT_ARGS
PYLINT_CHECK
PYLINT_EXCLUDE
PYTHONUNBUFFERED
PYTHON_VERSION_NAME
ROSDEP_SKIP_KEYS
ROSINSTALL_FILENAME
ROS_DISTRO
ROS_PYTHON_VERSION
ROS_REPO
ROS_REPOSITORY_KEY
ROS_REPOSITORY_PATH
ROS_VERSION
ROS_VERSION_EOL
TARGET_CMAKE_ARGS
TARGET_REPO_NAME
TARGET_REPO_PATH
Expand Down
11 changes: 9 additions & 2 deletions industrial_ci/src/isolation/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,15 @@ function ici_isolate() {
fi

if [ -z "${ROS_DISTRO:-}" ]; then
ROS_DISTRO=$(docker image inspect --format "{{.Config.Env}}" "${DOCKER_IMAGE}" | grep -o -P "(?<=ROS_DISTRO=)[a-z]*") || ici_error "ROS_DISTRO is not set"
elif [ "${ROS_DISTRO}" = "false" ]; then
# Attempt to extract ROS_DISTRO from the docker image
ROS_DISTRO=$(docker image inspect --format "{{.Config.Env}}" "${DOCKER_IMAGE}" | grep -o -P "(?<=ROS_DISTRO=)[a-z]*")
if [ -z "${ROS_DISTRO:-}" ]; then
ici_log "Could not extract environment variable 'ROS_DISTRO' from the docker image '${DOCKER_IMAGE}'; proceeding without 'ROS_DISTRO'"
unset ROS_DISTRO
else
ici_log "Extracted 'ROS_DISTRO=${ROS_DISTRO}' from docker image '${DOCKER_IMAGE}'"
fi
elif [ "${ROS_DISTRO:-}" = "false" ]; then
unset ROS_DISTRO
fi

Expand Down
5 changes: 4 additions & 1 deletion industrial_ci/src/ros.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ function _set_ros_defaults {
_ros2_defaults "jammy"
;;
"false")
export BUILDER=${BUILDER:-colcon}
export ROS_VERSION=0
export ROS_VERSION_EOL=false
export ROS_PYTHON_VERSION=${ROS_PYTHON_VERSION:-3}
unset ROS_DISTRO
;;
*)
Expand All @@ -100,7 +104,6 @@ function _set_ros_defaults {
elif [ "$ROS_PYTHON_VERSION" = 3 ]; then
export PYTHON_VERSION_NAME=python3
fi

}

function _use_snapshot() {
Expand Down
2 changes: 1 addition & 1 deletion industrial_ci/src/tests/source_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function run_source_tests {

ici_step "setup_rosdep" ici_setup_rosdep

extend=${UNDERLAY:?}
extend=${UNDERLAY:-}

if [ -n "$UPSTREAM_WORKSPACE" ]; then
ici_with_ws "$upstream_ws" ici_build_workspace "upstream" "$extend" "$upstream_ws"
Expand Down
6 changes: 3 additions & 3 deletions industrial_ci/src/workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ function ici_setup_rosdep {

if [ "$ROS_DISTRO" = "indigo" ] || [ "$ROS_DISTRO" = "jade" ]; then
ici_apt_install "ros-$ROS_DISTRO-roslib"
else
elif [ ! -z "${ROS_DISTRO:-}" ]; then
ici_apt_install "ros-$ROS_DISTRO-ros-environment"
fi

Expand All @@ -331,7 +331,7 @@ function ici_setup_rosdep {
fi

update_opts=()
if [ -z "${ROSDISTRO_INDEX_URL:-}" ]; then
if [ -z "${ROSDISTRO_INDEX_URL:-}" && ! -z "$ROS_DISTRO" ]; then
update_opts+=(--rosdistro "$ROS_DISTRO")
fi
if [ "$ROS_VERSION_EOL" = true ]; then
Expand Down Expand Up @@ -406,7 +406,7 @@ function ici_source_setup {
local extend=$1; shift
if [ ! -f "$extend/setup.bash" ]; then
if [ "$extend" != "/opt/ros/$ROS_DISTRO" ]; then
ici_error "'$extend' is not a devel/install space"
ici_log "'$extend' is not a devel/install space; skipping source"
fi
else
ici_with_unset_variables source "$extend/setup.bash"
Expand Down

0 comments on commit f5e1e7c

Please sign in to comment.