src/Pure/build-jars
author wenzelm
Mon, 04 Jul 2011 16:27:11 +0200
changeset 43651 511df47bcadc
parent 43600 4ac04bf9ff89
child 43660 bfc0bb115fa1
permissions -rwxr-xr-x
some support for theory files within Isabelle/Scala session;
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
43320
wenzelm
parents: 43285
diff changeset
     9
## sources
wenzelm
parents: 43285
diff changeset
    10
wenzelm
parents: 43285
diff changeset
    11
declare -a SOURCES=(
wenzelm
parents: 43285
diff changeset
    12
  Concurrent/future.scala
wenzelm
parents: 43285
diff changeset
    13
  Concurrent/simple_thread.scala
wenzelm
parents: 43285
diff changeset
    14
  Concurrent/volatile.scala
wenzelm
parents: 43285
diff changeset
    15
  General/exn.scala
wenzelm
parents: 43285
diff changeset
    16
  General/timing.scala
wenzelm
parents: 43285
diff changeset
    17
  General/linear_set.scala
wenzelm
parents: 43285
diff changeset
    18
  General/markup.scala
43600
4ac04bf9ff89 abstract algebra of file paths in Scala (cf. path.ML);
wenzelm
parents: 43523
diff changeset
    19
  General/path.scala
43320
wenzelm
parents: 43285
diff changeset
    20
  General/position.scala
wenzelm
parents: 43285
diff changeset
    21
  General/pretty.scala
wenzelm
parents: 43285
diff changeset
    22
  General/scan.scala
wenzelm
parents: 43285
diff changeset
    23
  General/sha1.scala
wenzelm
parents: 43285
diff changeset
    24
  General/symbol.scala
wenzelm
parents: 43285
diff changeset
    25
  General/xml.scala
wenzelm
parents: 43285
diff changeset
    26
  General/xml_data.scala
wenzelm
parents: 43285
diff changeset
    27
  General/yxml.scala
wenzelm
parents: 43285
diff changeset
    28
  Isar/keyword.scala
wenzelm
parents: 43285
diff changeset
    29
  Isar/outer_syntax.scala
wenzelm
parents: 43285
diff changeset
    30
  Isar/parse.scala
wenzelm
parents: 43285
diff changeset
    31
  Isar/token.scala
wenzelm
parents: 43285
diff changeset
    32
  PIDE/command.scala
wenzelm
parents: 43285
diff changeset
    33
  PIDE/document.scala
wenzelm
parents: 43285
diff changeset
    34
  PIDE/isar_document.scala
wenzelm
parents: 43285
diff changeset
    35
  PIDE/markup_tree.scala
wenzelm
parents: 43285
diff changeset
    36
  PIDE/text.scala
wenzelm
parents: 43285
diff changeset
    37
  System/cygwin.scala
wenzelm
parents: 43285
diff changeset
    38
  System/download.scala
wenzelm
parents: 43285
diff changeset
    39
  System/event_bus.scala
wenzelm
parents: 43285
diff changeset
    40
  System/gui_setup.scala
43517
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents: 43405
diff changeset
    41
  System/isabelle_charset.scala
43320
wenzelm
parents: 43285
diff changeset
    42
  System/isabelle_process.scala
wenzelm
parents: 43285
diff changeset
    43
  System/isabelle_syntax.scala
wenzelm
parents: 43285
diff changeset
    44
  System/isabelle_system.scala
wenzelm
parents: 43285
diff changeset
    45
  System/platform.scala
wenzelm
parents: 43285
diff changeset
    46
  System/session.scala
wenzelm
parents: 43285
diff changeset
    47
  System/session_manager.scala
wenzelm
parents: 43285
diff changeset
    48
  System/standard_system.scala
wenzelm
parents: 43285
diff changeset
    49
  System/swing_thread.scala
wenzelm
parents: 43285
diff changeset
    50
  Thy/completion.scala
wenzelm
parents: 43285
diff changeset
    51
  Thy/html.scala
wenzelm
parents: 43285
diff changeset
    52
  Thy/thy_header.scala
43651
511df47bcadc some support for theory files within Isabelle/Scala session;
wenzelm
parents: 43600
diff changeset
    53
  Thy/thy_info.scala
511df47bcadc some support for theory files within Isabelle/Scala session;
wenzelm
parents: 43600
diff changeset
    54
  Thy/thy_load.scala
43320
wenzelm
parents: 43285
diff changeset
    55
  Thy/thy_syntax.scala
wenzelm
parents: 43285
diff changeset
    56
  library.scala
wenzelm
parents: 43285
diff changeset
    57
  package.scala
wenzelm
parents: 43285
diff changeset
    58
)
wenzelm
parents: 43285
diff changeset
    59
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    60
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    61
## diagnostics
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    62
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    63
PRG="$(basename "$0")"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    64
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    65
function usage()
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    66
{
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    67
  echo
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    68
  echo "Usage: isabelle $PRG [OPTIONS]"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    69
  echo
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    70
  echo "  Options are:"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    71
  echo "    -f           fresh build"
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    72
  echo
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    73
  exit 1
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    74
}
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    75
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    76
function fail()
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    77
{
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    78
  echo "$1" >&2
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    79
  exit 2
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    80
}
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    81
42899
108e815fdc8e misc tuning and update;
wenzelm
parents: 42720
diff changeset
    82
