author | wenzelm |
Sat, 17 Jul 2021 21:31:15 +0200 | |
changeset 74030 | 39e05601faeb |
parent 73963 | 59b6f0462086 |
child 74031 | 09821ca262d3 |
permissions | -rwxr-xr-x |
73906 | 1 |
#!/usr/bin/env bash |
2 |
# |
|
3 |
# Author: Makarius |
|
4 |
# |
|
5 |
# DESCRIPTION: build component for Isabelle/Java setup tool |
|
6 |
||
7 |
## sources |
|
8 |
||
9 |
declare -a SOURCES=( |
|
73944 | 10 |
"Build.java" |
73906 | 11 |
"Environment.java" |
73963 | 12 |
"Exn.java" |
13 |
"Library.java" |
|
73906 | 14 |
"Setup.java" |
15 |
) |
|
16 |
||
17 |
||
18 |
## usage |
|
19 |
||
20 |
PRG=$(basename "$0") |
|
21 |
||
22 |
function usage() |
|
23 |
{ |
|
24 |
echo |
|
25 |
echo "Usage: isabelle $PRG [OPTIONS] COMPONENT_DIR" |
|
26 |
echo |
|
27 |
echo " Build component for Isabelle/Java setup tool." |
|
28 |
echo |
|
29 |
exit 1 |
|
30 |
} |
|
31 |
||
32 |
function fail() |
|
33 |
{ |
|
34 |
echo "$1" >&2 |
|
35 |
exit 2 |
|
36 |
} |
|
37 |
||
38 |
||
39 |
## process command line |
|
40 |
||
41 |
[ "$#" -ge 1 ] && { COMPONENT_DIR="$1"; shift; } |
|
42 |
[ "$#" -ne 0 -o -z "$COMPONENT_DIR" ] && usage |
|
43 |
||
44 |
||
45 |
||
46 |
## main |
|
47 |
||
48 |
[ -d "$COMPONENT_DIR" ] && fail "Directory already exists: \"$COMPONENT_DIR\"" |
|
49 |
||
50 |
||
74030
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
51 |
# etc/settings |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
52 |
|
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
53 |
mkdir -p "$COMPONENT_DIR/etc" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
54 |
cat > "$COMPONENT_DIR/etc/settings" <<EOF |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
55 |
# -*- shell-script -*- :mode=shellscript: |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
56 |
|
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
57 |
ISABELLE_SETUP_JAR="\$COMPONENT/lib/isabelle_setup.jar" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
58 |
classpath "\$ISABELLE_SETUP_JAR" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
59 |
EOF |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
60 |
|
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
61 |
BUILD_PROPS="$COMPONENT_DIR/etc/build.props" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
62 |
echo >> "$BUILD_PROPS" "no_module = lib/isabelle_setup.jar" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
63 |
|
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
64 |
|
73906 | 65 |
# build jar |
66 |
||
74030
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
67 |
SOURCE_DIR="$COMPONENT_DIR/src" |
73906 | 68 |
TARGET_DIR="$COMPONENT_DIR/lib" |
74030
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
69 |
mkdir -p "$SOURCE_DIR" "$TARGET_DIR/isabelle/setup" |
73906 | 70 |
|
71 |
declare -a ARGS=("-Xlint:unchecked") |
|
74030
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
72 |
echo -n >> "$BUILD_PROPS" "sources =" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
73 |
|
73906 | 74 |
for SRC in "${SOURCES[@]}" |
75 |
do |
|
73912 | 76 |
ARGS["${#ARGS[@]}"]="$(platform_path "$ISABELLE_HOME/src/Tools/Setup/isabelle/setup/$SRC")" |
74030
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
77 |
cp "$ISABELLE_HOME/src/Tools/Setup/isabelle/setup/$SRC" "$SOURCE_DIR" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
78 |
echo >> "$BUILD_PROPS" " \\" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
79 |
echo -n >> "$BUILD_PROPS" " src/$SRC" |
73906 | 80 |
done |
81 |
||
74030
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
82 |
echo >> "$BUILD_PROPS" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
83 |
|
73953 | 84 |
isabelle_jdk javac $ISABELLE_JAVAC_OPTIONS -d "$TARGET_DIR" \ |
85 |
-classpath "$(platform_path "$ISABELLE_CLASSPATH")" "${ARGS[@]}" || \ |
|
73906 | 86 |
fail "Failed to compile sources" |
87 |
||
88 |
isabelle_jdk jar -c -f "$(platform_path "$TARGET_DIR/isabelle_setup.jar")" \ |
|
89 |
-e "isabelle.setup.Setup" -C "$TARGET_DIR" isabelle || fail "Failed to produce jar" |
|
90 |
||
91 |
rm -rf "$TARGET_DIR/isabelle" |
|
92 |
||
93 |
||
94 |
# README |
|
95 |
||
96 |
cat > "$COMPONENT_DIR/README" <<EOF |
|
97 |
Isabelle setup in pure Java, see also \$ISABELLE_HOME/src/Tools/Setup/. |
|
98 |
EOF |