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