Files
kotlin-fork/samples/opengl/build.sh
T
Alexander Podkhalyuzin bc941269f0 Fixed samples for the latest changes in Gradle plugin.
- Smaller gradle scripts.
- More structure in sample projects.
- Simplified build/run.
- Added gradle to the rest two samples.
- Almost removed all sh scripts.
- Gradle now works only inside of build directory.
- Fixed READMEs according to the new changes.
2017-06-08 17:21:04 +03:00

34 lines
992 B
Bash
Executable File

#!/usr/bin/env bash
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )
PATH=$DIR/../../dist/bin:$DIR/../../bin:$PATH
LINKER_ARGS_macbook="-framework OpenGL -framework GLUT"
LINKER_ARGS_linux="-L/usr/lib/x86_64-linux-gnu -lglut -lGL -lGLU"
if [ x$TARGET == x ]; then
case "$OSTYPE" in
darwin*) TARGET=macbook ;;
linux*) TARGET=linux ;;
*) echo "unknown: $OSTYPE" && exit 1;;
esac
fi
var=CFLAGS_${TARGET}
CFLAGS=${!var}
var=LINKER_ARGS_${TARGET}
LINKER_ARGS=${!var}
var=COMPILER_ARGS_${TARGET}
COMPILER_ARGS=${!var} # add -opt for an optimized build.
mkdir -p $DIR/build/c_interop/
mkdir -p $DIR/build/bin/
cinterop -def $DIR/src/main/c_interop/opengl.def -target $TARGET \
-o $DIR/build/c_interop/opengl.kt.bc || exit 1
konanc -target $TARGET $DIR/src/main/kotlin/OpenGlTeapot.kt -library $DIR/build/c_interop/opengl.kt.bc \
-linkerOpts "$LINKER_ARGS" -o $DIR/build/bin/OpenGlTeapot.kexe || exit 1
echo "Artifact path is ./build/bin/OpenGlTeapot.kexe"