src/Pure/build-jars
author wenzelm
Thu Dec 01 14:29:14 2011 +0100 (2011-12-01)
changeset 45709 87017fcbad83
parent 45674 eb65c9d17e2f
child 46611 669601fa1a62
permissions -rwxr-xr-x
clarified modules (again) -- NB: both Document and Protocol are specific to this particular prover;
wenzelm@34282
     1
#!/usr/bin/env bash
wenzelm@34282
     2
#
wenzelm@34282
     3
# Author: Makarius
wenzelm@34282
     4
#
wenzelm@42899
     5
# build-jars - build Isabelle/Scala
wenzelm@34282
     6
#
wenzelm@34282
     7
# Requires proper Isabelle settings environment.
wenzelm@34282
     8
wenzelm@43320
     9
## sources
wenzelm@43320
    10
wenzelm@43320
    11
declare -a SOURCES=(
wenzelm@43660
    12
  Concurrent/counter.scala
wenzelm@43320
    13
  Concurrent/future.scala
wenzelm@43320
    14
  Concurrent/simple_thread.scala
wenzelm@43320
    15
  Concurrent/volatile.scala
wenzelm@43320
    16
  General/exn.scala
wenzelm@43320
    17
  General/linear_set.scala
wenzelm@43600
    18
  General/path.scala
wenzelm@43320
    19
  General/position.scala
wenzelm@43320
    20
  General/pretty.scala
wenzelm@43780
    21
  General/properties.scala
wenzelm@43320
    22
  General/scan.scala
wenzelm@43320
    23
  General/sha1.scala
wenzelm@43320
    24
  General/symbol.scala
wenzelm@45674
    25
  General/time.scala
wenzelm@45666
    26
  General/timing.scala
wenzelm@43320
    27
  Isar/keyword.scala
wenzelm@43320
    28
  Isar/outer_syntax.scala
wenzelm@43320
    29
  Isar/parse.scala
wenzelm@43320
    30
  Isar/token.scala
wenzelm@43715
    31
  PIDE/blob.scala
wenzelm@43320
    32
  PIDE/command.scala
wenzelm@43320
    33
  PIDE/document.scala
wenzelm@45670
    34
  PIDE/isabelle_markup.scala
wenzelm@45670
    35
  PIDE/markup.scala
wenzelm@43320
    36
  PIDE/markup_tree.scala
wenzelm@45709
    37
  PIDE/protocol.scala
wenzelm@43320
    38
  PIDE/text.scala
wenzelm@44698
    39
  PIDE/xml.scala
wenzelm@44698
    40
  PIDE/yxml.scala
wenzelm@43320
    41
  System/cygwin.scala
wenzelm@43320
    42
  System/download.scala
wenzelm@43320
    43
  System/event_bus.scala
wenzelm@43320
    44
  System/gui_setup.scala
wenzelm@43744
    45
  System/invoke_scala.scala
wenzelm@43517
    46
  System/isabelle_charset.scala
wenzelm@43320
    47
  System/isabelle_process.scala
wenzelm@43320
    48
  System/isabelle_system.scala
wenzelm@43320
    49
  System/platform.scala
wenzelm@43320
    50
  System/session.scala
wenzelm@43320
    51
  System/session_manager.scala
wenzelm@43320
    52
  System/standard_system.scala
wenzelm@43320
    53
  System/swing_thread.scala
wenzelm@45027
    54
  System/system_channel.scala
wenzelm@43320
    55
  Thy/completion.scala
wenzelm@43320
    56
  Thy/html.scala
wenzelm@43320
    57
  Thy/thy_header.scala
wenzelm@43651
    58
  Thy/thy_info.scala
wenzelm@43651
    59
  Thy/thy_load.scala
wenzelm@43320
    60
  Thy/thy_syntax.scala
wenzelm@43320
    61
  library.scala
wenzelm@43320
    62
  package.scala
wenzelm@43730
    63
  term.scala
wenzelm@43779
    64
  term_xml.scala
wenzelm@43320
    65
)
wenzelm@43320
    66
wenzelm@34282
    67
wenzelm@34282
    68
## diagnostics
wenzelm@34282
    69
wenzelm@43280
    70
PRG="$(basename "$0")"
wenzelm@43280
    71
wenzelm@43280
    72
function usage()
wenzelm@43280
    73
{
wenzelm@43280
    74
  echo
wenzelm@43280
    75
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
    76
  echo
wenzelm@43280
    77
  echo "  Options are:"
wenzelm@43280
    78
  echo "    -f           fresh build"
wenzelm@43280
    79
  echo
wenzelm@43280
    80
  exit 1
wenzelm@43280
    81
}
wenzelm@43280
    82
wenzelm@34282
    83
