Skip to content
This repository has been archived by the owner on Feb 3, 2025. It is now read-only.

Add relocatable setup.bash script #3061

Merged
merged 3 commits into from
Aug 12, 2021

Conversation

scpeters
Copy link
Member

This refactors the setup.sh script to set the GAZEBO_*_PATH environment variables relative to a path specified in a GAZEBO_INSTALL_PREFIX environment variable (defaulting to the current behavior of setting relative to the configure-time install prefix if GAZEBO_INSTALL_PREFIX is empty or unset). It also adds a relocatable setup.bash script that uses bash-specific syntax to detect the folder containing the setup.*sh scripts, set GAZEBO_INSTALL_PREFIX relative to that folder, and then source setup.sh.

Fixes #3056.

Set GAZEBO_*_PATH environment variables relative to a
GAZEBO_INSTALL_PREFIX environment variable if set.
Otherwise fall back to configure-time value of
CMAKE_INSTALL_PREFIX.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Add setup.bash that
* detects path of parent folder folder
* sets GAZEBO_INSTALL_PREFIX relative to that folder
* sources sibling setup.sh script

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
echo "The install prefix ${installPrefix} does not exist."
unset installPrefix
return 1
elif [ ! -f "${installPrefix}/@GAZEBO_RELATIVE_RESOURCE_PATH@/setup.sh" ]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this checking for the existing of the setup.sh produced by this file? Under what circumstance might this condition be true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is checking that the path in the installPrefix variable contains at least one expected file. In this case it resolves to ${installPrefix}/share/gazebo-11/setup.sh for gazebo11, but I suppose we could equivalently choose ${installPrefix}/share/gazebo-11/worlds/empty.world. The first if statement checks that the $installPrefix path exists; the second checks for some expected content.

I suppose it's possible to confuse matters if you manually set GAZEBO_INSTALL_PREFIX to one install path but source the setup.sh from a different install path, but the recommended approach is now to use setup.bash, which should avoid that type of confusion

Copy link

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one question above.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters
Copy link
Member Author

CI looks ok to me, merging

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setup.sh script is not relocatable
2 participants