src/Tools/Graphview/lib/Tools/graphview
author wenzelm
Mon, 24 Sep 2012 21:16:33 +0200
changeset 49558 af7b652180d5
child 49563 4b2762e12b47
permissions -rwxr-xr-x
minimal component and build setup for graphview;
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/dockable.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    12
  "src/floating_dialog.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    13
  "src/frame.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    14
  "src/graph_panel.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    15
  "src/graph_xml.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    16
  "src/layout_pendulum.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    17
  "src/main_panel.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    18
  "src/model.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    19
  "src/mutator_dialog.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    20
  "src/mutator_event.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    21
  "src/mutator.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    22
  "src/parameters.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    23
  "src/popups.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    24
  "src/shapes.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    25
  "src/tooltips.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    26
  "src/visualizer.scala"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    27
  "../jEdit/src/html_panel.scala"
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
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
## diagnostics
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    32
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    33
PRG="$(basename "$0")"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    34
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    35
function usage()
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    36
{
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    37
  echo
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    38
  echo "Usage: isabelle $PRG [OPTIONS] GRAPH_FILE"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    39
  echo
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    40
  echo "  Options are:"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    41
  echo "    -b           build only"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    42
  echo "    -f           fresh build"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    43
  echo
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    44
  exit 1
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    45
}
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
function fail()
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    48
{
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    49
  echo "$1" >&2
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    50
  exit 2
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
function failed()
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    54
{
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    55
  fail "Failed!"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    56
}
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    57
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    58
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    59
## process command line
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    60
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    61
# options
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    62
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    63
BUILD_ONLY=false
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    64
BUILD_JARS="jars"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    65
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    66
while getopts "bf" OPT
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    67
do
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    68
  case "$OPT" in
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    69
    b)
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    70
      BUILD_ONLY=true
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    71
      ;;
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    72
    f)
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    73
      BUILD_JARS="jars_fresh"
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
    \?)
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    76
      usage
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    77
      ;;
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    78
  esac
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    79
done
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    80
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    81
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    82
# args
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    83
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    84
GRAPH_FILE=""
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    85
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    86
if [ "$#" -eq 0 -a "$BUILD_ONLY" = false ]; then
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    87
  usage
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    88
elif [ "$#" -eq 1 ]; then
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    89
  GRAPH_FILE="$1"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    90
  shift
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    91
else
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    92
  usage
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    93
fi
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
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    96
## build
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    97
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    98
[ -e "$ISABELLE_HOME/Admin/build" ] && \
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
    99
  { "$ISABELLE_HOME/Admin/build" "$BUILD_JARS" || exit $?; }
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   100
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   101
pushd "$GRAPHVIEW_HOME" >/dev/null || failed
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   102
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   103
PURE_JAR="$ISABELLE_HOME/lib/classes/ext/Pure.jar"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   104
COBRA_JAR="$ISABELLE_JEDIT_BUILD_HOME/contrib/cobra.jar"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   105
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   106
TARGET_DIR="$ISABELLE_HOME/lib/classes"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   107
TARGET="$TARGET_DIR/ext/Graphview.jar"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   108
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   109
declare -a UPDATED=()
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   110
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   111
if [ "$BUILD_JARS" = jars_fresh ]; then
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   112
  OUTDATED=true
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
  OUTDATED=false
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   115
  if [ ! -e "$TARGET" ]; then
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   116
    OUTDATED=true
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   117
  else
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   118
    if [ -n "$ISABELLE_JEDIT_BUILD_HOME" ]; then
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   119
      declare -a DEPS=("$COBRA_JAR" "$PURE_JAR" "${SOURCES[@]}")
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   120
    elif [ -e "$ISABELLE_HOME/Admin/build" ]; then
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   121
      declare -a DEPS=("$PURE_JAR" "${SOURCES[@]}")
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   122
    else
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   123
      declare -a DEPS=()
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
    for DEP in "${DEPS[@]}"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   126
    do
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   127
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   128
      [ "$DEP" -nt "$TARGET" ] && {
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   129
        OUTDATED=true
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   130
        UPDATED["${#UPDATED[@]}"]="$DEP"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   131
      }
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   132
    done
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   133
  fi
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   134
fi
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   135
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   136
if [ "$OUTDATED" = true ]
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   137
then
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   138
  echo "### Building Isabelle/Graphview ..."
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   139
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   140
  [ "${#UPDATED[@]}" -gt 0 ] && {
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   141
    echo "Changed files:"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   142
    for FILE in "${UPDATED[@]}"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   143
    do
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   144
      echo "  $FILE"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   145
    done
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   146
  }
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   147
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   148
  [ -z "$ISABELLE_JEDIT_BUILD_HOME" ] && \
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   149
    fail "Unknown ISABELLE_JEDIT_BUILD_HOME -- missing auxiliary component"
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
  rm -rf classes && mkdir classes
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   152
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   153
  cp -p -R -f "$COBRA_JAR" "$TARGET_DIR/ext" || failed
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   154
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   155
  (
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   156
    for JAR in "$COBRA_JAR" "$PURE_JAR"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   157
    do
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   158
      CLASSPATH="$CLASSPATH:$JAR"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   159
    done
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   160
    CLASSPATH="$(jvmpath "$CLASSPATH")"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   161
    exec "$SCALA_HOME/bin/scalac" $ISABELLE_SCALA_BUILD_OPTIONS -d classes "${SOURCES[@]}"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   162
  ) || fail "Failed to compile sources"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   163
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   164
  cd classes
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   165
  isabelle_jdk jar cf "$TARGET" * || failed
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   166
  cd ..
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   167
  rm -rf classes
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   168
fi
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   169
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   170
popd >/dev/null
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   171
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   172
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   173
## run
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   174
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   175
[ "$BUILD_ONLY" = true ] || {
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   176
  exec "$ISABELLE_TOOL" java isabelle.graphview.Graphview_Frame "$(jvmpath "$GRAPH_FILE")"
af7b652180d5 minimal component and build setup for graphview;
wenzelm
parents:
diff changeset
   177
}