diff --git a/ament_java_resources/CMakeLists.txt b/ament_java_resources/CMakeLists.txt index fab14ab..a0bbf00 100644 --- a/ament_java_resources/CMakeLists.txt +++ b/ament_java_resources/CMakeLists.txt @@ -6,12 +6,22 @@ find_package(ament_cmake REQUIRED) ament_index_register_resource( "templates" - CONTENT_FILE "classpath.dsv.template" - PACKAGE_NAME "ament_build_type_gradle_classpath_dsv") + CONTENT_FILE "classpath.sh.template" + PACKAGE_NAME "ament_build_type_gradle_classpath_sh") ament_index_register_resource( "templates" - CONTENT_FILE "jni_library_path.dsv.template" - PACKAGE_NAME "ament_build_type_gradle_jni_library_path_dsv") + CONTENT_FILE "classpath.bat.template" + PACKAGE_NAME "ament_build_type_gradle_classpath_bat") +ament_index_register_resource( + "templates" + CONTENT_FILE "jni_library_path.sh.template" + PACKAGE_NAME "ament_build_type_gradle_jni_library_path_sh") + +ament_index_register_resource( + "templates" + CONTENT_FILE "jni_library_path.bat.template" + PACKAGE_NAME "ament_build_type_gradle_jni_library_path_bat") + ament_package() diff --git a/ament_java_resources/classpath.bat.template b/ament_java_resources/classpath.bat.template new file mode 100644 index 0000000..6dc448a --- /dev/null +++ b/ament_java_resources/classpath.bat.template @@ -0,0 +1,5 @@ +ament_prepend_unique_value CLASSPATH "." +REM https://ss64.com/nt/for.html +FOR %%j IN (@_AMENT_EXPORT_JARS_CLASSPATH@) DO ( + ament_prepend_unique_value CLASSPATH "%%j" +) diff --git a/ament_java_resources/classpath.dsv.template b/ament_java_resources/classpath.dsv.template deleted file mode 100644 index 428e14d..0000000 --- a/ament_java_resources/classpath.dsv.template +++ /dev/null @@ -1 +0,0 @@ -prepend-non-duplicate;CLASSPATH;@_AMENT_EXPORT_JARS_CLASSPATH@ diff --git a/ament_java_resources/classpath.sh.template b/ament_java_resources/classpath.sh.template new file mode 100644 index 0000000..fc8ace3 --- /dev/null +++ b/ament_java_resources/classpath.sh.template @@ -0,0 +1,27 @@ +if [ -n "$ZSH_VERSION" ]; then + if [[ $options[shwordsplit] = off ]]; then + _AMENT_JAVA_SH_WORD_SPLIT=1 + setopt shwordsplit + fi +fi + +ament_prepend_unique_value CLASSPATH "." +_AMENT_JAVA_IFS=$IFS +IFS=";" +jars="@_AMENT_EXPORT_JARS_CLASSPATH@" + +for jar in $jars +do + ament_prepend_unique_value CLASSPATH "$jar" +done + +IFS=$_AMENT_JAVA_IFS + +unset jar +unset jars +unset AMENT_JAVA_IFS + +if [ -n "$_AMENT_JAVA_SH_WORD_SPLIT" ]; then + unsetopt shwordsplit + unset _AMENT_JAVA_SH_WORD_SPLIT +fi diff --git a/ament_java_resources/jni_library_path.bat.template b/ament_java_resources/jni_library_path.bat.template new file mode 100644 index 0000000..f759d3a --- /dev/null +++ b/ament_java_resources/jni_library_path.bat.template @@ -0,0 +1 @@ +ament_prepend_unique_value PATH "%AMENT_CURRENT_PREFIX%\lib\jni" diff --git a/ament_java_resources/jni_library_path.dsv.template b/ament_java_resources/jni_library_path.dsv.template deleted file mode 100644 index 640bff5..0000000 --- a/ament_java_resources/jni_library_path.dsv.template +++ /dev/null @@ -1 +0,0 @@ -prepend-non-duplicate;@JNI_LIB_ENV_VAR@;lib/jni diff --git a/ament_java_resources/jni_library_path.sh.template b/ament_java_resources/jni_library_path.sh.template new file mode 100644 index 0000000..f2ccd76 --- /dev/null +++ b/ament_java_resources/jni_library_path.sh.template @@ -0,0 +1,14 @@ +# detect if running on Darwin platform +_UNAME=`uname -s` +_IS_DARWIN=0 +if [ "$_UNAME" = "Darwin" ]; then + _IS_DARWIN=1 +fi +unset _UNAME + +if [ $_IS_DARWIN -eq 0 ]; then + ament_prepend_unique_value LD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib/jni" +else + ament_prepend_unique_value DYLD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib/jni" +fi +unset _IS_DARWIN