src/Pure/build-jars
author wenzelm
Fri Feb 14 21:06:20 2014 +0100 (2014-02-14)
changeset 55497 c0f8aebfb43d
parent 54730 de2d99b459b3
child 55511 984e210d412e
permissions -rwxr-xr-x
lexical syntax for SML (in Scala);
tuned;
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@54439
    16
  General/bytes.scala
wenzelm@43320
    17
  General/exn.scala
wenzelm@48411
    18
  General/file.scala
wenzelm@46611
    19
  General/graph.scala
wenzelm@51098
    20
  General/graphics_file.scala
wenzelm@43320
    21
  General/linear_set.scala
wenzelm@52975
    22
  General/multi_map.scala
wenzelm@43600
    23
  General/path.scala
wenzelm@43320
    24
  General/position.scala
wenzelm@43320
    25
  General/pretty.scala
wenzelm@43780
    26
  General/properties.scala
wenzelm@43320
    27
  General/scan.scala
wenzelm@43320
    28
  General/sha1.scala
wenzelm@43320
    29
  General/symbol.scala
wenzelm@45674
    30
  General/time.scala
wenzelm@45666
    31
  General/timing.scala
wenzelm@52671
    32
  General/xz_file.scala
wenzelm@53783
    33
  GUI/color_value.scala
wenzelm@53783
    34
  GUI/gui.scala
wenzelm@53783
    35
  GUI/html5_panel.scala
wenzelm@53783
    36
  GUI/jfx_thread.scala
wenzelm@53783
    37
  GUI/popup.scala
wenzelm@53783
    38
  GUI/swing_thread.scala
wenzelm@53783
    39
  GUI/system_dialog.scala
wenzelm@53783
    40
  GUI/wrap_panel.scala
wenzelm@53279
    41
  Isar/completion.scala
wenzelm@43320
    42
  Isar/keyword.scala
wenzelm@43320
    43
  Isar/outer_syntax.scala
wenzelm@43320
    44
  Isar/parse.scala
wenzelm@43320
    45
  Isar/token.scala
wenzelm@55497
    46
  ML/ml_lex.scala
wenzelm@43320
    47
  PIDE/command.scala
wenzelm@43320
    48
  PIDE/document.scala
wenzelm@52530
    49
  PIDE/document_id.scala
wenzelm@52971
    50
  PIDE/editor.scala
wenzelm@45670
    51
  PIDE/markup.scala
wenzelm@43320
    52
  PIDE/markup_tree.scala
wenzelm@45709
    53
  PIDE/protocol.scala
wenzelm@52981
    54
  PIDE/query_operation.scala
wenzelm@43320
    55
  PIDE/text.scala
wenzelm@44698
    56
  PIDE/xml.scala
wenzelm@44698
    57
  PIDE/yxml.scala
wenzelm@48346
    58
  System/command_line.scala
wenzelm@43320
    59
  System/event_bus.scala
wenzelm@51250
    60
  System/interrupt.scala
wenzelm@43744
    61
  System/invoke_scala.scala
wenzelm@43517
    62
  System/isabelle_charset.scala
wenzelm@51614
    63
  System/isabelle_font.scala
wenzelm@43320
    64
  System/isabelle_process.scala
wenzelm@43320
    65
  System/isabelle_system.scala
wenzelm@48365
    66
  System/options.scala
wenzelm@43320
    67
  System/platform.scala
wenzelm@43320
    68
  System/session.scala
wenzelm@45027
    69
  System/system_channel.scala
wenzelm@50203
    70
  System/utf8.scala
wenzelm@43320
    71
  Thy/html.scala
wenzelm@50707
    72
  Thy/present.scala
wenzelm@43320
    73
  Thy/thy_header.scala
wenzelm@43651
    74
  Thy/thy_info.scala
wenzelm@43651
    75
  Thy/thy_load.scala
wenzelm@43320
    76
  Thy/thy_syntax.scala
wenzelm@50686
    77
  Tools/build.scala
wenzelm@52444
    78
  Tools/doc.scala
wenzelm@52439
    79
  Tools/keywords.scala
wenzelm@50687
    80
  Tools/main.scala
wenzelm@50981
    81
  Tools/ml_statistics.scala
wenzelm@54730
    82
  Tools/simplifier_trace.scala
wenzelm@53055
    83
  Tools/sledgehammer_params.scala
wenzelm@50980
    84
  Tools/task_statistics.scala
wenzelm@43320
    85
  library.scala
wenzelm@43320
    86
  package.scala
wenzelm@43730
    87
  term.scala
wenzelm@43779
    88
  term_xml.scala
wenzelm@43320
    89
)
wenzelm@43320
    90
wenzelm@34282
    91
wenzelm@34282
    92
## diagnostics
wenzelm@34282
    93
wenzelm@43280
    94
PRG="$(basename "$0")"
wenzelm@43280
    95
wenzelm@43280
    96
function usage()
wenzelm@43280
    97
{
wenzelm@43280
    98
  echo
wenzelm@43280
    99
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
   100
  echo
wenzelm@43280
   101
  echo "  Options are:"
wenzelm@43280
   102
  echo "    -f           fresh build"
wenzelm@47408
   103
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
   104
  echo
wenzelm@43280
   105
  exit 1
wenzelm@43280
   106
}
wenzelm@43280
   107
wenzelm@34282
   108
function fail()
wenzelm@34282
   109
{
wenzelm@34282
   110
  echo "$1" >&2
wenzelm@34282
   111
  exit 2
wenzelm@34282
   112
}
wenzelm@34282
   113
