src/Pure/build-jars
author wenzelm
Fri Jul 20 15:48:22 2012 +0200 (2012-07-20)
changeset 48365 d88aefda01c4
parent 48346 e2382bede914
child 48410 5539322f68c9
permissions -rwxr-xr-x
basic support for stand-alone options with external string representation;
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@46611
    17
  General/graph.scala
wenzelm@43320
    18
  General/linear_set.scala
wenzelm@43600
    19
  General/path.scala
wenzelm@43320
    20
  General/position.scala
wenzelm@43320
    21
  General/pretty.scala
wenzelm@43780
    22
  General/properties.scala
wenzelm@43320
    23
  General/scan.scala
wenzelm@43320
    24
  General/sha1.scala
wenzelm@43320
    25
  General/symbol.scala
wenzelm@45674
    26
  General/time.scala
wenzelm@45666
    27
  General/timing.scala
wenzelm@43320
    28
  Isar/keyword.scala
wenzelm@43320
    29
  Isar/outer_syntax.scala
wenzelm@43320
    30
  Isar/parse.scala
wenzelm@43320
    31
  Isar/token.scala
wenzelm@43715
    32
  PIDE/blob.scala
wenzelm@43320
    33
  PIDE/command.scala
wenzelm@43320
    34
  PIDE/document.scala
wenzelm@45670
    35
  PIDE/isabelle_markup.scala
wenzelm@45670
    36
  PIDE/markup.scala
wenzelm@43320
    37
  PIDE/markup_tree.scala
wenzelm@45709
    38
  PIDE/protocol.scala
wenzelm@43320
    39
  PIDE/text.scala
wenzelm@44698
    40
  PIDE/xml.scala
wenzelm@44698
    41
  PIDE/yxml.scala
wenzelm@48276
    42
  System/build.scala
wenzelm@48346
    43
  System/command_line.scala
wenzelm@43320
    44
  System/event_bus.scala
wenzelm@43320
    45
  System/gui_setup.scala
wenzelm@43744
    46
  System/invoke_scala.scala
wenzelm@43517
    47
  System/isabelle_charset.scala
wenzelm@43320
    48
  System/isabelle_process.scala
wenzelm@43320
    49
  System/isabelle_system.scala
wenzelm@47663
    50
  System/main.scala
wenzelm@48365
    51
  System/options.scala
wenzelm@43320
    52
  System/platform.scala
wenzelm@43320
    53
  System/session.scala
wenzelm@43320
    54
  System/session_manager.scala
wenzelm@43320
    55
  System/standard_system.scala
wenzelm@43320
    56
  System/swing_thread.scala
wenzelm@45027
    57
  System/system_channel.scala
wenzelm@43320
    58
  Thy/completion.scala
wenzelm@43320
    59
  Thy/html.scala
wenzelm@43320
    60
  Thy/thy_header.scala
wenzelm@43651
    61
  Thy/thy_info.scala
wenzelm@43651
    62
  Thy/thy_load.scala
wenzelm@43320
    63
  Thy/thy_syntax.scala
wenzelm@43320
    64
  library.scala
wenzelm@43320
    65
  package.scala
wenzelm@43730
    66
  term.scala
wenzelm@43779
    67
  term_xml.scala
wenzelm@43320
    68
)
wenzelm@43320
    69
wenzelm@34282
    70
wenzelm@34282
    71
## diagnostics
wenzelm@34282
    72
wenzelm@43280
    73
PRG="$(basename "$0")"
wenzelm@43280
    74
wenzelm@43280
    75
function usage()
wenzelm@43280
    76
{
wenzelm@43280
    77
  echo
wenzelm@43280
    78
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
    79
  echo
wenzelm@43280
    80
  echo "  Options are:"
wenzelm@43280
    81
  echo "    -f           fresh build"
wenzelm@47408
    82
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
    83
  echo
wenzelm@43280
    84
  exit 1
wenzelm@43280
    85
}
wenzelm@43280
    86
wenzelm@34282
    87
function fail()
wenzelm@34282
    88
{
wenzelm@34282
    89
  echo "$1" >&2
wenzelm@34282
    90
  exit 2
wenzelm@34282
    91
}
wenzelm@34282
    92
wenzelm@42899
    93
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
    94
wenzelm@34282
    95
wenzelm@43280
    96
## process command line
wenzelm@43280
    97
wenzelm@43280
    98
# options
wenzelm@43280
    99
wenzelm@43280
   100
FRESH=""
wenzelm@47408
   101
TEST_PIDE=""
wenzelm@43280
   102
wenzelm@47408
   103
while getopts "ft" OPT
wenzelm@43280
   104
do
wenzelm@43280
   105
  case "$OPT" in
wenzelm@43280
   106
    f)
wenzelm@43280
   107
      FRESH=true
