author | wenzelm |
Fri, 26 Apr 2024 13:25:44 +0200 | |
changeset 80150 | 96f60533ec1d |
parent 77566 | 2a99fcb283ee |
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 |
## usage |
|
8 |
||
9 |
PRG=$(basename "$0") |
|
10 |
||
11 |
function usage() |
|
12 |
{ |
|
13 |
echo |
|
75308 | 14 |
echo "Usage: isabelle $PRG COMPONENT_DIR" |
73906 | 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 |
||
74030
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
40 |
# etc/settings |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
41 |
|
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
42 |
mkdir -p "$COMPONENT_DIR/etc" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
43 |
cat > "$COMPONENT_DIR/etc/settings" <<EOF |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
44 |
# -*- shell-script -*- :mode=shellscript: |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
45 |
|
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
46 |
ISABELLE_SETUP_JAR="\$COMPONENT/lib/isabelle_setup.jar" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
47 |
classpath "\$ISABELLE_SETUP_JAR" |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
48 |
EOF |
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
49 |
|
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
50 |
|
73906 | 51 |
# build jar |
52 |
||
53 |
TARGET_DIR="$COMPONENT_DIR/lib" |
|
74039
8c213672f6f3
clarified component setup: exclude jar from active component, but use sources from template within ISABELLE_HOME (relevant for "isabelle scala_project -L");
wenzelm
parents:
74031
diff
changeset
|
54 |
mkdir -p "$TARGET_DIR/isabelle/setup" |
73906 | 55 |
|
56 |
declare -a ARGS=("-Xlint:unchecked") |
|
74030
39e05601faeb
more accurate scala_project, based on build.props of components;
wenzelm
parents:
73963
diff
changeset
|
57 |
|
74039
8c213672f6f3
clarified component setup: exclude jar from active component, but use sources from template within ISABELLE_HOME (relevant for "isabelle scala_project -L");
wenzelm
parents:
74031
diff
changeset
|
58 |
SOURCES="$(perl -e 'while (<>) { if (m/(\S+\.java)/) { print "$1 "; } }' "$ISABELLE_HOME/src/Tools/Setup/etc/build.props")" |
8c213672f6f3
clarified component setup: exclude jar from active component, but use sources from template within ISABELLE_HOME (relevant for "isabelle scala_project -L");
wenzelm
parents:
74031
diff
changeset
|
59 |
for SRC in $SOURCES |
73906 | 60 |
do |
74039
8c213672f6f3
clarified component setup: exclude jar from active component, but use sources from template within ISABELLE_HOME (relevant for "isabelle scala_project -L");
wenzelm
parents:
74031
diff
changeset
|
61 |
ARGS["${#ARGS[@]}"]="$(platform_path "$ISABELLE_HOME/src/Tools/Setup/$SRC")" |
73906 | 62 |
done |
63 |
||
73953 | 64 |
isabelle_jdk javac $ISABELLE_JAVAC_OPTIONS -d "$TARGET_DIR" \ |
65 |
-classpath "$(platform_path "$ISABELLE_CLASSPATH")" "${ARGS[@]}" || \ |
|
73906 | 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 |