src/Tools/Graphview/lib/Tools/graphview
author wenzelm
Thu, 12 Sep 2013 14:06:08 +0200
changeset 53578 838d9e058a1a
parent 53577 d033bc00b762
child 56664 8ff8e5d00115
permissions -rwxr-xr-x
tuned comments;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
     2
#
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
     3
# Author: Markus Kaiser, TU Muenchen
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
     4
# Author: Makarius
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
     5
#
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
     6
# DESCRIPTION: graphview command-line tool wrapper
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
     7
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
     8
## sources
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
     9
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    10
declare -a SOURCES=(
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    11
  "src/graph_panel.scala"
49575
7529c77ee92e more uniform graphview terminology;
wenzelm
parents: 49569
diff changeset
    12
  "src/graphview.scala"
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    13
  "src/layout_pendulum.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    14
  "src/main_panel.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    15
  "src/model.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    16
  "src/mutator_dialog.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    17
  "src/mutator_event.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    18
  "src/mutator.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    19
  "src/popups.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    20
  "src/shapes.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    21
  "src/visualizer.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    22
)
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    23
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    24
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    25
## diagnostics
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    26
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    27
PRG="$(basename "$0")"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    28
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    29
function usage()
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    30
{
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    31
  echo
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    32
  echo "Usage: isabelle $PRG [OPTIONS] GRAPH_FILE"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    33
  echo
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    34
  echo "  Options are:"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    35
  echo "    -b           build only"
49563
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
    36
  echo "    -c           cleanup -- remove GRAPH_FILE after use"
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    37
  echo "    -f           fresh build"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    38
  echo
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    39
  exit 1
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    40
}
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    41
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    42
function fail()
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    43
{
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    44
  echo "$1" >&2
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    45
  exit 2
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    46
}
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    47
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    48
function failed()
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    49
{
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    50
  fail "Failed!"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    51
}
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    52
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    53
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    54
## process command line
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    55
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    56
# options
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    57
49565
ea4308b7ef0f ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents: 49563
diff changeset
    58
BUILD_ONLY="false"
ea4308b7ef0f ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents: 49563
diff changeset
    59
CLEAN="false"
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    60
BUILD_JARS="jars"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    61
49563
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
    62
while getopts "bcf" OPT
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    63
do
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    64
  case "$OPT" in
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    65
    b)
49565
ea4308b7ef0f ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents: 49563
diff changeset
    66
      BUILD_ONLY="true"
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    67
      ;;
49563
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
    68
    c)
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
    69
      CLEAN="true"
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
    70
      ;;
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    71
    f)
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    72
      BUILD_JARS="jars_fresh"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    73
      ;;
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    74
    \?)
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    75
      usage
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    76
      ;;
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    77
  esac
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    78
done
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    79
49563
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
    80
shift $(($OPTIND - 1))
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
    81
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    82
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    83
# args
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    84
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    85
GRAPH_FILE=""
49565
ea4308b7ef0f ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents: 49563
diff changeset
    86
[ "$#" -gt 0 ] && { GRAPH_FILE="$1"; shift; }
ea4308b7ef0f ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents: 49563
diff changeset
    87
[ "$#" -ne 0 ] && usage
ea4308b7ef0f ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents: 49563
diff changeset
    88
[ -z "$GRAPH_FILE" -a "$BUILD_ONLY" = false ] && usage
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    89
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    90
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    91
## build
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    92
52443
725916b7dee5 more formal isabelle_admin_build;
wenzelm
parents: 50475
diff changeset
    93
isabelle_admin_build "$BUILD_JARS" || exit $?
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    94
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    95
pushd "$GRAPHVIEW_HOME" >/dev/null || failed
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    96
53577
d033bc00b762 clarified directory structure;
wenzelm
parents: 53576
diff changeset
    97
PURE_JAR="$ISABELLE_HOME/lib/classes/Pure.jar"
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    98
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    99
TARGET_DIR="$ISABELLE_HOME/lib/classes"
53577
d033bc00b762 clarified directory structure;
wenzelm
parents: 53576
diff changeset
   100
TARGET="$TARGET_DIR/Graphview.jar"
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   101
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   102
declare -a UPDATED=()
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   103
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   104
if [ "$BUILD_JARS" = jars_fresh ]; then
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   105
  OUTDATED=true
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   106
else
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   107
  OUTDATED=false
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   108
  if [ ! -e "$TARGET" ]; then
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   109
    OUTDATED=true
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   110
  else
