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