Skip to content

Add .sh env hook for setting GZ_CONFIG_PATH #11

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
4 changes: 4 additions & 0 deletions create_gz_vendor_pkg/create_vendor_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ def main(argv=sys.argv[1:]):
templates_path / "vendor.dsv.in",
Path(args.output_dir) / f"{vendor_name}.dsv.in",
)
shutil.copy(
templates_path / "vendor.sh.in",
Path(args.output_dir) / f"{vendor_name}.sh.in",
)


if __name__ == "__main__":
Expand Down
5 changes: 1 addition & 4 deletions create_gz_vendor_pkg/templates/CMakeLists.txt.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ ament_export_dependencies(
{% if vendor_has_dsv %}
if(NOT ${${LIB_NAME_FULL}_FOUND})
ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.dsv.in")
# Create a dummy .sh file needed for ament_package to source the .dsv file.
# See https://github.com/ament/ament_package/issues/145
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.sh "# Dummy .sh file needed for .dsv file to be sourced.")
ament_environment_hooks("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.sh")
ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.sh.in")
endif()
{% endif %}

Expand Down
3 changes: 3 additions & 0 deletions create_gz_vendor_pkg/templates/vendor.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if [ -d "$AMENT_CURRENT_PREFIX/opt/@PROJECT_NAME@/share/gz" ]; then
ament_prepend_unique_value GZ_CONFIG_PATH "$AMENT_CURRENT_PREFIX/opt/@PROJECT_NAME@/share/gz"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I tested this by building a colcon workspace with the vendor packages and deleting the .dsv files in the install directories. What I found is that since $AMENT_CURRENT_PREFIX was /opt/ros/rolling, the condition here is never satisfied and GZ_CONFIG_PATH is never set. So I guess this would only work if you're installing the vendor packages to /opt/ros/<ros-version>?

fi