49569
7b6aaf446496 tuned pretty_locale/print_locale, with more basic pretty_locale_deps based on that;
wenzelm
parents: 49567
diff changeset
   111
    if [ -e "$ISABELLE_HOME/Admin/build" ]; then
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   112
      declare -a DEPS=("$PURE_JAR" "${SOURCES[@]}")
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   113
    else
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   114
      declare -a DEPS=()
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   115
    fi
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   116
    for DEP in "${DEPS[@]}"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   117
    do
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   118
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   119
      [ "$DEP" -nt "$TARGET" ] && {
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   120
        OUTDATED=true
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   121
        UPDATED["${#UPDATED[@]}"]="$DEP"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   122
      }
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   123
    done
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   124
  fi
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   125
fi
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   126
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   127
if [ "$OUTDATED" = true ]
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   128
then
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   129
  echo "### Building Isabelle/Graphview ..."
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   130
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   131
  [ "${#UPDATED[@]}" -gt 0 ] && {
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   132
    echo "Changed files:"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   133
    for FILE in "${UPDATED[@]}"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   134
    do
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   135
      echo "  $FILE"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   136
    done
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   137
  }
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   138
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   139
  rm -rf classes && mkdir classes
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   140
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   141
  (
53578
838d9e058a1a tuned comments;
wenzelm
parents: 53577
diff changeset
   142
    #workaround for scalac 2.10.2
53451
fb74a9cb699c odd workaround for scalac to enable nohup;
wenzelm
parents: 52443
diff changeset
   143
    function stty() { :; }
fb74a9cb699c odd workaround for scalac to enable nohup;
wenzelm
parents: 52443
diff changeset
   144
    export -f stty
fb74a9cb699c odd workaround for scalac to enable nohup;
wenzelm
parents: 52443
diff changeset
   145
53576
793a429c63e7 maintain classpath in more elementary manner: turn ISABELLE_CLASSPATH into -classpath option, so that all jars are covered by sun.misc.Launcher.AppClassLoader (e.g. relevant for loading add-on resources);
wenzelm
parents: 53451
diff changeset
   146
    classpath "$PURE_JAR"
793a429c63e7 maintain classpath in more elementary manner: turn ISABELLE_CLASSPATH into -classpath option, so that all jars are covered by sun.misc.Launcher.AppClassLoader (e.g. relevant for loading add-on resources);
wenzelm
parents: 53451
diff changeset
   147
    export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   148
    exec "$SCALA_HOME/bin/scalac" $ISABELLE_SCALA_BUILD_OPTIONS -d classes "${SOURCES[@]}"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   149
  ) || fail "Failed to compile sources"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   150
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   151
  cd classes
49567
136dd296ba24 proper jvmpath for Windows;
wenzelm
parents: 49565
diff changeset
   152
  isabelle_jdk jar cf "$(jvmpath "$TARGET")" * || failed
49558
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   153
  cd ..
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   154
  rm -rf classes
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   155
fi
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   156
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   157
popd >/dev/null
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   158
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   159
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   160
## run
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   161
49563
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   162
if [ "$BUILD_ONLY" = false ]; then
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   163
  PRIVATE_FILE="${ISABELLE_TMP:-/tmp}/$$""$(basename "$GRAPH_FILE")"
49565
ea4308b7ef0f ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents: 49563
diff changeset
   164
  if [ "$CLEAN" = "true" ]; then
49563
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   165
    mv -f "$GRAPH_FILE" "$PRIVATE_FILE" || fail "Cannot move file: $GRAPH_FILE"
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   166
  else
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   167
    cp -f "$GRAPH_FILE" "$PRIVATE_FILE" || fail "Cannot copy file: $GRAPH_FILE"
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   168
  fi
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   169
49575
7529c77ee92e more uniform graphview terminology;
wenzelm
parents: 49569
diff changeset
   170
  "$ISABELLE_TOOL" java $GRAPHVIEW_JAVA_OPTIONS isabelle.graphview.Graphview "$PRIVATE_FILE"
49563
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   171
  RC="$?"
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   172
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   173
  rm -f "$PRIVATE_FILE"
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   174
  echo "$RC"
4b2762e12b47 more complete build;
wenzelm
parents: 49558
diff changeset
   175
fi