-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·68 lines (56 loc) · 1.48 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Check for compile flag.
if [[ "$1" != "--debug" ]]; then
if [[ "$1" != "--release" ]]; then
echo "Usage: ./build.sh (--release | --debug)"
exit 1
fi
fi
# Verify that the javac command is in path
if ! [ -x "$(command -v javac)" ]; then
echo "Error: Command 'javac' not in path." >&2
exit 2
fi
# Verify that the jar command is in path
if ! [ -x "$(command -v jar)" ]; then
echo "Error: Command 'jar' not in path." >&2
exit 2
fi
# Create Temporary Directory
mkdir tmp
# Compile jtwod Files
echo "Compiling jtwod classes..."
cp -R src/* tmp/
cd tmp/
find . -name "*.java" > sources.txt
javac -cp ../lib/tinysound-1.1.1.jar @sources.txt
rm sources.txt
file="lib-jtwod-static.jar"
if [[ "$1" == "--debug" ]];
then
echo "Packaging source (debug)..."
file="lib-jtwod-static-debug.jar"
else
echo "Removing source (release)..."
find . -name '*.java' -delete
fi
# Extract TinySound library and License
echo "Migrating TinySound..."
jar -xf ../lib/tinysound-1.1.1.jar
cp ../lib/TINYSOUND_LICENSE ./
cd ..
# Compile final Jar
echo "Compiling final jar..."
jar -cvf $file -C tmp . >/dev/null
# Clean up
echo "Cleaning up..."
rm -rf tmp
# Documentation
if ! [ -x "$(command -v javadoc)" ]; then
echo "Could not generate javadocs, Error: command 'javadoc' not in path."
else
echo "Generating JavaDocs... (./docs)"
javadoc -sourcepath ./src/ -d ./docs -subpackages jtwod -exclude jtwod.examples >/dev/null 2>&1
fi
echo "Done."
echo "Output: $file"