Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
stites
committed
Feb 21, 2018
1 parent
5de26bb
commit df1ba2b
Showing
1 changed file
with
29 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,34 @@ | ||
#!/usr/bin/env bash | ||
if [[ "$0" != "$BASH_SOURCE" ]]; then | ||
echo 'This script is not meant to be sourced. Please run `./setenv` instead, or `chmod u+x ./setenv && ./setenv`' | ||
else | ||
# execute this command if needed when building on OSX if there are linker errors. | ||
# dylib files in extra-lib-dirs don't get forwarded to ghc | ||
# in some versions of OSX. See https://github.com/commercialhaskell/stack/issues/1826 | ||
HASKTORCH_LIB_PATH="$(pwd)/vendor/build/" | ||
|
||
function add_vendor_lib_path { | ||
case "$(uname)" in | ||
"Darwin") | ||
DYLD_LIBRARY_PATH=$HASKTORCH_LIB_PATH:$DYLD_LIBRARY_PATH | ||
export DYLD_LIBRARY_PATH | ||
;; | ||
"Linux"|"FreeBSD") | ||
LD_LIBRARY_PATH=$HASKTORCH_LIB_PATH:$LD_LIBRARY_PATH | ||
export LD_LIBRARY_PATH | ||
;; | ||
*) | ||
echo "OS doesn't have known environment variable hacks to set" | ||
;; | ||
esac | ||
} | ||
# execute this command if needed when building on OSX if there are linker errors. | ||
# dylib files in extra-lib-dirs don't get forwarded to ghc | ||
# in some versions of OSX. See https://github.com/commercialhaskell/stack/issues/1826 | ||
HASKTORCH_LIB_PATH="$(pwd)/vendor/build/" | ||
|
||
function add_vendor_lib_path { | ||
case "$(uname)" in | ||
"Darwin") | ||
DYLD_LIBRARY_PATH=$HASKTORCH_LIB_PATH:$DYLD_LIBRARY_PATH | ||
export DYLD_LIBRARY_PATH | ||
;; | ||
"Linux"|"FreeBSD") | ||
LD_LIBRARY_PATH=$HASKTORCH_LIB_PATH:$LD_LIBRARY_PATH | ||
export LD_LIBRARY_PATH | ||
;; | ||
*) | ||
echo "OS doesn't have known environment variable hacks to set" | ||
;; | ||
esac | ||
} | ||
|
||
if ! type git &> /dev/null; then | ||
echo "git is not installed, setenv cannot reliably perform checks to set your system's library path" | ||
exit 1 | ||
fi | ||
if ! type git &> /dev/null; then | ||
echo "git is not installed, setenv cannot reliably perform checks to set your system's library path" | ||
fi | ||
|
||
if [[ "$(basename "$(git rev-parse --show-toplevel)")" == "hasktorch" ]] && ls $HASKTORCH_LIB_PATH &> /dev/null; then | ||
echo "updating library path..." | ||
add_vendor_lib_path | ||
echo "...done!" | ||
exit 0 | ||
else | ||
echo "couldn't update library path. Please file an issue or adjust this script for your system and submit a pull request" | ||
exit 1 | ||
fi | ||
if [[ "$(basename "$(git rev-parse --show-toplevel)")" == "hasktorch" ]] && ls $HASKTORCH_LIB_PATH &> /dev/null; then | ||
echo "updating library path..." | ||
add_vendor_lib_path | ||
echo "...done!" | ||
else | ||
echo "couldn't update library path. Please file an issue or adjust this script for your system and submit a pull request" | ||
fi |