src/Pure/build-jars
author wenzelm
Wed, 08 Jun 2011 17:11:00 +0200
changeset 43280 e5dd0ae1b054
parent 42899 108e815fdc8e
child 43285 966f359dc724
permissions -rwxr-xr-x
support fresh build of jars; prefer pushd/popd, to avoid unclarity about fail/exit within sub-shell;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
     2
#
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
     3
# Author: Makarius
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
     4
#
42899
108e815fdc8e misc tuning and update;
wenzelm
parents: 42720
diff changeset
     5
# build-jars - build Isabelle/Scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
     6
#
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
     7
# Requires proper Isabelle settings environment.
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
     8
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
     9
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    10
## diagnostics
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    11
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    12
PRG="$(basename "$0")"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    13
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    14
function usage()
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    15
{
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    16
  echo
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    17
  echo "Usage: isabelle $PRG [OPTIONS]"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    18
  echo
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    19
  echo "  Options are:"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    20
  echo "    -f           fresh build"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    21
  echo
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    22
  exit 1
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    23
}
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    24
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    25
function fail()
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    26
{
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    27
  echo "$1" >&2
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    28
  exit 2
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    29
}
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    30
42899
108e815fdc8e misc tuning and update;
wenzelm
parents: 42720
diff changeset
    31
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
37174
6feaab4fc27d assume given SCALA_HOME, e.g. from component settings or external setup;
wenzelm
parents: 37044
diff changeset
    32
[ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    33
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    34
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    35
## process command line
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    36
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    37
# options
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    38
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    39
FRESH=""
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    40
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    41
while getopts "f" OPT
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    42
do
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    43
  case "$OPT" in
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    44
    f)
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    45
      FRESH=true
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    46
      ;;
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    47
    \?)
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    48
      usage
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    49
      ;;
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    50
  esac
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    51
done
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    52
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    53
shift $(($OPTIND - 1))
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    54
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    55
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    56
# args
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    57
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    58
[ "$#" -ne 0 ] && usage
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    59
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    60
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    61
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    62
## dependencies
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    63
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    64
declare -a SOURCES=(
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    65
  Concurrent/future.scala
38636
b7647ca7de5a module for simplified thread operations (Scala version);
wenzelm
parents: 38567
diff changeset
    66
  Concurrent/simple_thread.scala
38840
ec75dc58688b volatile variables (in Scala);
wenzelm
parents: 38636
diff changeset
    67
  Concurrent/volatile.scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    68
  General/exn.scala
40393
2bb7ec08574a somewhat more uniform timing in ML vs. Scala;
wenzelm
parents: 38840
diff changeset
    69
  General/timing.scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    70
  General/linear_set.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    71
  General/markup.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    72
  General/position.scala
36683
41a1210519fd basic support for symbolic pretty printing;
wenzelm
parents: 36676
diff changeset
    73
  General/pretty.scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    74
  General/scan.scala
38473
bd96f2a5beb0 digesting strings according to SHA-1 -- Scala version;
wenzelm
parents: 38429
diff changeset
    75
  General/sha1.scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    76
  General/symbol.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    77
  General/xml.scala
38267
e50c283dd125 type XML.Body as basic data representation language (Scala version);
wenzelm
parents: 38227
diff changeset
    78
  General/xml_data.scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    79
  General/yxml.scala
36947
285b39022372 renamed Outer_Keyword to Keyword (in Scala);
wenzelm
parents: 36683
diff changeset
    80
  Isar/keyword.scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    81
  Isar/outer_syntax.scala
36948
d2cdad45fd14 renamed Outer_Parse to Parse (in Scala);
wenzelm
parents: 36947
diff changeset
    82
  Isar/parse.scala
36956
21be4832c362 renamed class Outer_Lex to Token and Token_Kind to Token.Kind;
wenzelm
parents: 36948
diff changeset
    83
  Isar/token.scala
36676
ac7961d42ac3 some rearrangement of Scala sources;
wenzelm
parents: 36011
diff changeset
    84
  PIDE/command.scala
ac7961d42ac3 some rearrangement of Scala sources;
wenzelm
parents: 36011
diff changeset
    85
  PIDE/document.scala
38483
3d16bebee1d3 moved Isar_Document to Pure/PIDE;
wenzelm
parents: 38479
diff changeset
    86
  PIDE/isar_document.scala
38479
e628da370072 more efficient Markup_Tree, based on branches sorted by quasi-order;
wenzelm
parents: 38473
diff changeset
    87
  PIDE/markup_tree.scala
38425
e467db701d78 moved Text_Edit to Text.Edit;
wenzelm
parents: 38412
diff changeset
    88
  PIDE/text.scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    89
  System/cygwin.scala
36676
ac7961d42ac3 some rearrangement of Scala sources;
wenzelm
parents: 36011
diff changeset
    90
  System/download.scala
38428
c13c95c97e89 event_bus.scala rather belongs to system plumbing;
wenzelm
parents: 38425
diff changeset
    91
  System/event_bus.scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    92
  System/gui_setup.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    93
  System/isabelle_process.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    94
  System/isabelle_syntax.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    95
  System/isabelle_system.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    96
  System/platform.scala
34871
e596a0b71f3c incorporate "proofdocument" part into main Isabelle/Pure.jar -- except for html_panel.scala, which depends on external library (Lobo/Cobra browser);
wenzelm
parents: 34284
diff changeset
    97
  System/session.scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    98
  System/session_manager.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    99
  System/standard_system.scala
36676
ac7961d42ac3 some rearrangement of Scala sources;
wenzelm
parents: 36011
diff changeset
   100
  System/swing_thread.scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   101
  Thy/completion.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   102
  Thy/html.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   103
  Thy/thy_header.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   104
  Thy/thy_syntax.scala
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   105
  library.scala
42720
caa4f1279154 added toplevel isabelle package -- reduce warnings with scala-2.9.0.final;
wenzelm
parents: 40393
diff changeset
   106
  package.scala
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   107
)
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   108
34284
33ad3571ad83 tuned Isabelle/Scala build;
wenzelm
parents: 34282
diff changeset
   109
