src/Pure/build-jars
author wenzelm
Mon Nov 28 22:05:32 2011 +0100 (2011-11-28)
changeset 45666 d83797ef0d2d
parent 45027 f459e93a038e
child 45670 b84170538043
permissions -rwxr-xr-x
separate module for concrete Isabelle markup;
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@45666
    17
  General/isabelle_markup.scala
wenzelm@43320
    18
  General/linear_set.scala
wenzelm@43320
    19
  General/markup.scala
wenzelm@43600
    20
  General/path.scala
wenzelm@43320
    21
  General/position.scala
wenzelm@43320
    22
  General/pretty.scala
wenzelm@43780
    23
  General/properties.scala
wenzelm@43320
    24
  General/scan.scala
wenzelm@43320
    25
  General/sha1.scala
wenzelm@43320
    26
  General/symbol.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@43320
    35
  PIDE/isar_document.scala
wenzelm@43320
    36
  PIDE/markup_tree.scala
wenzelm@43320
    37
  PIDE/text.scala
wenzelm@44698
    38
  PIDE/xml.scala
wenzelm@44698
    39
  PIDE/yxml.scala
wenzelm@43320
    40
  System/cygwin.scala
wenzelm@43320
    41
  System/download.scala
wenzelm@43320
    42
  System/event_bus.scala
wenzelm@43320
    43
  System/gui_setup.scala
wenzelm@43744
    44
  System/invoke_scala.scala
wenzelm@43517
    45
  System/isabelle_charset.scala
wenzelm@43320
    46
  System/isabelle_process.scala
wenzelm@43320
    47
  System/isabelle_system.scala
wenzelm@43320
    48
  System/platform.scala
wenzelm@43320
    49
  System/session.scala
wenzelm@43320
    50
  System/session_manager.scala
wenzelm@43320
    51
  System/standard_system.scala
wenzelm@43320
    52
  System/swing_thread.scala
wenzelm@45027
    53
  System/system_channel.scala
wenzelm@43320
    54
  Thy/completion.scala
wenzelm@43320
    55
  Thy/html.scala
wenzelm@43320
    56
  Thy/thy_header.scala
wenzelm@43651
    57
  Thy/thy_info.scala
wenzelm@43651
    58
  Thy/thy_load.scala
wenzelm@43320
    59
  Thy/thy_syntax.scala
wenzelm@43320
    60
  library.scala
wenzelm@43320
    61
  package.scala
wenzelm@43730
    62
  term.scala
wenzelm@43779
    63
  term_xml.scala
wenzelm@43320
    64
)
wenzelm@43320
    65
wenzelm@34282
    66
wenzelm@34282
    67
## diagnostics
wenzelm@34282
    68
wenzelm@43280
    69
PRG="$(basename "$0")"
wenzelm@43280
    70
wenzelm@43280
    71
function usage()
wenzelm@43280
    72
{
wenzelm@43280
    73
  echo
wenzelm@43280
    74
  echo "Usage: isabelle $PRG [OPTIONS]"
wenzelm@43280
    75
  echo
wenzelm@43280
    76
  echo "  Options are:"
wenzelm@43280
    77
  echo "    -f           fresh build"
wenzelm@43280
    78
  echo
wenzelm@43280
    79
  exit 1
wenzelm@43280
    80
}
wenzelm@43280
    81
wenzelm@34282
    82
function fail()
wenzelm@34282
    83
{
wenzelm@34282
    84
  echo "$1" >&2
wenzelm@34282
    85
  exit 2
wenzelm@34282
    86
}
wenzelm@34282
    87
wenzelm@42899
    88
[ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
wenzelm@37174
    89
[ -z "$SCALA_HOME" ] && fail "Unknown SCALA_HOME -- Scala unavailable"
wenzelm@34282
    90
wenzelm@34282
    91
wenzelm@43280
    92
## process command line
wenzelm@43280
    93
wenzelm@43280
    94
# options
wenzelm@43280
    95
wenzelm@43280
    96
FRESH=""
wenzelm@43280
    97
wenzelm@43280
    98
while getopts "f" OPT
wenzelm@43280
    99
do
wenzelm@43280
   100
  case "$OPT" in
wenzelm@43280
   101
    f)