[ -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
    83
[ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    84
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
    85
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    86
## process command line
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    87
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    88
# options
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    89
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    90
FRESH=""
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    91
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    92
while getopts "f" OPT
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    93
do
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    94
  case "$OPT" in
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    95
    f)
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    96
      FRESH=true
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    97
      ;;
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    98
    \?)
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
    99
      usage
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   100
      ;;
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   101
  esac
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   102
done
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   103
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   104
shift $(($OPTIND - 1))
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   105
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   106
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   107
# args
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   108
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   109
[ "$#" -ne 0 ] && usage
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   110
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   111
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   112
43523
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   113
# build
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   114
34284
33ad3571ad83 tuned Isabelle/Scala build;
wenzelm
parents: 34282
diff changeset
   115
TARGET_DIR="$ISABELLE_HOME/lib/classes"
43523
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   116
TARGET="$TARGET_DIR/ext/Pure.jar"
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   117
43405
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   118
declare -a UPDATED=()
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   119
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   120
if [ -n "$FRESH" ]; then
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   121
  OUTDATED=true
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   122
else
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   123
  OUTDATED=false
43523
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   124
  if [ ! -e "$TARGET" ]; then
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   125
    OUTDATED=true
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   126
  else
43405
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   127
    for DEP in "${SOURCES[@]}"
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   128
    do
43405
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   129
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
43523
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   130
      [ "$DEP" -nt "$TARGET" ] && {
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   131
        OUTDATED=true
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   132
        UPDATED["${#UPDATED[@]}"]="$DEP"
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   133
      }
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   134
    done
43405
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   135
  fi
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   136
fi
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   137
34284
33ad3571ad83 tuned Isabelle/Scala build;
wenzelm
parents: 34282
diff changeset
   138
if [ "$OUTDATED" = true ]
33ad3571ad83 tuned Isabelle/Scala build;
wenzelm
parents: 34282
diff changeset
   139
then
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   140
  echo "###"
34876
b52e03f68cc3 clarified terminology;
wenzelm
parents: 34871
diff changeset
   141
  echo "### Building Isabelle/Scala layer ..."
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   142
  echo "###"
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   143
43405
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   144
  [ "${#UPDATED[@]}" -gt 0 ] && {
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   145
    echo "Changed files:"
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   146
    for FILE in "${UPDATED[@]}"
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   147
    do
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   148
      echo "  $FILE"
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   149
    done
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   150
  }
723a8af9d3f0 tuned messages;
wenzelm
parents: 43320
diff changeset
   151
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   152
  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
   153
  "$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
   154
    fail "Failed to compile sources"
43523
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   155
  mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   156
43285
966f359dc724 further jedit build option;
wenzelm
parents: 43280
diff changeset
   157
  pushd classes >/dev/null
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   158
43517
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents: 43405
diff changeset
   159
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents: 43405
diff changeset
   160
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents: 43405
diff changeset
   161
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
87ec9a1c0f98 basic setup for Isabelle charset;
wenzelm
parents: 43405
diff changeset
   162
43523
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   163
  jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   164
    fail "Failed to produce $TARGET"
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   165
43523
5aaa0fe92672 simplified arrangement of jars;
wenzelm
parents: 43521
diff changeset
   166
  cp "$SCALA_HOME/lib/scala-swing.jar" "$SCALA_HOME/lib/scala-library.jar" "$TARGET_DIR/ext"
43521
d477b92109b8 provide Isabelle/Scala environment as Java extension, instead of user classpath
wenzelm
parents: 43517
diff changeset
   167
43280
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   168
  popd >/dev/null
e5dd0ae1b054 support fresh build of jars;
wenzelm
parents: 42899
diff changeset
   169
34282
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   170
  rm -rf classes
549969a7f582 simplified build/bootstrap of Isabelle/Scala components -- avoid make;
wenzelm
parents:
diff changeset
   171
fi