1 #!/usr/bin/env bash |
|
2 # |
|
3 # Author: Makarius |
|
4 # |
|
5 # DESCRIPTION: build component for Isabelle/Java setup tool |
|
6 |
|
7 ## usage |
|
8 |
|
9 PRG=$(basename "$0") |
|
10 |
|
11 function usage() |
|
12 { |
|
13 echo |
|
14 echo "Usage: isabelle $PRG COMPONENT_DIR" |
|
15 echo |
|
16 echo " Build component for Isabelle/Java setup tool." |
|
17 echo |
|
18 exit 1 |
|
19 } |
|
20 |
|
21 function fail() |
|
22 { |
|
23 echo "$1" >&2 |
|
24 exit 2 |
|
25 } |
|
26 |
|
27 |
|
28 ## process command line |
|
29 |
|
30 [ "$#" -ge 1 ] && { COMPONENT_DIR="$1"; shift; } |
|
31 [ "$#" -ne 0 -o -z "$COMPONENT_DIR" ] && usage |
|
32 |
|
33 |
|
34 |
|
35 ## main |
|
36 |
|
37 [ -d "$COMPONENT_DIR" ] && fail "Directory already exists: \"$COMPONENT_DIR\"" |
|
38 |
|
39 |
|
40 # etc/settings |
|
41 |
|
42 mkdir -p "$COMPONENT_DIR/etc" |
|
43 cat > "$COMPONENT_DIR/etc/settings" <<EOF |
|
44 # -*- shell-script -*- :mode=shellscript: |
|
45 |
|
46 ISABELLE_SETUP_JAR="\$COMPONENT/lib/isabelle_setup.jar" |
|
47 classpath "\$ISABELLE_SETUP_JAR" |
|
48 EOF |
|
49 |
|
50 |
|
51 # build jar |
|
52 |
|
53 TARGET_DIR="$COMPONENT_DIR/lib" |
|
54 mkdir -p "$TARGET_DIR/isabelle/setup" |
|
55 |
|
56 declare -a ARGS=("-Xlint:unchecked") |
|
57 |
|
58 SOURCES="$(perl -e 'while (<>) { if (m/(\S+\.java)/) { print "$1 "; } }' "$ISABELLE_HOME/src/Tools/Setup/etc/build.props")" |
|
59 for SRC in $SOURCES |
|
60 do |
|
61 ARGS["${#ARGS[@]}"]="$(platform_path "$ISABELLE_HOME/src/Tools/Setup/$SRC")" |
|
62 done |
|
63 |
|
64 isabelle_jdk javac $ISABELLE_JAVAC_OPTIONS -d "$TARGET_DIR" \ |
|
65 -classpath "$(platform_path "$ISABELLE_CLASSPATH")" "${ARGS[@]}" || \ |
|
66 fail "Failed to compile sources" |
|
67 |
|
68 isabelle_jdk jar -c -f "$(platform_path "$TARGET_DIR/isabelle_setup.jar")" \ |
|
69 -e "isabelle.setup.Setup" -C "$TARGET_DIR" isabelle || fail "Failed to produce jar" |
|
70 |
|
71 rm -rf "$TARGET_DIR/isabelle" |
|
72 |
|
73 |
|
74 # README |
|
75 |
|
76 cat > "$COMPONENT_DIR/README" <<EOF |
|
77 Isabelle setup in pure Java, see also \$ISABELLE_HOME/src/Tools/Setup/. |
|
78 EOF |
|