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