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