src/Pure/build-jars
author wenzelm
Thu Oct 13 12:13:43 2016 +0200 (2016-10-13)
changeset 64188 f88bae1922c4
parent 64161 2b1128e95dfb
child 64202 967515846691
permissions -rwxr-xr-x
clarified modules;
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@64161
    12
  Admin/build_doc.scala
wenzelm@64160
    13
  Admin/build_history.scala
wenzelm@64160
    14
  Admin/build_log.scala
wenzelm@64161
    15
  Admin/build_stats.scala
wenzelm@64161
    16
  Admin/check_sources.scala
wenzelm@64160
    17
  Admin/ci_api.scala
wenzelm@64160
    18
  Admin/ci_profile.scala
wenzelm@64148
    19
  Admin/isabelle_cronjob.scala
wenzelm@64188
    20
  Admin/other_isabelle.scala
wenzelm@64161
    21
  Admin/remote_dmg.scala
wenzelm@56695
    22
  Concurrent/consumer_thread.scala
wenzelm@43660
    23
  Concurrent/counter.scala
wenzelm@56768
    24
  Concurrent/event_timer.scala
wenzelm@43320
    25
  Concurrent/future.scala
wenzelm@56693
    26
  Concurrent/mailbox.scala
wenzelm@59136
    27
  Concurrent/par_list.scala
wenzelm@61556
    28
  Concurrent/standard_thread.scala
wenzelm@56685
    29
  Concurrent/synchronized.scala
wenzelm@57647
    30
  GUI/color_value.scala
wenzelm@57647
    31
  GUI/gui.scala
wenzelm@57647
    32
  GUI/gui_thread.scala
wenzelm@57647
    33
  GUI/html5_panel.scala
wenzelm@57908
    34
  GUI/jfx_gui.scala
wenzelm@57647
    35
  GUI/popup.scala
wenzelm@57647
    36
  GUI/wrap_panel.scala
wenzelm@55511
    37
  General/antiquote.scala
wenzelm@54439
    38
  General/bytes.scala
wenzelm@55673
    39
  General/completion.scala
wenzelm@64056
    40
  General/date.scala
wenzelm@62508
    41
  General/exn.scala
wenzelm@48411
    42
  General/file.scala
wenzelm@46611
    43
  General/graph.scala
wenzelm@59244
    44
  General/graph_display.scala
wenzelm@51098
    45
  General/graphics_file.scala
wenzelm@63823
    46
  General/http_server.scala
wenzelm@63644
    47
  General/json.scala
wenzelm@43320
    48
  General/linear_set.scala
wenzelm@56800
    49
  General/long_name.scala
wenzelm@63997
    50
  General/mercurial.scala
wenzelm@52975
    51
  General/multi_map.scala
wenzelm@56782
    52
  General/output.scala
wenzelm@43600
    53
  General/path.scala
wenzelm@43320
    54
  General/position.scala
wenzelm@43320
    55
  General/pretty.scala
wenzelm@43780
    56
  General/properties.scala
wenzelm@43320
    57
  General/scan.scala
wenzelm@43320
    58
  General/sha1.scala
wenzelm@63788
    59
  General/sql.scala
wenzelm@63788
    60
  General/sqlite.scala
wenzelm@64123
    61
  General/ssh.scala
wenzelm@43320
    62
  General/symbol.scala
wenzelm@45674
    63
  General/time.scala
wenzelm@45666
    64
  General/timing.scala
wenzelm@57647
    65
  General/untyped.scala
wenzelm@56501
    66
  General/url.scala
wenzelm@63805
    67
  General/value.scala
wenzelm@56599
    68
  General/word.scala
wenzelm@64000
    69
  General/xz.scala
wenzelm@63604
    70
  Isar/document_structure.scala
wenzelm@43320
    71
  Isar/keyword.scala
wenzelm@63603
    72
  Isar/line_structure.scala
wenzelm@43320
    73
  Isar/outer_syntax.scala
wenzelm@43320
    74
  Isar/parse.scala
wenzelm@43320
    75
  Isar/token.scala
wenzelm@55497
    76
  ML/ml_lex.scala
wenzelm@62528
    77
  ML/ml_syntax.scala
wenzelm@59362
    78
  PIDE/batch_session.scala
wenzelm@43320
    79
  PIDE/command.scala
wenzelm@57905
    80
  PIDE/command_span.scala
wenzelm@43320
    81
  PIDE/document.scala
wenzelm@52530
    82
  PIDE/document_id.scala
wenzelm@52971
    83
  PIDE/editor.scala
wenzelm@45670
    84
  PIDE/markup.scala
wenzelm@43320
    85
  PIDE/markup_tree.scala
wenzelm@45709
    86
  PIDE/protocol.scala
wenzelm@59713
    87
  PIDE/protocol_message.scala
wenzelm@56385
    88
  PIDE/prover.scala
wenzelm@52981
    89
  PIDE/query_operation.scala
wenzelm@56208
    90
  PIDE/resources.scala
