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