src/Tools/Graphview/lib/Tools/graphview
changeset 57032 cf570f3ecdc1
parent 57031 30ee1453a954
child 57033 b24e2b83917f
     1.1 --- a/src/Tools/Graphview/lib/Tools/graphview	Wed May 21 10:13:12 2014 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,175 +0,0 @@
     1.4 -#!/usr/bin/env bash
     1.5 -#
     1.6 -# Author: Markus Kaiser, TU Muenchen
     1.7 -# Author: Makarius
     1.8 -#
     1.9 -# DESCRIPTION: graphview command-line tool wrapper
    1.10 -
    1.11 -## sources
    1.12 -
    1.13 -declare -a SOURCES=(
    1.14 -  "src/graph_panel.scala"
    1.15 -  "src/graphview.scala"
    1.16 -  "src/layout_pendulum.scala"
    1.17 -  "src/main_panel.scala"
    1.18 -  "src/model.scala"
    1.19 -  "src/mutator_dialog.scala"
    1.20 -  "src/mutator_event.scala"
    1.21 -  "src/mutator.scala"
    1.22 -  "src/popups.scala"
    1.23 -  "src/shapes.scala"
    1.24 -  "src/visualizer.scala"
    1.25 -)
    1.26 -
    1.27 -
    1.28 -## diagnostics
    1.29 -
    1.30 -PRG="$(basename "$0")"
    1.31 -
    1.32 -function usage()
    1.33 -{
    1.34 -  echo
    1.35 -  echo "Usage: isabelle $PRG [OPTIONS] GRAPH_FILE"
    1.36 -  echo
    1.37 -  echo "  Options are:"
    1.38 -  echo "    -b           build only"
    1.39 -  echo "    -c           cleanup -- remove GRAPH_FILE after use"
    1.40 -  echo "    -f           fresh build"
    1.41 -  echo
    1.42 -  exit 1
    1.43 -}
    1.44 -
    1.45 -function fail()
    1.46 -{
    1.47 -  echo "$1" >&2
    1.48 -  exit 2
    1.49 -}
    1.50 -
    1.51 -function failed()
    1.52 -{
    1.53 -  fail "Failed!"
    1.54 -}
    1.55 -
    1.56 -
    1.57 -## process command line
    1.58 -
    1.59 -# options
    1.60 -
    1.61 -BUILD_ONLY="false"
    1.62 -CLEAN="false"
    1.63 -BUILD_JARS="jars"
    1.64 -
    1.65 -while getopts "bcf" OPT
    1.66 -do
    1.67 -  case "$OPT" in
    1.68 -    b)
    1.69 -      BUILD_ONLY="true"
    1.70 -      ;;
    1.71 -    c)
    1.72 -      CLEAN="true"
    1.73 -      ;;
    1.74 -    f)
    1.75 -      BUILD_JARS="jars_fresh"
    1.76 -      ;;
    1.77 -    \?)
    1.78 -      usage
    1.79 -      ;;
    1.80 -  esac
    1.81 -done
    1.82 -
    1.83 -shift $(($OPTIND - 1))
    1.84 -
    1.85 -
    1.86 -# args
    1.87 -
    1.88 -GRAPH_FILE=""
    1.89 -[ "$#" -gt 0 ] && { GRAPH_FILE="$1"; shift; }
    1.90 -[ "$#" -ne 0 ] && usage
    1.91 -[ -z "$GRAPH_FILE" -a "$BUILD_ONLY" = false ] && usage
    1.92 -
    1.93 -
    1.94 -## build
    1.95 -
    1.96 -isabelle_admin_build "$BUILD_JARS" || exit $?
    1.97 -
    1.98 -pushd "$GRAPHVIEW_HOME" >/dev/null || failed
    1.99 -
   1.100 -PURE_JAR="$ISABELLE_HOME/lib/classes/Pure.jar"
   1.101 -
   1.102 -TARGET_DIR="$ISABELLE_HOME/lib/classes"
   1.103 -TARGET="$TARGET_DIR/Graphview.jar"
   1.104 -
   1.105 -declare -a UPDATED=()
   1.106 -
   1.107 -if [ "$BUILD_JARS" = jars_fresh ]; then
   1.108 -  OUTDATED=true
   1.109 -else
   1.110 -  OUTDATED=false
   1.111 -  if [ ! -e "$TARGET" ]; then
   1.112 -    OUTDATED=true
   1.113 -  else
   1.114 -    if [ -e "$ISABELLE_HOME/Admin/build" ]; then
   1.115 -      declare -a DEPS=("$PURE_JAR" "${SOURCES[@]}")
   1.116 -    else
   1.117 -      declare -a DEPS=()
   1.118 -    fi
   1.119 -    for DEP in "${DEPS[@]}"
   1.120 -    do
   1.121 -      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   1.122 -      [ "$DEP" -nt "$TARGET" ] && {
   1.123 -        OUTDATED=true
   1.124 -        UPDATED["${#UPDATED[@]}"]="$DEP"
   1.125 -      }
   1.126 -    done
   1.127 -  fi
   1.128 -fi
   1.129 -
   1.130 -if [ "$OUTDATED" = true ]
   1.131 -then
   1.132 -  echo "### Building Isabelle/Graphview ..."
   1.133 -
   1.134 -  [ "${#UPDATED[@]}" -gt 0 ] && {
   1.135 -    echo "Changed files:"
   1.136 -    for FILE in "${UPDATED[@]}"
   1.137 -    do
   1.138 -      echo "  $FILE"
   1.139 -    done
   1.140 -  }
   1.141 -
   1.142 -  rm -rf classes && mkdir classes
   1.143 -
   1.144 -  (
   1.145 -    #FIXME workaround for scalac 2.11.0
   1.146 -    function stty() { :; }
   1.147 -    export -f stty
   1.148 -
   1.149 -    classpath "$PURE_JAR"
   1.150 -    export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
   1.151 -    exec "$SCALA_HOME/bin/scalac" $ISABELLE_SCALA_BUILD_OPTIONS -d classes "${SOURCES[@]}"
   1.152 -  ) || fail "Failed to compile sources"
   1.153 -
   1.154 -  cd classes
   1.155 -  isabelle_jdk jar cf "$(jvmpath "$TARGET")" * || failed
   1.156 -  cd ..
   1.157 -  rm -rf classes
   1.158 -fi
   1.159 -
   1.160 -popd >/dev/null
   1.161 -
   1.162 -
   1.163 -## run
   1.164 -
   1.165 -if [ "$BUILD_ONLY" = false ]; then
   1.166 -  PRIVATE_FILE="${ISABELLE_TMP:-/tmp}/$$""$(basename "$GRAPH_FILE")"
   1.167 -  if [ "$CLEAN" = "true" ]; then
   1.168 -    mv -f "$GRAPH_FILE" "$PRIVATE_FILE" || fail "Cannot move file: $GRAPH_FILE"
   1.169 -  else
   1.170 -    cp -f "$GRAPH_FILE" "$PRIVATE_FILE" || fail "Cannot copy file: $GRAPH_FILE"
   1.171 -  fi
   1.172 -
   1.173 -  "$ISABELLE_TOOL" java $GRAPHVIEW_JAVA_OPTIONS isabelle.graphview.Graphview "$PRIVATE_FILE"
   1.174 -  RC="$?"
   1.175 -
   1.176 -  rm -f "$PRIVATE_FILE"
   1.177 -  echo "$RC"
   1.178 -fi