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