TARGET_DIR="$ISABELLE_HOME/lib/classes"
33ad3571ad83 tuned Isabelle/Scala build;
wenzelm
parents: 34282
diff changeset
   110
PURE_JAR="$TARGET_DIR/Pure.jar"
33ad3571ad83 tuned Isabelle/Scala build;
wenzelm
parents: 34282
diff changeset
   111
FULL_JAR="$TARGET_DIR/isabelle-scala.jar"
33ad3571ad83 tuned Isabelle/Scala build;
wenzelm
parents: 34282
diff changeset
   112
33ad3571ad83 tuned Isabelle/Scala build;
wenzelm
parents: 34282
diff changeset
   113
declare -a TARGETS=("$PURE_JAR" "$FULL_JAR")
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   114
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   115
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   116
## main
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   117
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   118
if [ -n "$FRESH" ]; then
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   119
  OUTDATED=true
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   120
else
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   121
  OUTDATED=false
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   122
  for SOURCE in "${SOURCES[@]}"
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   123
  do
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   124
    [ ! -e "$SOURCE" ] && fail "Missing source file: $SOURCE"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   125
    for TARGET in "${TARGETS[@]}"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   126
    do
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   127
      [ ! -e "$TARGET" -o "$SOURCE" -nt "$TARGET" ] && OUTDATED=true
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   128
    done
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   129
  done
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   130
fi
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   131
34284
33ad3571ad83 tuned Isabelle/Scala build;
wenzelm
parents: 34282
diff changeset
   132
if [ "$OUTDATED" = true ]
33ad3571ad83 tuned Isabelle/Scala build;
wenzelm
parents: 34282
diff changeset
   133
then
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   134
  echo "###"
34876
b52e03f68cc3 clarified terminology;
wenzelm
parents: 34871
diff changeset
   135
  echo "### Building Isabelle/Scala layer ..."
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   136
  echo "###"
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   137
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   138
  rm -rf classes && mkdir classes
36011
3ff725ac13a4 adapted to Scala 2.8.0 Beta1 -- with notable changes to scala.collection;
wenzelm
parents: 34876
diff changeset
   139
  "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   140
    fail "Failed to compile sources"
34284
33ad3571ad83 tuned Isabelle/Scala build;
wenzelm
parents: 34282
diff changeset
   141
  mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   142
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   143
  pushd classes
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   144
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   145
  jar cfe "$(jvmpath "$PURE_JAR")" isabelle.GUI_Setup isabelle || \
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   146
    fail "Failed to produce $PURE_JAR"
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   147
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   148
  cp "$SCALA_HOME/lib/scala-swing.jar" .
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   149
  jar xf scala-swing.jar
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   150
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   151
  cp "$SCALA_HOME/lib/scala-library.jar" "$FULL_JAR"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   152
  jar ufe "$(jvmpath "$FULL_JAR")" isabelle.GUI_Setup isabelle scala || \
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   153
    fail "Failed to produce $FULL_JAR"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   154
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   155
  popd >/dev/null
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   156
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   157
  rm -rf classes
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   158
fi