facebookresearch / diffkt

A framework for automatic differentiation in Kotlin
MIT License
59 stars 6 forks source link

Fix environmental variable issues. #75

Closed david-boney-jobs closed 2 years ago

david-boney-jobs commented 2 years ago

Move the follow code from kotlin/scripts/set_env_vars.sh to kotlin/api/src/main/kotlin/org.diffkt/external/LibraryUtils.kt and remove placing info in environmental variables in the first place.

Set machine-dependent env vars. Extension is used for locating shared libraries

if [ "$(uname)" = "Darwin" ]; then export ENV_NAME="DARWIN" export DYLIB_EXTENSION=".dylib" if [ "$(echo $(sw_vers -productVersion) | cut -c1-5)" = "10.15" ]; then export SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" export CPLUS_INCLUDE_PATH="/usr/local/opt/gflags/include/" fi elif [ "$(expr substr $(uname -s) 1 5)" = "Linux" ]; then export ENV_NAME="LINUX" export DYLIB_EXTENSION=".so" fi

and update this code in LibraryUtils.kt

fun getLibNameWithExtension(name: String): String { val ext = System.getenv(DYLIB_EXTENSION_ENV_VAR) ?: DEFAULT_DYLIB_EXTENSION return "${name}$ext" }

david-boney-jobs commented 2 years ago

Done.