wenzelm@56210
    91
  PIDE/session.scala
wenzelm@43320
    92
  PIDE/text.scala
wenzelm@44698
    93
  PIDE/xml.scala
wenzelm@44698
    94
  PIDE/yxml.scala
wenzelm@57647
    95
  ROOT.scala
wenzelm@62584
    96
  System/bash.scala
wenzelm@61925
    97
  System/command_line.scala
wenzelm@61282
    98
  System/cygwin.scala
wenzelm@62845
    99
  System/distribution.scala
wenzelm@62431
   100
  System/getopts.scala
wenzelm@43744
   101
  System/invoke_scala.scala
wenzelm@43517
   102
  System/isabelle_charset.scala
wenzelm@43320
   103
  System/isabelle_process.scala
wenzelm@43320
   104
  System/isabelle_system.scala
wenzelm@62829
   105
  System/isabelle_tool.scala
wenzelm@48365
   106
  System/options.scala
wenzelm@43320
   107
  System/platform.scala
wenzelm@56860
   108
  System/posix_interrupt.scala
wenzelm@62400
   109
  System/process_result.scala
wenzelm@61276
   110
  System/progress.scala
wenzelm@45027
   111
  System/system_channel.scala
wenzelm@50203
   112
  System/utf8.scala
wenzelm@43320
   113
  Thy/html.scala
wenzelm@50707
   114
  Thy/present.scala
wenzelm@62631
   115
  Thy/sessions.scala
wenzelm@43320
   116
  Thy/thy_header.scala
wenzelm@43651
   117
  Thy/thy_info.scala
wenzelm@43320
   118
  Thy/thy_syntax.scala
wenzelm@58523
   119
  Tools/bibtex.scala
wenzelm@57647
   120
  Tools/build.scala
wenzelm@59891
   121
  Tools/check_keywords.scala
wenzelm@60749
   122
  Tools/debugger.scala
wenzelm@52444
   123
  Tools/doc.scala
wenzelm@50687
   124
  Tools/main.scala
wenzelm@62559
   125
  Tools/ml_console.scala
wenzelm@62586
   126
  Tools/ml_process.scala
wenzelm@50981
   127
  Tools/ml_statistics.scala
wenzelm@62114
   128
  Tools/news.scala
wenzelm@56864
   129
  Tools/print_operation.scala
wenzelm@54730
   130
  Tools/simplifier_trace.scala
wenzelm@50980
   131
  Tools/task_statistics.scala
wenzelm@58610
   132
  Tools/update_cartouches.scala
wenzelm@58872
   133
  Tools/update_header.scala
wenzelm@61216
   134
  Tools/update_then.scala
wenzelm@61337
   135
  Tools/update_theorems.scala
wenzelm@43320
   136
  library.scala
wenzelm@43730
   137
  term.scala
wenzelm@43779
   138
  term_xml.scala
wenzelm@59441
   139
  "../Tools/Graphview/graph_file.scala"
wenzelm@59202
   140
  "../Tools/Graphview/graph_panel.scala"
wenzelm@59459
   141
  "../Tools/Graphview/graphview.scala"
wenzelm@59232
   142
  "../Tools/Graphview/layout.scala"
wenzelm@59202
   143
  "../Tools/Graphview/main_panel.scala"
wenzelm@59290
   144
  "../Tools/Graphview/metrics.scala"
wenzelm@59202
   145
  "../Tools/Graphview/model.scala"
wenzelm@59392
   146
  "../Tools/Graphview/mutator.scala"
wenzelm@59202
   147
  "../Tools/Graphview/mutator_dialog.scala"
wenzelm@59202
   148
  "../Tools/Graphview/mutator_event.scala"
wenzelm@59202
   149
  "../Tools/Graphview/popups.scala"
wenzelm@59202
   150
  "../Tools/Graphview/shapes.scala"
wenzelm@59392
   151
  "../Tools/Graphview/tree_panel.scala"
wenzelm@43320
   152
)
wenzelm@43320
   153
wenzelm@34282
   154
wenzelm@34282
   155
## diagnostics
wenzelm@34282
   156
wenzelm@43280
   157
PRG="$(basename "$0")"
wenzelm@43280
   158
wenzelm@43280
   159
function usage()
wenzelm@43280
   160
{
wenzelm@43280
   161
  echo
wenzelm@43280
   162
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
   163
  echo
wenzelm@43280
   164
  echo "  Options are:"
wenzelm@43280
   165
  echo "    -f           fresh build"
wenzelm@47408
   166
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
   167
  echo
wenzelm@43280
   168
  exit 1
wenzelm@43280
   169
}
wenzelm@43280
   170
wenzelm@34282
   171
function fail()
wenzelm@34282
   172
{
wenzelm@34282
   173
  echo "$1" >&2
wenzelm@34282
   174
  exit 2
wenzelm@34282
   175
}
wenzelm@34282
   176
wenzelm@42899
   177
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
   178
wenzelm@34282
   179
