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