src/Pure/build-jars
author wenzelm
Tue Oct 07 14:53:51 2014 +0200 (2014-10-07)
changeset 58610 fffdbce036db
parent 58523 937c479e62fe
child 58706 70a947611792
permissions -rwxr-xr-x
added update_cartouches 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@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@57900
    86
  Thy/thy_structure.scala
wenzelm@43320
    87
  Thy/thy_syntax.scala
wenzelm@58523
    88
  Tools/bibtex.scala
wenzelm@57647
    89
  Tools/build.scala
wenzelm@57647
    90
  Tools/build_console.scala
wenzelm@57647
    91
  Tools/build_doc.scala
wenzelm@56791
    92
  Tools/check_source.scala
wenzelm@52444
    93
  Tools/doc.scala
wenzelm@52439
    94
  Tools/keywords.scala
wenzelm@50687
    95
  Tools/main.scala
wenzelm@50981
    96
  Tools/ml_statistics.scala
wenzelm@56864
    97
  Tools/print_operation.scala
wenzelm@54730
    98
  Tools/simplifier_trace.scala
wenzelm@50980
    99
  Tools/task_statistics.scala
wenzelm@58610
   100
  Tools/update_cartouches.scala
wenzelm@43320
   101
  library.scala
wenzelm@43730
   102
  term.scala
wenzelm@43779
   103
  term_xml.scala
wenzelm@57032
   104
  "../Tools/Graphview/src/graph_panel.scala"
wenzelm@57032
   105
  "../Tools/Graphview/src/layout_pendulum.scala"
wenzelm@57032
   106
  "../Tools/Graphview/src/main_panel.scala"
wenzelm@57032
   107
  "../Tools/Graphview/src/model.scala"
wenzelm@57032
   108
  "../Tools/Graphview/src/mutator_dialog.scala"
wenzelm@57032
   109
  "../Tools/Graphview/src/mutator_event.scala"
wenzelm@57032
   110
  "../Tools/Graphview/src/mutator.scala"
wenzelm@57032
   111
  "../Tools/Graphview/src/popups.scala"
wenzelm@57032
   112
  "../Tools/Graphview/src/shapes.scala"
wenzelm@57032
   113
  "../Tools/Graphview/src/visualizer.scala"
wenzelm@43320
   114
)
wenzelm@43320
   115
wenzelm@34282
   116
wenzelm@34282
   117
## diagnostics
wenzelm@34282
   118
wenzelm@43280
   119
PRG="$(basename "$0")"
wenzelm@43280
   120
wenzelm@43280
   121
function usage()
wenzelm@43280
   122
{
wenzelm@43280
   123
  echo
wenzelm@43280
   124
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
   125
  echo
wenzelm@43280
   126
  echo "  Options are:"
wenzelm@43280
   127
  echo "    -f           fresh build"
wenzelm@47408
   128
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
   129
  echo
wenzelm@43280
   130
  exit 1
wenzelm@43280
   131
}
wenzelm@43280
   132
wenzelm@34282
   133
function fail()
wenzelm@34282
   134
{
wenzelm@34282
   135
  echo "$1" >&2
wenzelm@34282
   136
  exit 2
wenzelm@34282
   137
}
wenzelm@34282
   138
wenzelm@42899
   139
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
   140
wenzelm@34282
   141
wenzelm@43280
   142
## process command line
wenzelm@43280
   143
wenzelm@43280
   144
# options
wenzelm@43280
   145
wenzelm@43280
   146
FRESH=""
wenzelm@47408
   147
TEST_PIDE=""
wenzelm@43280
   148
wenzelm@47408
   149
while getopts "ft" OPT
wenzelm@43280
   150
do
wenzelm@43280
   151
  case "$OPT" in
wenzelm@43280
   152
    f)
wenzelm@43280
   153
      FRESH=true
wenzelm@43280
   154
      ;;
wenzelm@47408
   155
    t)
wenzelm@47408
   156
      TEST_PIDE=true
wenzelm@47408
   157
      ;;
wenzelm@43280
   158
    \?)
wenzelm@43280
   159
      usage
wenzelm@43280
   160
      ;;
