src/Pure/build-jars
author wenzelm
Tue Jul 17 15:56:19 2012 +0200 (2012-07-17)
changeset 48276 4bd480886813
parent 47998 969457d93f75
child 48346 e2382bede914
permissions -rwxr-xr-x
basic setup for Isabelle build tool;
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@46611
    17
  General/graph.scala
wenzelm@43320
    18
  General/linear_set.scala
wenzelm@43600
    19
  General/path.scala
wenzelm@43320
    20
  General/position.scala
wenzelm@43320
    21
  General/pretty.scala
wenzelm@43780
    22
  General/properties.scala
wenzelm@43320
    23
  General/scan.scala
wenzelm@43320
    24
  General/sha1.scala
wenzelm@43320
    25
  General/symbol.scala
wenzelm@45674
    26
  General/time.scala
wenzelm@45666
    27
  General/timing.scala
wenzelm@43320
    28
  Isar/keyword.scala
wenzelm@43320
    29
  Isar/outer_syntax.scala
wenzelm@43320
    30
  Isar/parse.scala
wenzelm@43320
    31
  Isar/token.scala
wenzelm@43715
    32
  PIDE/blob.scala
wenzelm@43320
    33
  PIDE/command.scala
wenzelm@43320
    34
  PIDE/document.scala
wenzelm@45670
    35
  PIDE/isabelle_markup.scala
wenzelm@45670
    36
  PIDE/markup.scala
wenzelm@43320
    37
  PIDE/markup_tree.scala
wenzelm@45709
    38
  PIDE/protocol.scala
wenzelm@43320
    39
  PIDE/text.scala
wenzelm@44698
    40
  PIDE/xml.scala
wenzelm@44698
    41
  PIDE/yxml.scala
wenzelm@48276
    42
  System/build.scala
wenzelm@43320
    43
  System/event_bus.scala
wenzelm@43320
    44
  System/gui_setup.scala
wenzelm@43744
    45
  System/invoke_scala.scala
wenzelm@43517
    46
  System/isabelle_charset.scala
wenzelm@43320
    47
  System/isabelle_process.scala
wenzelm@43320
    48
  System/isabelle_system.scala
wenzelm@47663
    49
  System/main.scala
wenzelm@43320
    50
  System/platform.scala
wenzelm@43320
    51
  System/session.scala
wenzelm@43320
    52
  System/session_manager.scala
wenzelm@43320
    53
  System/standard_system.scala
wenzelm@43320
    54
  System/swing_thread.scala
wenzelm@45027
    55
  System/system_channel.scala
wenzelm@43320
    56
  Thy/completion.scala
wenzelm@43320
    57
  Thy/html.scala
wenzelm@43320
    58
  Thy/thy_header.scala
wenzelm@43651
    59
  Thy/thy_info.scala
wenzelm@43651
    60
  Thy/thy_load.scala
wenzelm@43320
    61
  Thy/thy_syntax.scala
wenzelm@43320
    62
  library.scala
wenzelm@43320
    63
  package.scala
wenzelm@43730
    64
  term.scala
wenzelm@43779
    65
  term_xml.scala
wenzelm@43320
    66
)
wenzelm@43320
    67
wenzelm@34282
    68
wenzelm@34282
    69
## diagnostics
wenzelm@34282
    70
wenzelm@43280
    71
PRG="$(basename "$0")"
wenzelm@43280
    72
wenzelm@43280
    73
function usage()
wenzelm@43280
    74
{
wenzelm@43280
    75
  echo
wenzelm@43280
    76
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
    77
  echo
wenzelm@43280
    78
  echo "  Options are:"
wenzelm@43280
    79
  echo "    -f           fresh build"
wenzelm@47408
    80
  echo "    -t           test separate compilation of PIDE"
wenzelm@43280
    81
  echo
wenzelm@43280
    82
  exit 1
wenzelm@43280
    83
}
wenzelm@43280
    84
wenzelm@34282
    85
function fail()
wenzelm@34282
    86
{
wenzelm@34282
    87
  echo "$1" >&2
wenzelm@34282
    88
  exit 2
wenzelm@34282
    89
}
wenzelm@34282
    90
wenzelm@42899
    91
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@34282
    92
wenzelm@34282
    93
wenzelm@43280
    94
## process command line
wenzelm@43280
    95
wenzelm@43280
    96
# options
wenzelm@43280
    97
wenzelm@43280
    98
FRESH=""
wenzelm@47408
    99
TEST_PIDE=""
wenzelm@43280
   100
wenzelm@47408
   101
while getopts "ft" OPT
wenzelm@43280
   102
do
wenzelm@43280
   103
  case "$OPT" in
wenzelm@43280
   104
    f)
wenzelm@43280
   105
      FRESH=true
wenzelm@43280
   106
      ;;