function fail()
wenzelm@34282
    84
{
wenzelm@34282
    85
  echo "$1" >&2
wenzelm@34282
    86
  exit 2
wenzelm@34282
    87
}
wenzelm@34282
    88
wenzelm@42899
    89
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@37174
    90
[ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
wenzelm@34282
    91
wenzelm@34282
    92
wenzelm@43280
    93
## process command line
wenzelm@43280
    94
wenzelm@43280
    95
# options
wenzelm@43280
    96
wenzelm@43280
    97
FRESH=""
wenzelm@43280
    98
wenzelm@43280
    99
while getopts "f" OPT
wenzelm@43280
   100
do
wenzelm@43280
   101
  case "$OPT" in
wenzelm@43280
   102
    f)
wenzelm@43280
   103
      FRESH=true
wenzelm@43280
   104
      ;;
wenzelm@43280
   105
    \?)
wenzelm@43280
   106
      usage
wenzelm@43280
   107
      ;;
wenzelm@43280
   108
  esac
wenzelm@43280
   109
done
wenzelm@43280
   110
wenzelm@43280
   111
shift $(($OPTIND - 1))
wenzelm@43280
   112
wenzelm@43280
   113
wenzelm@43280
   114
# args
wenzelm@43280
   115
wenzelm@43280
   116
[ "$#" -ne 0 ] && usage
wenzelm@43280
   117
wenzelm@43280
   118
wenzelm@43280
   119
wenzelm@43523
   120
# build
wenzelm@34282
   121
wenzelm@34284
   122
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@43523
   123
TARGET="$TARGET_DIR/ext/Pure.jar"
wenzelm@34282
   124
wenzelm@45673
   125
declare -a PIDE_SOURCES=()
wenzelm@45673
   126
declare -a PURE_SOURCES=()
wenzelm@45673
   127
wenzelm@45673
   128
for DEP in "${SOURCES[@]}"
wenzelm@45673
   129
do
wenzelm@45673
   130
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   131
  then
wenzelm@45673
   132
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   133
  else
wenzelm@45673
   134
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   135
  fi
wenzelm@45673
   136
done
wenzelm@45673
   137
wenzelm@43405
   138
declare -a UPDATED=()
wenzelm@43405
   139
wenzelm@43280
   140
if [ -n "$FRESH" ]; then
wenzelm@43280
   141
  OUTDATED=true
wenzelm@43280
   142
else
wenzelm@43280
   143
  OUTDATED=false
wenzelm@43523
   144
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   145
    OUTDATED=true
wenzelm@43523
   146
  else
wenzelm@43405
   147
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   148
    do
wenzelm@43405
   149
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   150
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   151
        OUTDATED=true
wenzelm@43523
   152
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   153
      }
wenzelm@43280
   154
    done
wenzelm@43405
   155
  fi
wenzelm@43280
   156
fi
wenzelm@34282
   157
wenzelm@34284
   158
if [ "$OUTDATED" = true ]
wenzelm@34284
   159
then
wenzelm@34876
   160
  echo "### Building Isabelle/Scala layer ..."
wenzelm@34282
   161
wenzelm@43405
   162
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   163
    echo "Changed files:"
wenzelm@43405
   164
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   165
    do
wenzelm@43405
   166
      echo "  $FILE"
wenzelm@43405
   167
    done
wenzelm@43405
   168
  }
wenzelm@43405
   169
wenzelm@34282
   170
  rm -rf classes && mkdir classes
wenzelm@45673
   171
wenzelm@45673
   172
  SCALAC_OPTIONS="-unchecked -deprecation -d classes -target:jvm-1.5"
wenzelm@45673
   173
wenzelm@45673
   174
  "$SCALA_HOME/bin/scalac" $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@45673
   175
    fail "Failed to compile PIDE sources"
wenzelm@45673
   176
wenzelm@45673
   177
  "$SCALA_HOME/bin/scalac" $SCALAC_OPTIONS -classpath classes "${PURE_SOURCES[@]}" || \
wenzelm@45673
   178
    fail "Failed to compile Pure sources"
wenzelm@45673
   179
wenzelm@43523
   180
  mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
wenzelm@43280
   181
wenzelm@43285
   182
  pushd classes >/dev/null
wenzelm@43280
   183
wenzelm@43517
   184
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   185
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   186
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   187
wenzelm@43523
   188
  jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
wenzelm@43523
   189
    fail "Failed to produce $TARGET"
wenzelm@34282
   190
wenzelm@43523
   191
  cp "$SCALA_HOME/lib/scala-swing.jar" "$SCALA_HOME/lib/scala-library.jar" "$TARGET_DIR/ext"
wenzelm@43521
   192
wenzelm@43280
   193
  popd >/dev/null
wenzelm@43280
   194
wenzelm@34282
   195
  rm -rf classes
wenzelm@34282
   196
fi