-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·53 lines (42 loc) · 1 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
if [ ! -e build.sh ]; then
echo "build.sh must be ran from the root of the project."
exit 1
fi
which cmake >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "You must install cmake first."
exit 1
fi
which mvn >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "You must install maven first."
exit 1
fi
set -e
if [ -z "${JAVA_HOME}" ]; then
for DIR in /usr/lib/jvm/*1.8* /usr/lib/jvm/java-7-openjdk-*; do
if [ -d "$DIR" ] && [ -x "$DIR"/bin/javac ]; then
export JAVA_HOME="$DIR"
fi
done
fi
export PATH="$JAVA_HOME/bin:$PATH"
# Cleanup
pushd . && rm -rf build dist && mkdir build
# Generate the JNI interface header
cd ./java
mvn clean compile
declare -a CMAKE_ARGS=()
if [ -n "${CMAKE_OSX_ARCHITECTURES}" ]; then
CMAKE_ARGS+=("-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}")
fi
# Build the shared library
cd ../build
cmake "${CMAKE_ARGS[@]}" ../jni/
make
# Run the tests and create the .jar
cd ../java
mvn package || (echo "Build failed." && exit 1)
cp target/jrrd2-api-*.jar ../dist/
popd