From 8ac984f2278dc8ade750bf506ff03f11c11e6ea2 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 29 Dec 2016 17:10:04 +0100 Subject: [PATCH] env-hooks: install env-hook to etc/orocos/profile.d Check https://github.com/orocos-toolchain/orocos_toolchain/pull/13. Also set [DY]LD_LIBRARY_PATH here instead of in the typelib env-hook. Signed-off-by: Johannes Meyer --- CMakeLists.txt | 10 ++++++++++ env-hooks/00.utilrb.sh.in | 30 ++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fac5f7..31d009a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,16 @@ string(REGEX REPLACE ".*(lib|share)(32|64)?/?" "\\1/" RUBY_LIBRARY_INSTALL_DIR $ install(DIRECTORY lib/ DESTINATION ${RUBY_LIBRARY_INSTALL_DIR} ) install(FILES package.xml DESTINATION share/utilrb) +# Install an env-hook in etc/orocos/${OROCOS_TARGET}/profile.d +configure_file(env-hooks/00.utilrb.sh.in ${CMAKE_CURRENT_BINARY_DIR}/env-hooks/00.utilrb.sh @ONLY) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/env-hooks/00.utilrb.sh + DESTINATION etc/orocos/profile.d +) + +message(STATUS "RUBY_RUBY_LIB_DIR: ${RUBY_RUBY_LIB_DIR}") +message(STATUS "RUBY_ARCH_DIR: ${RUBY_ARCH_DIR}") + # Install an env-hook if catkin is found find_package(catkin QUIET) if(catkin_FOUND) diff --git a/env-hooks/00.utilrb.sh.in b/env-hooks/00.utilrb.sh.in index e09333e..46433d6 100644 --- a/env-hooks/00.utilrb.sh.in +++ b/env-hooks/00.utilrb.sh.in @@ -2,9 +2,31 @@ export RUBYOPT=-rubygems -export RUBYLIB=@CMAKE_INSTALL_PREFIX@/@RUBY_EXTENSIONS_INSTALL_DIR@:@CMAKE_INSTALL_PREFIX@/@RUBY_LIBRARY_INSTALL_DIR@ +for path in "@CMAKE_INSTALL_PREFIX@/@RUBY_LIBRARY_INSTALL_DIR@" "@CMAKE_INSTALL_PREFIX@/@RUBY_EXTENSIONS_INSTALL_DIR@"; do + if [ ! -d "$path" ]; then + continue + fi -if [ `uname -s` = Darwin ]; then - export RUBYLIB=$RUBYLIB:@RUBY_ARCH_DIR@:@RUBY_RUBY_LIB_DIR@ -fi + if [ -z "$RUBYLIB" ]; then + RUBYLIB="$path" + elif ! echo "$RUBYLIB" | grep -q "$path"; then + RUBYLIB="$path:$RUBYLIB" + fi + export RUBYLIB + if [ `uname -s` != Darwin ]; then + if [ -z "$LD_LIBRARY_PATH" ]; then + LD_LIBRARY_PATH="$path" + elif ! echo "$LD_LIBRARY_PATH" | grep -q "$path"; then + LD_LIBRARY_PATH="$path:$LD_LIBRARY_PATH" + fi + export LD_LIBRARY_PATH + else + if [ -z "$DYLD_LIBRARY_PATH" ]; then + DYLD_LIBRARY_PATH="$path" + elif ! echo "$DYLD_LIBRARY_PATH" | grep -q "$path"; then + DYLD_LIBRARY_PATH="$path:$DYLD_LIBRARY_PATH" + fi + export DYLD_LIBRARY_PATH + fi +done \ No newline at end of file