wenzelm@43280
   108
      ;;
wenzelm@47408
   109
    t)
wenzelm@47408
   110
      TEST_PIDE=true
wenzelm@47408
   111
      ;;
wenzelm@43280
   112
    \?)
wenzelm@43280
   113
      usage
wenzelm@43280
   114
      ;;
wenzelm@43280
   115
  esac
wenzelm@43280
   116
done
wenzelm@43280
   117
wenzelm@43280
   118
shift $(($OPTIND - 1))
wenzelm@43280
   119
wenzelm@43280
   120
wenzelm@43280
   121
# args
wenzelm@43280
   122
wenzelm@43280
   123
[ "$#" -ne 0 ] && usage
wenzelm@43280
   124
wenzelm@43280
   125
wenzelm@43280
   126
wenzelm@43523
   127
# build
wenzelm@34282
   128
wenzelm@34284
   129
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@43523
   130
TARGET="$TARGET_DIR/ext/Pure.jar"
wenzelm@34282
   131
wenzelm@45673
   132
declare -a PIDE_SOURCES=()
wenzelm@45673
   133
declare -a PURE_SOURCES=()
wenzelm@45673
   134
wenzelm@45673
   135
for DEP in "${SOURCES[@]}"
wenzelm@45673
   136
do
wenzelm@45673
   137
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   138
  then
wenzelm@45673
   139
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   140
  else
wenzelm@45673
   141
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   142
  fi
wenzelm@45673
   143
done
wenzelm@45673
   144
wenzelm@43405
   145
declare -a UPDATED=()
wenzelm@43405
   146
wenzelm@43280
   147
if [ -n "$FRESH" ]; then
wenzelm@43280
   148
  OUTDATED=true
wenzelm@43280
   149
else
wenzelm@43280
   150
  OUTDATED=false
wenzelm@43523
   151
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   152
    OUTDATED=true
wenzelm@43523
   153
  else
wenzelm@43405
   154
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   155
    do
wenzelm@43405
   156
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   157
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   158
        OUTDATED=true
wenzelm@43523
   159
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   160
      }
wenzelm@43280
   161
    done
wenzelm@43405
   162
  fi
wenzelm@43280
   163
fi
wenzelm@34282
   164
wenzelm@34284
   165
if [ "$OUTDATED" = true ]
wenzelm@34284
   166
then
wenzelm@34876
   167
  echo "### Building Isabelle/Scala layer ..."
wenzelm@34282
   168
wenzelm@43405
   169
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   170
    echo "Changed files:"
wenzelm@43405
   171
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   172
    do
wenzelm@43405
   173
      echo "  $FILE"
wenzelm@43405
   174
    done
wenzelm@43405
   175
  }
wenzelm@43405
   176
wenzelm@34282
   177
  rm -rf classes && mkdir classes
wenzelm@45673
   178
wenzelm@47009
   179
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   180
wenzelm@47408
   181
  if [ "$TEST_PIDE" = true ]; then
wenzelm@47408
   182
    isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@47408
   183
      fail "Failed to compile PIDE sources"
wenzelm@47408
   184
    isabelle_scala scalac $SCALAC_OPTIONS -classpath classes "${PURE_SOURCES[@]}" || \
wenzelm@47408
   185
      fail "Failed to compile Pure sources"
wenzelm@47408
   186
  else
wenzelm@47408
   187
    isabelle_scala scalac $SCALAC_OPTIONS -classpath classes \
wenzelm@47408
   188
      "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@47408
   189
      fail "Failed to compile sources"
wenzelm@47408
   190
  fi
wenzelm@45673
   191
wenzelm@43523
   192
  mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
wenzelm@43280
   193
wenzelm@43285
   194
  pushd classes >/dev/null
wenzelm@43280
   195
wenzelm@43517
   196
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   197
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   198
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   199
wenzelm@47115
   200
  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
wenzelm@43523
   201
    fail "Failed to produce $TARGET"
wenzelm@34282
   202
wenzelm@47995
   203
  cp "$SCALA_HOME/lib/scala-compiler.jar" \
wenzelm@47995
   204
    "$SCALA_HOME/lib/scala-library.jar" \
wenzelm@47995
   205
    "$SCALA_HOME/lib/scala-swing.jar" "$TARGET_DIR/ext"
wenzelm@47995
   206
wenzelm@47849
   207
  [ -e "$SCALA_HOME/lib/scala-actors.jar" ] && \
wenzelm@47849
   208
    cp "$SCALA_HOME/lib/scala-actors.jar" "$TARGET_DIR/ext"
wenzelm@43521
   209
wenzelm@43280
   210
  popd >/dev/null
wenzelm@43280
   211
wenzelm@34282
   212
  rm -rf classes
wenzelm@34282
   213
fi