wenzelm@43280
   102
      FRESH=true
wenzelm@43280
   103
      ;;
wenzelm@43280
   104
    \?)
wenzelm@43280
   105
      usage
wenzelm@43280
   106
      ;;
wenzelm@43280
   107
  esac
wenzelm@43280
   108
done
wenzelm@43280
   109
wenzelm@43280
   110
shift $(($OPTIND - 1))
wenzelm@43280
   111
wenzelm@43280
   112
wenzelm@43280
   113
# args
wenzelm@43280
   114
wenzelm@43280
   115
[ "$#" -ne 0 ] && usage
wenzelm@43280
   116
wenzelm@43280
   117
wenzelm@43280
   118
wenzelm@43523
   119
# build
wenzelm@34282
   120
wenzelm@34284
   121
TARGET_DIR="$ISABELLE_HOME/lib/classes"
wenzelm@43523
   122
TARGET="$TARGET_DIR/ext/Pure.jar"
wenzelm@34282
   123
wenzelm@43405
   124
declare -a UPDATED=()
wenzelm@43405
   125
wenzelm@43280
   126
if [ -n "$FRESH" ]; then
wenzelm@43280
   127
  OUTDATED=true
wenzelm@43280
   128
else
wenzelm@43280
   129
  OUTDATED=false
wenzelm@43523
   130
  if [ ! -e "$TARGET" ]; then
wenzelm@43523
   131
    OUTDATED=true
wenzelm@43523
   132
  else
wenzelm@43405
   133
    for DEP in "${SOURCES[@]}"
wenzelm@43280
   134
    do
wenzelm@43405
   135
      [ ! -e "$DEP" ] && fail "Missing file: $DEP"
wenzelm@43523
   136
      [ "$DEP" -nt "$TARGET" ] && {
wenzelm@43523
   137
        OUTDATED=true
wenzelm@43523
   138
        UPDATED["${#UPDATED[@]}"]="$DEP"
wenzelm@43523
   139
      }
wenzelm@43280
   140
    done
wenzelm@43405
   141
  fi
wenzelm@43280
   142
fi
wenzelm@34282
   143
wenzelm@34284
   144
if [ "$OUTDATED" = true ]
wenzelm@34284
   145
then
wenzelm@34876
   146
  echo "### Building Isabelle/Scala layer ..."
wenzelm@34282
   147
wenzelm@43405
   148
  [ "${#UPDATED[@]}" -gt 0 ] && {
wenzelm@43405
   149
    echo "Changed files:"
wenzelm@43405
   150
    for FILE in "${UPDATED[@]}"
wenzelm@43405
   151
    do
wenzelm@43405
   152
      echo "  $FILE"
wenzelm@43405
   153
    done
wenzelm@43405
   154
  }
wenzelm@43405
   155
wenzelm@34282
   156
  rm -rf classes && mkdir classes
wenzelm@36011
   157
  "$SCALA_HOME/bin/scalac" -unchecked -deprecation -d classes -target:jvm-1.5 "${SOURCES[@]}" || \
wenzelm@34282
   158
    fail "Failed to compile sources"
wenzelm@43523
   159
  mkdir -p "$TARGET_DIR/ext" || fail "Failed to create directory $TARGET_DIR/ext"
wenzelm@43280
   160
wenzelm@43285
   161
  pushd classes >/dev/null
wenzelm@43280
   162
wenzelm@43517
   163
  CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
wenzelm@43517
   164
  mkdir -p "$(dirname "$CHARSET_SERVICE")"
wenzelm@43517
   165
  echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
wenzelm@43517
   166
wenzelm@43523
   167
  jar cfe "$(jvmpath "$TARGET")" isabelle.GUI_Setup META-INF isabelle || \
wenzelm@43523
   168
    fail "Failed to produce $TARGET"
wenzelm@34282
   169
wenzelm@43523
   170
  cp "$SCALA_HOME/lib/scala-swing.jar" "$SCALA_HOME/lib/scala-library.jar" "$TARGET_DIR/ext"
wenzelm@43521
   171
wenzelm@43280
   172
  popd >/dev/null
wenzelm@43280
   173
wenzelm@34282
   174
  rm -rf classes
wenzelm@34282
   175
fi