src/Pure/build-jars
author wenzelm
Thu Feb 23 14:17:51 2012 +0100 (2012-02-23)
changeset 46611 669601fa1a62
parent 45709 87017fcbad83
child 47009 97b68d61de2e
permissions -rwxr-xr-x
directed graphs (in Scala);
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@43320
    42
  System/cygwin.scala
wenzelm@43320
    43
  System/download.scala
wenzelm@43320
    44
  System/event_bus.scala
wenzelm@43320
    45
  System/gui_setup.scala
wenzelm@43744
    46
  System/invoke_scala.scala
wenzelm@43517
    47
  System/isabelle_charset.scala
wenzelm@43320
    48
  System/isabelle_process.scala
wenzelm@43320
    49
  System/isabelle_system.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@43280
    80
  echo
wenzelm@43280
    81
  exit 1
wenzelm@43280
    82
}
wenzelm@43280
    83
wenzelm@34282
    84
function fail()
wenzelm@34282
    85
{
wenzelm@34282
    86
  echo "$1" >&2
wenzelm@34282
    87
  exit 2
wenzelm@34282
    88
}
wenzelm@34282
    89
wenzelm@42899
    90
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@37174
    91
[ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
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@43280
    99
wenzelm@43280
   100
while getopts "f" OPT
wenzelm@43280
   101
do
wenzelm@43280
   102
  case "$OPT" in
wenzelm@43280
   103
    f)
wenzelm@43280
   104
      FRESH=true
wenzelm@43280
   105
      ;;
wenzelm@43280
   106
    \?)
wenzelm@43280
   107
      usage
wenzelm@43280
   108
      ;;
wenzelm@43280
   109
  esac
wenzelm@43280
   110
done
wenzelm@43280
   111
wenzelm@43280
   112
shift $(($OPTIND - 1))
wenzelm@43280
   113
wenzelm@43280
   114
wenzelm@43280
   115
# args
wenzelm@43280
   116
wenzelm@43280
   117
[ "$#" -ne 0 ] && usage
wenzelm@43280
   118
wenzelm@43280
   119
wenzelm@43280
   120
wenzelm@43523
   121
# build
wenzelm@34282
   122
wenzelm@34284
   123
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@43523
   124
TARGET="$TARGET_DIR/ext/Pure.jar"
wenzelm@34282
   125
wenzelm@45673
   126
declare -a PIDE_SOURCES=()
wenzelm@45673
   127
declare -a PURE_SOURCES=()
wenzelm@45673
   128
wenzelm@45673
   129
for DEP in "${SOURCES[@]}"
wenzelm@45673
   130
do
wenzelm@45673
   131
  if grep "Module:.*PIDE" "$DEP" >/dev/null
wenzelm@45673
   132
  then
wenzelm@45673
   133
    PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   134
  else
wenzelm@45673
   135
    PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
wenzelm@45673
   136
  fi
wenzelm@45673
   137
done
wenzelm@45673
   138
wenzelm@43405
   139
declare -a UPDATED=()
wenzelm@43405
   140
wenzelm@43280
   141
if [ -n "$FRESH" ]; then
wenzelm@43280
   142
  OUTDATED=true
wenzelm@43280
   143
else
wenzelm@43280
   144
  OUTDATED=false
wenzelm@43523
   145
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   146
    OUTDATED=true
wenzelm@43523
   147
  else
wenzelm@43405
   148
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   149
    do
wenzelm@43405
   150
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   151
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   152
        OUTDATED=true
wenzelm@43523
   153
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   154
      }
wenzelm@43280
   155
    done
wenzelm@43405
   156
  fi
wenzelm@43280
   157
fi
wenzelm@34282
   158
wenzelm@34284
   159
if [ "$OUTDATED" = true ]
wenzelm@34284
   160
then
wenzelm@34876
   161
  echo "### Building Isabelle/Scala layer ..."
wenzelm@34282
   162
wenzelm@43405
   163
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   164
    echo "Changed files:"
wenzelm@43405
   165
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   166
    do
wenzelm@43405
   167
      echo "  $FILE"
wenzelm@43405
   168
    done
wenzelm@43405
   169
  }
wenzelm@43405
   170
wenzelm@34282
   171
  rm -rf classes && mkdir classes
wenzelm@45673
   172
wenzelm@45673
   173
  SCALAC_OPTIONS="-unchecked -deprecation -d classes -target:jvm-1.5"
wenzelm@45673
   174
wenzelm@45673
   175
  "$SCALA_HOME/bin/scalac" $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
wenzelm@45673
   176
    fail "Failed to compile PIDE sources"
wenzelm@45673
   177
wenzelm@45673
   178
  "$SCALA_HOME/bin/scalac" $SCALAC_OPTIONS -classpath classes "${PURE_SOURCES[@]}" || \
wenzelm@45673
   179
    fail "Failed to compile Pure sources"
wenzelm@45673
   180
wenzelm@43523
   181
  mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
wenzelm@43280
   182
wenzelm@43285
   183
  pushd classes >/dev/null
wenzelm@43280
   184
wenzelm@43517
   185
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   186
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   187
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   188
wenzelm@43523
   189
  jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
wenzelm@43523
   190
    fail "Failed to produce $TARGET"
wenzelm@34282
   191
wenzelm@43523
   192
  cp "$SCALA_HOME/lib/scala-swing.jar" "$SCALA_HOME/lib/scala-library.jar" "$TARGET_DIR/ext"
wenzelm@43521
   193
wenzelm@43280
   194
  popd >/dev/null
wenzelm@43280
   195
wenzelm@34282
   196
  rm -rf classes
wenzelm@34282
   197
fi