diff --git a/recipe/bld.bat b/recipe/bld.bat index 4f215f5d..5d224da2 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -1,3 +1,5 @@ +setlocal EnableDelayedExpansion + XCOPY bin\* %LIBRARY_BIN% /s /i /y if errorlevel 1 exit 1 @@ -7,10 +9,18 @@ if errorlevel 1 exit 1 XCOPY lib\* %LIBRARY_LIB% /s /i /y if errorlevel 1 exit 1 - :: ensure that JAVA_HOME is set correctly mkdir %PREFIX%\etc\conda\activate.d echo set "JAVA_HOME_CONDA_BACKUP=%%JAVA_HOME%%" > "%PREFIX%\etc\conda\activate.d\java_home.bat" echo set "JAVA_HOME=%%CONDA_PREFIX%%\Library" >> "%PREFIX%\etc\conda\activate.d\java_home.bat" mkdir %PREFIX%\etc\conda\deactivate.d echo set "JAVA_HOME=%%JAVA_HOME_CONDA_BACKUP%%" > "%PREFIX%\etc\conda\deactivate.d\java_home.bat" + +:: Copy the [de]activate scripts to %PREFIX%\etc\conda\[de]activate.d. +:: This will allow them to be run on environment activation. +FOR %%F IN (activate deactivate) DO ( + if not exist %PREFIX%\etc\conda\%%F.d MKDIR %PREFIX%\etc\conda\%%F.d + if errorlevel 1 exit 1 + copy %RECIPE_DIR%\scripts\%%F.bat %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.bat + if errorlevel 1 exit 1 +) \ No newline at end of file diff --git a/recipe/build.sh b/recipe/build.sh index 278e78c4..70371a39 100644 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -26,8 +26,10 @@ fi mv lib/* $PREFIX/lib -# Ensure that JAVA_HOME is set correctly -mkdir -p $PREFIX/etc/conda/activate.d -mkdir -p $PREFIX/etc/conda/deactivate.d -cp $RECIPE_DIR/scripts/activate.sh $PREFIX/etc/conda/activate.d/java_home.sh -cp $RECIPE_DIR/scripts/deactivate.sh $PREFIX/etc/conda/deactivate.d/java_home.sh +# Copy the [de]activate scripts to $PREFIX/etc/conda/[de]activate.d. +# This will allow them to be run on environment activation. +for CHANGE in "activate" "deactivate" +do + mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d" + cp "${RECIPE_DIR}/scripts/${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh" +done diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 5c5df05b..4be46d08 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -29,7 +29,7 @@ build: requirements: build: - - curl + - curl # [unix] test: files: diff --git a/recipe/scripts/deactivate.bat b/recipe/scripts/deactivate.bat index c7c4e055..0f13d18c 100644 --- a/recipe/scripts/deactivate.bat +++ b/recipe/scripts/deactivate.bat @@ -1 +1,2 @@ set "JAVA_HOME=%JAVA_HOME_CONDA_BACKUP%" +set "JAVA_HOME_CONDA_BACKUP=" diff --git a/recipe/test-jni.sh b/recipe/test-jni.sh index af24fd06..e3067dc0 100755 --- a/recipe/test-jni.sh +++ b/recipe/test-jni.sh @@ -1,20 +1,19 @@ #!/bin/bash - set -e -export + if [ ! -d $JAVA_LD_LIBRARY_PATH ]; then echo "Did you remember to activate the conda environment?" exit -1 fi + os=$(uname -s | tr '[:upper:]' '[:lower:]') +gcc -I$JAVA_HOME/include \ + -I$JAVA_HOME/include/$os \ + -Wl,-rpath,$JAVA_LD_LIBRARY_PATH \ + -L$JAVA_LD_LIBRARY_PATH \ + -L$JAVA_LD_LIBRARY_PATH/server \ + -o vmtest \ + test-jni/vmtest.c \ + -ljvm -gcc \ - -I$JAVA_HOME/include \ - -I$JAVA_HOME/include/$os \ - -Wl,-rpath,$JAVA_LD_LIBRARY_PATH \ - -L$JAVA_LD_LIBRARY_PATH \ - -ljvm \ - -o vmtest \ - test-jni/vmtest.c - ./vmtest