-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjava_bundle.sh
executable file
·64 lines (55 loc) · 1.3 KB
/
java_bundle.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
#!/bin/sh
set -e
#set -x
if [ $# -lt 3 ]; then
cat >&2 <<EOF
Usage: $0 simgrid.jar java_command entry_point strip_command [-so file.so...] [-txt file.txt...]
simgrid.jar SimGrid jar file
java_command path to the Java runtime
entry_point entry point for java
strip_command path to the command used to strip libraries
file.so library file to stript and bundle into the archive
file.txt other file to bundle into the archive
EOF
exit 1
fi
SIMGRID_JAR=$1
JAVA=$2
ENTRY_POINT=$3
STRIP=$4
shift 4
echo "$JAVA" -classpath "$SIMGRID_JAR" $ENTRY_POINT $1 $2
JSG_BUNDLE=$("$JAVA" -classpath "$SIMGRID_JAR" $ENTRY_POINT)
# sanity check
case "$JSG_BUNDLE" in
NATIVE/*)
cat >&2 <<EOF
-- [Java] Native libraries bundled into: ${JSG_BUNDLE}
EOF
;;
*)
cat >&2 <<EOF
-- [Java] Native libraries NOT bundled into invalid directory: ${JSG_BUNDLE}
EOF
exit 1
;;
esac
# prepare directory
rm -fr NATIVE
mkdir -p "$JSG_BUNDLE"
if [ "$1" = "-so" ]; then
shift
for file; do
[ "$file" != "-txt" ] || break
cp -f "$file" "$JSG_BUNDLE"
"$STRIP" -S "$JSG_BUNDLE/${file##*/}"
shift
done
fi
if [ "$1" = "-txt" ]; then
shift
for file; do
cp -f "$file" "$JSG_BUNDLE"
shift
done
fi