wenzelm@43280
   161
  esac
wenzelm@43280
   162
done
wenzelm@43280
   163
wenzelm@43280
   164
shift $(($OPTIND - 1))
wenzelm@43280
   165
wenzelm@43280
   166
wenzelm@43280
   167
# args
wenzelm@43280
   168
wenzelm@43280
   169
[ "$#" -ne 0 ] && usage
wenzelm@43280
   170
wenzelm@43280
   171
wenzelm@49558
   172
## build
wenzelm@34282
   173
wenzelm@34284
   174
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@53577
   175
TARGET="$TARGET_DIR/Pure.jar"
wenzelm@34282
   176
wenzelm@45673
   177
declare -a PIDE_SOURCES=()
wenzelm@45673
   178
declare -a PURE_SOURCES=()
wenzelm@45673
   179
wenzelm@45673
   180
for DEP in "${SOURCES[@]}"
wenzelm@45673
   181
do
wenzelm@45673
   182
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   183
  then
wenzelm@45673
   184
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   185
  else
wenzelm@45673
   186
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   187
  fi
wenzelm@45673
   188
done
wenzelm@45673
   189
wenzelm@43405
   190
declare -a UPDATED=()
wenzelm@43405
   191
wenzelm@43280
   192
if [ -n "$FRESH" ]; then
wenzelm@43280
   193
  OUTDATED=true
wenzelm@43280
   194
else
wenzelm@43280
   195
  OUTDATED=false
wenzelm@43523
   196
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   197
    OUTDATED=true
wenzelm@43523
   198
  else
wenzelm@43405
   199
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   200
    do
wenzelm@43405
   201
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   202
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   203
        OUTDATED=true
wenzelm@43523
   204
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   205
      }
wenzelm@43280
   206
    done
wenzelm@43405
   207
  fi
wenzelm@43280
   208
fi
wenzelm@34282
   209
wenzelm@34284
   210
if [ "$OUTDATED" = true ]
wenzelm@34284
   211
then
wenzelm@49173
   212
  echo "### Building Isabelle/Scala ..."
wenzelm@34282
   213
wenzelm@43405
   214
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   215
    echo "Changed files:"
wenzelm@43405
   216
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   217
    do
wenzelm@43405
   218
      echo "  $FILE"
wenzelm@43405
   219
    done
wenzelm@43405
   220
  }
wenzelm@43405
   221
wenzelm@34282
   222
  rm -rf classes && mkdir classes
wenzelm@45673
   223
wenzelm@47009
   224
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   225
wenzelm@50689
   226
  (
wenzelm@53576
   227
    classpath "$ISABELLE_JDK_HOME/jre/lib/jfxrt.jar"
wenzelm@53576
   228
    classpath classes
wenzelm@53576
   229
    export CLASSPATH="$(jvmpath "$ISABELLE_CLASSPATH")"
wenzelm@50689
   230
wenzelm@50689
   231
    if [ "$TEST_PIDE" = true ]; then
wenzelm@50689
   232
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@50689
   233
        fail "Failed to compile PIDE sources"
wenzelm@50689
   234
      isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
wenzelm@50689
   235
        fail "Failed to compile Pure sources"
wenzelm@50689
   236
    else
wenzelm@50689
   237
      isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@50689
   238
        fail "Failed to compile sources"
wenzelm@50689
   239
    fi
wenzelm@51508
   240
  ) || exit "$?"
wenzelm@45673
   241
wenzelm@53577
   242
  mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
wenzelm@43280
   243
wenzelm@43285
   244
  pushd classes >/dev/null
wenzelm@43280
   245
wenzelm@43517
   246
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   247
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   248
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   249
wenzelm@54676
   250
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
wenzelm@54709
   251
  cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
wenzelm@53452
   252
wenzelm@53841
   253
  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.Main META-INF isabelle || \
wenzelm@43523
   254
    fail "Failed to produce $TARGET"
wenzelm@34282
   255
wenzelm@43280
   256
  popd >/dev/null
wenzelm@43280
   257
wenzelm@34282
   258
  rm -rf classes
wenzelm@34282
   259
fi