wenzelm@47408
   107
    t)
wenzelm@47408
   108
      TEST_PIDE=true
wenzelm@47408
   109
      ;;
wenzelm@43280
   110
    \?)
wenzelm@43280
   111
      usage
wenzelm@43280
   112
      ;;
wenzelm@43280
   113
  esac
wenzelm@43280
   114
done
wenzelm@43280
   115
wenzelm@43280
   116
shift $(($OPTIND - 1))
wenzelm@43280
   117
wenzelm@43280
   118
wenzelm@43280
   119
# args
wenzelm@43280
   120
wenzelm@43280
   121
[ "$#" -ne 0 ] && usage
wenzelm@43280
   122
wenzelm@43280
   123
wenzelm@43280
   124
wenzelm@43523
   125
# build
wenzelm@34282
   126
wenzelm@34284
   127
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@43523
   128
TARGET="$TARGET_DIR/ext/Pure.jar"
wenzelm@34282
   129
wenzelm@45673
   130
declare -a PIDE_SOURCES=()
wenzelm@45673
   131
declare -a PURE_SOURCES=()
wenzelm@45673
   132
wenzelm@45673
   133
for DEP in "${SOURCES[@]}"
wenzelm@45673
   134
do
wenzelm@45673
   135
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   136
  then
wenzelm@45673
   137
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   138
  else
wenzelm@45673
   139
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   140
  fi
wenzelm@45673
   141
done
wenzelm@45673
   142
wenzelm@43405
   143
declare -a UPDATED=()
wenzelm@43405
   144
wenzelm@43280
   145
if [ -n "$FRESH" ]; then
wenzelm@43280
   146
  OUTDATED=true
wenzelm@43280
   147
else
wenzelm@43280
   148
  OUTDATED=false
wenzelm@43523
   149
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   150
    OUTDATED=true
wenzelm@43523
   151
  else
wenzelm@43405
   152
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   153
    do
wenzelm@43405
   154
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   155
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   156
        OUTDATED=true
wenzelm@43523
   157
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   158
      }
wenzelm@43280
   159
    done
wenzelm@43405
   160
  fi
wenzelm@43280
   161
fi
wenzelm@34282
   162
wenzelm@34284
   163
if [ "$OUTDATED" = true ]
wenzelm@34284
   164
then
wenzelm@34876
   165
  echo "### Building Isabelle/Scala layer ..."
wenzelm@34282
   166
wenzelm@43405
   167
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   168
    echo "Changed files:"
wenzelm@43405
   169
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   170
    do
wenzelm@43405
   171
      echo "  $FILE"
wenzelm@43405
   172
    done
wenzelm@43405
   173
  }
wenzelm@43405
   174
wenzelm@34282
   175
  rm -rf classes && mkdir classes
wenzelm@45673
   176
wenzelm@47009
   177
  SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
wenzelm@45673
   178
wenzelm@47408
   179
  if [ "$TEST_PIDE" = true ]; then
wenzelm@47408
   180
    isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@47408
   181
      fail "Failed to compile PIDE sources"
wenzelm@47408
   182
    isabelle_scala scalac $SCALAC_OPTIONS -classpath classes "${PURE_SOURCES[@]}" || \
wenzelm@47408
   183
      fail "Failed to compile Pure sources"
wenzelm@47408
   184
  else
wenzelm@47408
   185
    isabelle_scala scalac $SCALAC_OPTIONS -classpath classes \
wenzelm@47408
   186
      "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
wenzelm@47408
   187
      fail "Failed to compile sources"
wenzelm@47408
   188
  fi
wenzelm@45673
   189
wenzelm@43523
   190
  mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
wenzelm@43280
   191
wenzelm@43285
   192
  pushd classes >/dev/null
wenzelm@43280
   193
wenzelm@43517
   194
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   195
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   196
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   197
wenzelm@47115
   198
  isabelle_jdk jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
wenzelm@43523
   199
    fail "Failed to produce $TARGET"
wenzelm@34282
   200
wenzelm@47995
   201
  cp "$SCALA_HOME/lib/scala-compiler.jar" \
wenzelm@47995
   202
    "$SCALA_HOME/lib/scala-library.jar" \
wenzelm@47995
   203
    "$SCALA_HOME/lib/scala-swing.jar" "$TARGET_DIR/ext"
wenzelm@47995
   204
wenzelm@47849
   205
  [ -e "$SCALA_HOME/lib/scala-actors.jar" ] && \
wenzelm@47849
   206
    cp "$SCALA_HOME/lib/scala-actors.jar" "$TARGET_DIR/ext"
wenzelm@43521
   207
wenzelm@43280
   208
  popd >/dev/null
wenzelm@43280
   209
wenzelm@34282
   210
  rm -rf classes
wenzelm@34282
   211
fi