wenzelm@42899
   114
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
   115
wenzelm@34282
   116
wenzelm@43280
   117
## process command line
wenzelm@43280
   118
wenzelm@43280
   119
# options
wenzelm@43280
   120
wenzelm@43280
   121
FRESH=""
wenzelm@47408
   122
TEST_PIDE=""
wenzelm@43280
   123
wenzelm@47408
   124
while getopts "ft" OPT
wenzelm@43280
   125
do
wenzelm@43280
   126
  case "$OPT" in
wenzelm@43280
   127
    f)
wenzelm@43280
   128
      FRESH=true
wenzelm@43280
   129
      ;;
wenzelm@47408
   130
    t)
wenzelm@47408
   131
      TEST_PIDE=true
wenzelm@47408
   132
      ;;
wenzelm@43280
   133
    \?)
wenzelm@43280
   134
      usage
wenzelm@43280
   135
      ;;
wenzelm@43280
   136
  esac
wenzelm@43280
   137
done
wenzelm@43280
   138
wenzelm@43280
   139
shift $(($OPTIND - 1))
wenzelm@43280
   140
wenzelm@43280
   141
wenzelm@43280
   142
# args
wenzelm@43280
   143
wenzelm@43280
   144
[ "$#" -ne 0 ] && usage
wenzelm@43280
   145
wenzelm@43280
   146
wenzelm@49558
   147
## build
wenzelm@34282
   148
wenzelm@34284
   149
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@53577
   150
TARGET="$TARGET_DIR/Pure.jar"
wenzelm@34282
   151
wenzelm@45673
   152
declare -a PIDE_SOURCES=()
wenzelm@45673
   153
declare -a PURE_SOURCES=()
wenzelm@45673
   154
wenzelm@45673
   155
for DEP in "${SOURCES[@]}"
wenzelm@45673
   156
do
wenzelm@45673
   157
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   158
  then
wenzelm@45673
   159
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   160
  else
wenzelm@45673
   161
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   162
  fi
wenzelm@45673
   163
done
wenzelm@45673
   164
wenzelm@43405
   165
declare -a UPDATED=()
wenzelm@43405
   166
wenzelm@43280
   167
if [ -n "$FRESH" ]; then
wenzelm@43280
   168
  OUTDATED=true
wenzelm@43280
   169
else
wenzelm@43280
   170
  OUTDATED=false
wenzelm@43523
   171
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   172
    OUTDATED=true
wenzelm@43523
   173
  else
wenzelm@43405
   174
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   175
    do
wenzelm@43405
   176
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   177
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   178
        OUTDATED=true
wenzelm@43523
   179
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   180
      }
wenzelm@43280
   181
    done
wenzelm@43405
   182
  fi
wenzelm@43280
   183
fi
wenzelm@34282
   184
wenzelm@34284
   185
if [ "$OUTDATED" = true ]
wenzelm@34284
   186
then
wenzelm@49173
   187
  echo "### Building Isabelle/Scala ..."
wenzelm@34282
   188
wenzelm@43405
   189
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   190
    echo "Changed files:"
wenzelm@43405
   191
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   192
    do
wenzelm@43405
   193
      echo "  $FILE"
wenzelm@43405
   194
    done
wenzelm@43405
   195
  }
wenzelm@43405
   196
wenzelm@34282
   197
  rm -rf classes && mkdir classes
wenzelm@45673
   198
wenzelm@47009
   199
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   200
wenzelm@50689
   201
  (
wenzelm@53576
   202
    classpath "$ISABELLE_JDK_HOME/jre/lib/jfxrt.jar"
wenzelm@53576
   203
    classpath classes
wenzelm@53576
   204
    export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
wenzelm@50689
   205
wenzelm@50689
   206
    if [ "$TEST_PIDE" = true ]; then
wenzelm@50689
   207
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@50689
   208
        fail "Failed to compile PIDE sources"
wenzelm@50689
   209
      isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
wenzelm@50689
   210
        fail "Failed to compile Pure sources"
wenzelm@50689
   211
    else
wenzelm@50689
   212
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@50689
   213
        fail "Failed to compile sources"
wenzelm@50689
   214
    fi
wenzelm@51508
   215
  ) || exit "$?"
wenzelm@45673
   216
wenzelm@53577
   217
  mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
wenzelm@43280
   218
wenzelm@43285
   219
  pushd classes >/dev/null
wenzelm@43280
   220
wenzelm@43517
   221
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   222
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   223
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   224
wenzelm@54676
   225
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
wenzelm@54709
   226
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
wenzelm@53452
   227
wenzelm@53841
   228
  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.Main META-INF isabelle || \
wenzelm@43523
   229
    fail "Failed to produce $TARGET"
wenzelm@34282
   230
wenzelm@49449
   231
  cp "$SCALA_HOME/lib/scala-compiler.jar" \
wenzelm@47995
   232
    "$SCALA_HOME/lib/scala-library.jar" \
wenzelm@53577
   233
    "$SCALA_HOME/lib/scala-swing.jar" \
wenzelm@53577
   234
    "$SCALA_HOME/lib/scala-actors.jar" \
wenzelm@53577
   235
    "$SCALA_HOME/lib/scala-reflect.jar" \
wenzelm@53577
   236
    "$TARGET_DIR"
wenzelm@49955
   237
wenzelm@43280
   238
  popd >/dev/null
wenzelm@43280
   239
wenzelm@34282
   240
  rm -rf classes
wenzelm@34282
   241
fi