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