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