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