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