support fresh build of jars;
prefer pushd/popd, to avoid unclarity about fail/exit within sub-shell;
--- a/Admin/build Wed Jun 08 16:19:22 2011 +0200
+++ b/Admin/build Wed Jun 08 17:11:00 2011 +0200
@@ -27,6 +27,7 @@
browser graph browser (requires jdk)
doc documentation (requires latex and rail)
jars Isabelle/Scala layer (requires Scala in \$SCALA_HOME)
+ jars_fresh fresh build of jars
EOF
exit 1
@@ -84,7 +85,7 @@
function build_jars ()
{
pushd "$ISABELLE_HOME/src/Pure" >/dev/null
- "$ISABELLE_TOOL" env ./build-jars || exit $?
+ "$ISABELLE_TOOL" env ./build-jars "$@" || exit $?
popd >/dev/null
}
@@ -98,6 +99,7 @@
browser) build_browser;;
doc) build_doc;;
jars) build_jars;;
+ jars_fresh) build_jars -f;;
*) fail "Bad module $MODULE"
esac
done
--- a/src/Pure/build-jars Wed Jun 08 16:19:22 2011 +0200
+++ b/src/Pure/build-jars Wed Jun 08 17:11:00 2011 +0200
@@ -9,6 +9,19 @@
## diagnostics
+PRG="$(basename "$0")"
+
+function usage()
+{
+ echo
+ echo "Usage: isabelle $PRG [OPTIONS]"
+ echo
+ echo " Options are:"
+ echo " -f fresh build"
+ echo
+ exit 1
+}
+
function fail()
{
echo "$1" >&2
@@ -19,6 +32,33 @@
[ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
+## process command line
+
+# options
+
+FRESH=""
+
+while getopts "f" OPT
+do
+ case "$OPT" in
+ f)
+ FRESH=true
+ ;;
+ \?)
+ usage
+ ;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+
+# args
+
+[ "$#" -ne 0 ] && usage
+
+
+
## dependencies
declare -a SOURCES=(
@@ -75,16 +115,19 @@
## main
-OUTDATED=false
-
-for SOURCE in "${SOURCES[@]}"
-do
- [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
- for TARGET in "${TARGETS[@]}"
+if [ -n "$FRESH" ]; then
+ OUTDATED=true
+else
+ OUTDATED=false
+ for SOURCE in "${SOURCES[@]}"
do
- [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
+ [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
+ for TARGET in "${TARGETS[@]}"
+ do
+ [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
+ done
done
-done
+fi
if [ "$OUTDATED" = true ]
then
@@ -96,17 +139,20 @@
"$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
fail "Failed to compile sources"
mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
- (
- cd classes
- jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
- fail "Failed to produce $PURE_JAR"
+
+ pushd classes
+
+ jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
+ fail "Failed to produce $PURE_JAR"
- cp "$SCALA_HOME/lib/scala-swing.jar" .
- jar xf scala-swing.jar
+ cp "$SCALA_HOME/lib/scala-swing.jar" .
+ jar xf scala-swing.jar
- cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
- jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
- fail "Failed to produce $FULL_JAR"
- )
+ cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
+ jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
+ fail "Failed to produce $FULL_JAR"
+
+ popd >/dev/null
+
rm -rf classes
fi