wenzelm@43280
   180
## process command line
wenzelm@43280
   181
wenzelm@43280
   182
# options
wenzelm@43280
   183
wenzelm@43280
   184
FRESH=""
wenzelm@47408
   185
TEST_PIDE=""
wenzelm@43280
   186
wenzelm@47408
   187
while getopts "ft" OPT
wenzelm@43280
   188
do
wenzelm@43280
   189
  case "$OPT" in
wenzelm@43280
   190
    f)
wenzelm@43280
   191
      FRESH=true
wenzelm@43280
   192
      ;;
wenzelm@47408
   193
    t)
wenzelm@47408
   194
      TEST_PIDE=true
wenzelm@47408
   195
      ;;
wenzelm@43280
   196
    \?)
wenzelm@43280
   197
      usage
wenzelm@43280
   198
      ;;
wenzelm@43280
   199
  esac
wenzelm@43280
   200
done
wenzelm@43280
   201
wenzelm@43280
   202
shift $(($OPTIND - 1))
wenzelm@43280
   203
wenzelm@43280
   204
wenzelm@43280
   205
# args
wenzelm@43280
   206
wenzelm@43280
   207
[ "$#" -ne 0 ] && usage
wenzelm@43280
   208
wenzelm@43280
   209
wenzelm@49558
   210
## build
wenzelm@34282
   211
wenzelm@34284
   212
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@53577
   213
TARGET="$TARGET_DIR/Pure.jar"
wenzelm@34282
   214
wenzelm@45673
   215
declare -a PIDE_SOURCES=()
wenzelm@45673
   216
declare -a PURE_SOURCES=()
wenzelm@45673
   217
wenzelm@45673
   218
for DEP in "${SOURCES[@]}"
wenzelm@45673
   219
do
wenzelm@45673
   220
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   221
  then
wenzelm@45673
   222
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   223
  else
wenzelm@45673
   224
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   225
  fi
wenzelm@45673
   226
done
wenzelm@45673
   227
wenzelm@43405
   228
declare -a UPDATED=()
wenzelm@43405
   229
wenzelm@43280
   230
if [ -n "$FRESH" ]; then
wenzelm@43280
   231
  OUTDATED=true
wenzelm@43280
   232
else
wenzelm@43280
   233
  OUTDATED=false
wenzelm@43523
   234
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   235
    OUTDATED=true
wenzelm@43523
   236
  else
wenzelm@43405
   237
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   238
    do
wenzelm@43405
   239
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   240
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   241
        OUTDATED=true
wenzelm@43523
   242
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   243
      }
wenzelm@43280
   244
    done
wenzelm@43405
   245
  fi
wenzelm@43280
   246
fi
wenzelm@34282
   247
wenzelm@34284
   248
if [ "$OUTDATED" = true ]
wenzelm@34284
   249
then
wenzelm@49173
   250
  echo "### Building Isabelle/Scala ..."
wenzelm@34282
   251
wenzelm@43405
   252
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   253
    echo "Changed files:"
wenzelm@43405
   254
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   255
    do
wenzelm@43405
   256
      echo "  $FILE"
wenzelm@43405
   257
    done
wenzelm@43405
   258
  }
wenzelm@43405
   259
wenzelm@34282
   260
  rm -rf classes && mkdir classes
wenzelm@45673
   261
wenzelm@47009
   262
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   263
wenzelm@50689
   264
  (
wenzelm@58791
   265
    classpath "$JAVA_HOME/lib/jfxrt.jar"
wenzelm@53576
   266
    classpath classes
wenzelm@61294
   267
    export CLASSPATH="$(platform_path "$ISABELLE_CLASSPATH")"
wenzelm@50689
   268
wenzelm@50689
   269
    if [ "$TEST_PIDE" = true ]; then
wenzelm@50689
   270
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@50689
   271
        fail "Failed to compile PIDE sources"
wenzelm@50689
   272
      isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
wenzelm@50689
   273
        fail "Failed to compile Pure sources"
wenzelm@50689
   274
    else
wenzelm@50689
   275
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@50689
   276
        fail "Failed to compile sources"
wenzelm@50689
   277
    fi
wenzelm@51508
   278
  ) || exit "$?"
wenzelm@45673
   279
wenzelm@53577
   280
  mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
wenzelm@43280
   281
wenzelm@43285
   282
  pushd classes >/dev/null
wenzelm@43280
   283
wenzelm@43517
   284
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   285
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   286
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   287
wenzelm@54676
   288
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
wenzelm@54709
   289
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
wenzelm@53452
   290
wenzelm@61294
   291
  isabelle_jdk jar cfe "$(platform_path "$TARGET")" isabelle.Main META-INF isabelle || \
wenzelm@43523
   292
    fail "Failed to produce $TARGET"
wenzelm@34282
   293
wenzelm@43280
   294
  popd >/dev/null
wenzelm@43280
   295
wenzelm@34282
   296
  rm -rf classes
wenzelm@34282
   297
fi