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