Created
January 19, 2022 21:05
-
-
Save shannah/f1a123fdc9492184e1257a3c19563c73 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -e | |
echo "Building on platform $(uname -s)" | |
export CGO_CFLAGS="-I$JAVA_HOME/include" | |
if [ -d "$JAVA_HOME/include/darwin" ]; then | |
export CGO_CFLAGS="-I$JAVA_HOME/include/darwin $CGO_CFLAGS" | |
elif [ -d "$JAVA_HOME/include/linux" ]; then | |
export CGO_CFLAGS="-I$JAVA_HOME/include/linux $CGO_CFLAGS" | |
elif [ -d "$JAVA_HOME/include/win32" ]; then | |
export CGO_CFLAGS="-I$JAVA_HOME/include/win32 $CGO_CFLAGS" | |
fi | |
export CGO_LDFLAGS="" | |
if [ -d "$JAVA_HOME/lib" ]; then | |
export CGO_LDFLAGS="-L$JAVA_HOME/lib $CGO_LDFLAGS" | |
fi | |
if [ -d "$JAVA_HOME/lib/server" ]; then | |
export CGO_LDFLAGS="-L$JAVA_HOME/lib/server $CGO_LDFLAGS" | |
fi | |
if [ -d "$JAVA_HOME/jre/lib" ]; then | |
export CGO_LDFLAGS="-L$JAVA_HOME/jre/lib $CGO_LDFLAGS" | |
fi | |
if [ -d "$JAVA_HOME/jre/lib/server" ]; then | |
export CGO_LDFLAGS="-L$JAVA_HOME/jre/lib/server $CGO_LDFLAGS" | |
fi | |
case "$(uname -s)" in | |
Darwin) | |
export CGO_LDFLAGS="-mmacosx-version-min=10.10 -Wl,-rpath,@executable_path/jdk/lib -Wl,-rpath,@executable_path/jdk/lib/server -lazy-ljvm $CGO_LDFLAGS" | |
export ENABLE_STRICT_OBJC_MSGSEND="NO" | |
export CGO_CFLAGS="-mmacosx-version-min=10.10 $CGO_CFLAGS" | |
export ENABLE_STRICT_OBJC_MSGSEND="NO" | |
export CFLAGS="-mmacosx-version-min=10.10" | |
go build -ldflags="-s -w -extldflags=-mmacosx-version-min=10.10" | |
;; | |
Linux) | |
export CGO_LDFLAGS="-L$JAVA_HOME -Wl,-rpath,jdk/lib -Wl,-rpath,jdk/lib/server -Wl,-rpath,jdk -zlazy -ljvm $CGO_LDFLAGS" | |
go build | |
;; | |
CYGWIN*|MINGW32*|MSYS*|MINGW64*) | |
go build -tags windows -ldflags="-w -s -H=windowsgui" | |
;; | |
# Add here more strings to compare | |
# See correspondence table at the bottom of this answer | |
*) | |
go build | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment