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