src/Pure/build-jars
author Lars Hupel <lars.hupel@mytum.de>
Sat Jun 11 17:23:24 2016 +0200 (2016-06-11)
changeset 63288 e0513d6e4916
parent 62902 3c0f53eae166
child 63603 9d9ea2c6bc38
permissions -rwxr-xr-x
start moving actual Jenkins build scripts into the repository
     1 #!/usr/bin/env bash
     2 #
     3 # Author: Makarius
     4 #
     5 # build-jars - build Isabelle/Scala
     6 #
     7 # Requires proper Isabelle settings environment.
     8 
     9 ## sources
    10 
    11 declare -a SOURCES=(
    12   Concurrent/consumer_thread.scala
    13   Concurrent/counter.scala
    14   Concurrent/event_timer.scala
    15   Concurrent/future.scala
    16   Concurrent/mailbox.scala
    17   Concurrent/par_list.scala
    18   Concurrent/standard_thread.scala
    19   Concurrent/synchronized.scala
    20   GUI/color_value.scala
    21   GUI/gui.scala
    22   GUI/gui_thread.scala
    23   GUI/html5_panel.scala
    24   GUI/jfx_gui.scala
    25   GUI/popup.scala
    26   GUI/wrap_panel.scala
    27   General/antiquote.scala
    28   General/bytes.scala
    29   General/completion.scala
    30   General/exn.scala
    31   General/file.scala
    32   General/graph.scala
    33   General/graph_display.scala
    34   General/graphics_file.scala
    35   General/linear_set.scala
    36   General/long_name.scala
    37   General/multi_map.scala
    38   General/output.scala
    39   General/path.scala
    40   General/position.scala
    41   General/pretty.scala
    42   General/properties.scala
    43   General/scan.scala
    44   General/sha1.scala
    45   General/symbol.scala
    46   General/time.scala
    47   General/timing.scala
    48   General/untyped.scala
    49   General/url.scala
    50   General/word.scala
    51   General/xz_file.scala
    52   Isar/keyword.scala
    53   Isar/outer_syntax.scala
    54   Isar/parse.scala
    55   Isar/token.scala
    56   ML/ml_lex.scala
    57   ML/ml_syntax.scala
    58   PIDE/batch_session.scala
    59   PIDE/command.scala
    60   PIDE/command_span.scala
    61   PIDE/document.scala
    62   PIDE/document_id.scala
    63   PIDE/editor.scala
    64   PIDE/markup.scala
    65   PIDE/markup_tree.scala
    66   PIDE/protocol.scala
    67   PIDE/protocol_message.scala
    68   PIDE/prover.scala
    69   PIDE/query_operation.scala
    70   PIDE/resources.scala
    71   PIDE/session.scala
    72   PIDE/text.scala
    73   PIDE/xml.scala
    74   PIDE/yxml.scala
    75   ROOT.scala
    76   System/bash.scala
    77   System/command_line.scala
    78   System/cygwin.scala
    79   System/distribution.scala
    80   System/getopts.scala
    81   System/invoke_scala.scala
    82   System/isabelle_charset.scala
    83   System/isabelle_process.scala
    84   System/isabelle_system.scala
    85   System/isabelle_tool.scala
    86   System/options.scala
    87   System/platform.scala
    88   System/posix_interrupt.scala
    89   System/process_result.scala
    90   System/progress.scala
    91   System/system_channel.scala
    92   System/utf8.scala
    93   Thy/html.scala
    94   Thy/present.scala
    95   Thy/sessions.scala
    96   Thy/thy_header.scala
    97   Thy/thy_info.scala
    98   Thy/thy_syntax.scala
    99   Tools/bibtex.scala
   100   Tools/build.scala
   101   Tools/build_doc.scala
   102   Tools/check_keywords.scala
   103   Tools/check_sources.scala
   104   Tools/ci_profile.scala
   105   Tools/debugger.scala
   106   Tools/doc.scala
   107   Tools/main.scala
   108   Tools/ml_console.scala
   109   Tools/ml_process.scala
   110   Tools/ml_statistics.scala
   111   Tools/news.scala
   112   Tools/print_operation.scala
   113   Tools/simplifier_trace.scala
   114   Tools/task_statistics.scala
   115   Tools/update_cartouches.scala
   116   Tools/update_header.scala
   117   Tools/update_then.scala
   118   Tools/update_theorems.scala
   119   library.scala
   120   term.scala
   121   term_xml.scala
   122   "../Tools/Graphview/graph_file.scala"
   123   "../Tools/Graphview/graph_panel.scala"
   124   "../Tools/Graphview/graphview.scala"
   125   "../Tools/Graphview/layout.scala"
   126   "../Tools/Graphview/main_panel.scala"
   127   "../Tools/Graphview/metrics.scala"
   128   "../Tools/Graphview/model.scala"
   129   "../Tools/Graphview/mutator.scala"
   130   "../Tools/Graphview/mutator_dialog.scala"
   131   "../Tools/Graphview/mutator_event.scala"
   132   "../Tools/Graphview/popups.scala"
   133   "../Tools/Graphview/shapes.scala"
   134   "../Tools/Graphview/tree_panel.scala"
   135 )
   136 
   137 
   138 ## diagnostics
   139 
   140 PRG="$(basename "$0")"
   141 
   142 function usage()
   143 {
   144   echo
   145   echo "Usage: isabelle $PRG [OPTIONS]"
   146   echo
   147   echo "  Options are:"
   148   echo "    -f           fresh build"
   149   echo "    -t           test separate compilation of PIDE"
   150   echo
   151   exit 1
   152 }
   153 
   154 function fail()
   155 {
   156   echo "$1" >&2
   157   exit 2
   158 }
   159 
   160 [ -z "$ISABELLE_HOME" ] && fail "Missing Isabelle settings environment"
   161 
   162 
   163 ## process command line
   164 
   165 # options
   166 
   167 FRESH=""
   168 TEST_PIDE=""
   169 
   170 while getopts "ft" OPT
   171 do
   172   case "$OPT" in
   173     f)
   174       FRESH=true
   175       ;;
   176     t)
   177       TEST_PIDE=true
   178       ;;
   179     \?)
   180       usage
   181       ;;
   182   esac
   183 done
   184 
   185 shift $(($OPTIND - 1))
   186 
   187 
   188 # args
   189 
   190 [ "$#" -ne 0 ] && usage
   191 
   192 
   193 ## build
   194 
   195 TARGET_DIR="$ISABELLE_HOME/lib/classes"
   196 TARGET="$TARGET_DIR/Pure.jar"
   197 
   198 declare -a PIDE_SOURCES=()
   199 declare -a PURE_SOURCES=()
   200 
   201 for DEP in "${SOURCES[@]}"
   202 do
   203   if grep "Module:.*PIDE" "$DEP" >/dev/null
   204   then
   205     PIDE_SOURCES["${#PIDE_SOURCES[@]}"]="$DEP"
   206   else
   207     PURE_SOURCES["${#PURE_SOURCES[@]}"]="$DEP"
   208   fi
   209 done
   210 
   211 declare -a UPDATED=()
   212 
   213 if [ -n "$FRESH" ]; then
   214   OUTDATED=true
   215 else
   216   OUTDATED=false
   217   if [ ! -e "$TARGET" ]; then
   218     OUTDATED=true
   219   else
   220     for DEP in "${SOURCES[@]}"
   221     do
   222       [ ! -e "$DEP" ] && fail "Missing file: $DEP"
   223       [ "$DEP" -nt "$TARGET" ] && {
   224         OUTDATED=true
   225         UPDATED["${#UPDATED[@]}"]="$DEP"
   226       }
   227     done
   228   fi
   229 fi
   230 
   231 if [ "$OUTDATED" = true ]
   232 then
   233   echo "### Building Isabelle/Scala ..."
   234 
   235   [ "${#UPDATED[@]}" -gt 0 ] && {
   236     echo "Changed files:"
   237     for FILE in "${UPDATED[@]}"
   238     do
   239       echo "  $FILE"
   240     done
   241   }
   242 
   243   rm -rf classes && mkdir classes
   244 
   245   SCALAC_OPTIONS="$ISABELLE_SCALA_BUILD_OPTIONS -d classes"
   246 
   247   (
   248     classpath "$JAVA_HOME/lib/jfxrt.jar"
   249     classpath classes
   250     export CLASSPATH="$(platform_path "$ISABELLE_CLASSPATH")"
   251 
   252     if [ "$TEST_PIDE" = true ]; then
   253       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" || \
   254         fail "Failed to compile PIDE sources"
   255       isabelle_scala scalac $SCALAC_OPTIONS "${PURE_SOURCES[@]}" || \
   256         fail "Failed to compile Pure sources"
   257     else
   258       isabelle_scala scalac $SCALAC_OPTIONS "${PIDE_SOURCES[@]}" "${PURE_SOURCES[@]}" || \
   259         fail "Failed to compile sources"
   260     fi
   261   ) || exit "$?"
   262 
   263   mkdir -p "$TARGET_DIR" || fail "Failed to create directory $TARGET_DIR"
   264 
   265   pushd classes >/dev/null
   266 
   267   CHARSET_SERVICE="META-INF/services/java.nio.charset.spi.CharsetProvider"
   268   mkdir -p "$(dirname "$CHARSET_SERVICE")"
   269   echo isabelle.Isabelle_Charset_Provider > "$CHARSET_SERVICE"
   270 
   271   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent-32.gif" isabelle/.
   272   cp "$ISABELLE_HOME/lib/logo/isabelle_transparent.gif" isabelle/.
   273 
   274   isabelle_jdk jar cfe "$(platform_path "$TARGET")" isabelle.Main META-INF isabelle || \
   275     fail "Failed to produce $TARGET"
   276 
   277   popd >/dev/null
   278 
   279   rm -rf classes
   280 fi