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