replaced shell script by Isabelle/Scala;
authorwenzelm
Thu Oct 13 23:44:40 2016 +0200 (2016-10-13)
changeset 64202967515846691
parent 64201 c3edc64e219d
child 64203 2f9a1c76f731
replaced shell script by Isabelle/Scala;
Admin/Release/CHECKLIST
Admin/Release/build
Admin/build_release
src/Pure/Admin/build_release.scala
src/Pure/build-jars
     1.1 --- a/Admin/Release/CHECKLIST	Thu Oct 13 23:09:26 2016 +0200
     1.2 +++ b/Admin/Release/CHECKLIST	Thu Oct 13 23:44:40 2016 +0200
     1.3 @@ -78,7 +78,7 @@
     1.4  
     1.5  - fully-automated packaging (e.g. on macbroy2):
     1.6  
     1.7 -  hg up -r DISTNAME && Admin/Release/build -M macbroy30 -O -l -r DISTNAME /home/isabelle/dist
     1.8 +  hg up -r DISTNAME && Admin/build_release -M macbroy30 -O -l -R DISTNAME /home/isabelle/dist
     1.9  
    1.10  
    1.11  Final release stage
     2.1 --- a/Admin/Release/build	Thu Oct 13 23:09:26 2016 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,166 +0,0 @@
     2.4 -#!/usr/bin/env bash
     2.5 -#
     2.6 -# Author: Makarius
     2.7 -#
     2.8 -# build full Isabelle distribution from repository
     2.9 -
    2.10 -THIS="$(cd "$(dirname "$0")"; pwd)"
    2.11 -PRG="$(basename "$0")"
    2.12 -
    2.13 -
    2.14 -## diagnostics
    2.15 -
    2.16 -PRG="$(basename "$0")"
    2.17 -
    2.18 -function usage()
    2.19 -{
    2.20 -  echo
    2.21 -  echo "Usage: isabelle $PRG [OPTIONS] DIR [VERSION]"
    2.22 -  echo
    2.23 -  echo "  Options are:"
    2.24 -  echo "    -M USER@HOST remote Mac OS X for dmg build"
    2.25 -  echo "    -O           official release (not release-candidate)"
    2.26 -  echo "    -j INT       maximum number of parallel jobs (default 1)"
    2.27 -  echo "    -l           build library"
    2.28 -  echo "    -r RELEASE   proper release with name"
    2.29 -  echo
    2.30 -  echo "  Make Isabelle distribution DIR, using the local repository clone."
    2.31 -  echo
    2.32 -  echo "  VERSION identifies the snapshot, using usual Mercurial terminology;"
    2.33 -  echo "  the default is RELEASE if given, otherwise \"tip\"."
    2.34 -  echo
    2.35 -  exit 1
    2.36 -}
    2.37 -
    2.38 -function fail()
    2.39 -{
    2.40 -  echo "$1" >&2
    2.41 -  exit 2
    2.42 -}
    2.43 -
    2.44 -function check_number()
    2.45 -{
    2.46 -  [ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\""
    2.47 -}
    2.48 -
    2.49 -
    2.50 -## process command line
    2.51 -
    2.52 -# options
    2.53 -
    2.54 -REMOTE_MAC=""
    2.55 -OFFICIAL_RELEASE=""
    2.56 -JOBS=""
    2.57 -LIBRARY=""
    2.58 -RELEASE=""
    2.59 -
    2.60 -while getopts "M:Oj:lr:" OPT
    2.61 -do
    2.62 -  case "$OPT" in
    2.63 -    M)
    2.64 -      REMOTE_MAC="$OPTARG"
    2.65 -      ;;
    2.66 -    O)
    2.67 -      OFFICIAL_RELEASE="-O"
    2.68 -      ;;
    2.69 -    j)
    2.70 -      check_number "$OPTARG"
    2.71 -      JOBS="-j $OPTARG"
    2.72 -      ;;
    2.73 -    l)
    2.74 -      LIBRARY="true"
    2.75 -      ;;
    2.76 -    r)
    2.77 -      RELEASE="$OPTARG"
    2.78 -      ;;
    2.79 -    \?)
    2.80 -      usage
    2.81 -      ;;
    2.82 -  esac
    2.83 -done
    2.84 -
    2.85 -shift $(($OPTIND - 1))
    2.86 -
    2.87 -
    2.88 -# args
    2.89 -
    2.90 -BASE_DIR=""
    2.91 -[ "$#" -gt 0 ] && { BASE_DIR="$1"; shift; }
    2.92 -[ -z "$BASE_DIR" ] && usage
    2.93 -
    2.94 -VERSION=""
    2.95 -[ "$#" -gt 0 ] && { VERSION="$1"; shift; }
    2.96 -[ -z "$VERSION" ] && VERSION="$RELEASE"
    2.97 -[ -z "$VERSION" ] && VERSION="tip"
    2.98 -
    2.99 -[ "$#" -gt 0 ] && usage
   2.100 -
   2.101 -
   2.102 -## Isabelle settings
   2.103 -
   2.104 -ISABELLE_TOOL="$THIS/../../bin/isabelle"
   2.105 -ISABELLE_PLATFORM_FAMILY="$("$ISABELLE_TOOL" getenv -b ISABELLE_PLATFORM_FAMILY)"
   2.106 -
   2.107 -
   2.108 -## main
   2.109 -
   2.110 -# make dist
   2.111 -
   2.112 -if [ -z "$RELEASE" ]; then
   2.113 -  DISTNAME="Isabelle_$(env LC_ALL=C date "+%d-%b-%Y")"
   2.114 -  "$ISABELLE_TOOL" makedist -d "$BASE_DIR" $JOBS $OFFICIAL_RELEASE
   2.115 -else
   2.116 -  DISTNAME="$RELEASE"
   2.117 -  "$ISABELLE_TOOL" makedist -d "$BASE_DIR" $JOBS $OFFICIAL_RELEASE -r "$RELEASE"
   2.118 -fi
   2.119 -[ "$?" = 0 ] || exit "$?"
   2.120 -
   2.121 -DISTBASE="$BASE_DIR/dist-${DISTNAME}"
   2.122 -
   2.123 -
   2.124 -# make bundles
   2.125 -
   2.126 -for PLATFORM_FAMILY in linux windows windows64 macos
   2.127 -do
   2.128 -
   2.129 -echo
   2.130 -echo "*** $PLATFORM_FAMILY ***"
   2.131 -
   2.132 -if [ -n "$REMOTE_MAC" ]; then
   2.133 -  "$ISABELLE_TOOL" makedist_bundle "$DISTBASE/${DISTNAME}.tar.gz" "$PLATFORM_FAMILY" "$REMOTE_MAC"
   2.134 -else
   2.135 -  "$ISABELLE_TOOL" makedist_bundle "$DISTBASE/${DISTNAME}.tar.gz" "$PLATFORM_FAMILY"
   2.136 -fi
   2.137 -[ "$?" = 0 ] || exit "$?"
   2.138 -
   2.139 -done
   2.140 -
   2.141 -
   2.142 -# minimal index
   2.143 -
   2.144 -cat > "$DISTBASE/index.html" <<EOF
   2.145 -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
   2.146 -<html>
   2.147 -<head>
   2.148 -<title>${DISTNAME}</title>
   2.149 -</head>
   2.150 -
   2.151 -<body>
   2.152 -<h1>${DISTNAME}</h1>
   2.153 -<ul>
   2.154 -<li><a href="${DISTNAME}_app.tar.gz">Linux</a></li>
   2.155 -<li><a href="${DISTNAME}-win32.exe">Windows</a></li>
   2.156 -<li><a href="${DISTNAME}-win64.exe">Windows (64bit)</a></li>
   2.157 -<li><a href="${DISTNAME}.dmg">Mac OS X</a></li>
   2.158 -</ul>
   2.159 -</body>
   2.160 -
   2.161 -</html>
   2.162 -EOF
   2.163 -
   2.164 -
   2.165 -# HTML library
   2.166 -
   2.167 -if [ -n "$LIBRARY" ]; then
   2.168 -  "$THIS/build_library" $JOBS "$DISTBASE/${DISTNAME}_${ISABELLE_PLATFORM_FAMILY}.tar.gz"
   2.169 -fi
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/Admin/build_release	Thu Oct 13 23:44:40 2016 +0200
     3.3 @@ -0,0 +1,8 @@
     3.4 +#!/usr/bin/env bash
     3.5 +#
     3.6 +# DESCRIPTION: build full Isabelle distribution from repository
     3.7 +
     3.8 +THIS="$(cd "$(dirname "$0")"; pwd)"
     3.9 +
    3.10 +"$THIS/build" jars || exit $?
    3.11 +exec "$THIS/../bin/isabelle_java" isabelle.Build_Release "$@"
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/Pure/Admin/build_release.scala	Thu Oct 13 23:44:40 2016 +0200
     4.3 @@ -0,0 +1,130 @@
     4.4 +/*  Title:      Pure/Admin/build_release.scala
     4.5 +    Author:     Makarius
     4.6 +
     4.7 +Build full Isabelle distribution from repository.
     4.8 +*/
     4.9 +
    4.10 +package isabelle
    4.11 +
    4.12 +
    4.13 +object Build_Release
    4.14 +{
    4.15 +  def build_release(base_dir: Path,
    4.16 +    progress: Progress = Ignore_Progress,
    4.17 +    rev: String = "",
    4.18 +    official_release: Boolean = false,
    4.19 +    release_name: String = "",
    4.20 +    build_library: Boolean = false,
    4.21 +    parallel_jobs: Int = 1,
    4.22 +    remote_mac: String = "")
    4.23 +  {
    4.24 +    /* release info */
    4.25 +
    4.26 +    val release_date = Date.now()
    4.27 +
    4.28 +    val distribution_name =
    4.29 +      if (release_name != "") release_name
    4.30 +      else "Isabelle_" + Date.Format.date(release_date)
    4.31 +
    4.32 +    val distribution_dir = base_dir + Path.explode("dist-" + distribution_name)
    4.33 +
    4.34 +
    4.35 +    /* make distribution */
    4.36 +
    4.37 +    progress.bash(
    4.38 +      "isabelle makedist -d " + File.bash_path(base_dir) + " -j" + parallel_jobs.toString +
    4.39 +        (if (official_release) " -O" else "") +
    4.40 +        (if (release_name != "") " -r " + File.bash_string(release_name) else "") +
    4.41 +        (if (rev != "") " " + File.bash_string(rev) else ""),
    4.42 +      echo = true).check
    4.43 +
    4.44 +
    4.45 +    /* make application bundles */
    4.46 +
    4.47 +    for (platform_family <- List("linux", "windows", "windows64", "macos")) {
    4.48 +      progress.echo("\n*** " + platform_family + " ***")
    4.49 +      progress.bash(
    4.50 +        "isabelle makedist_bundle " +
    4.51 +          File.bash_path(distribution_dir + Path.explode(distribution_name + ".tar.gz")) +
    4.52 +          " " + File.bash_string(platform_family) +
    4.53 +          (if (remote_mac == "") "" else " " + File.bash_string(remote_mac)),
    4.54 +        echo = true).check
    4.55 +    }
    4.56 +
    4.57 +
    4.58 +    /* minimal website */
    4.59 +
    4.60 +    File.write(distribution_dir + Path.explode("index.html"),
    4.61 +"""<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
    4.62 +<html>
    4.63 +<head>
    4.64 +<title>""" + HTML.output(distribution_name) + """</title>
    4.65 +</head>
    4.66 +
    4.67 +<body>
    4.68 +<h1>""" + HTML.output(distribution_name) + """</h1>
    4.69 +<ul>
    4.70 +<li><a href=""" + "\"" + HTML.output(distribution_name) + """_app.tar.gz">Linux</a></li>
    4.71 +<li><a href=""" + "\"" + HTML.output(distribution_name) + """-win32.exe">Windows</a></li>
    4.72 +<li><a href=""" + "\"" + HTML.output(distribution_name) + """-win64.exe">Windows (64bit)</a></li>
    4.73 +<li><a href=""" + "\"" + HTML.output(distribution_name) + """.dmg">Mac OS X</a></li>
    4.74 +</ul>
    4.75 +</body>
    4.76 +
    4.77 +</html>
    4.78 +""")
    4.79 +
    4.80 +
    4.81 +    /* HTML library */
    4.82 +
    4.83 +    if (build_library)
    4.84 +      progress.bash("\"$ISABELLE_HOME/Admin/Release/build_library\" -j" + parallel_jobs.toString +
    4.85 +        File.bash_path(distribution_dir +
    4.86 +          Path.explode(distribution_name + "_" +
    4.87 +            Isabelle_System.getenv_strict("ISABELLE_PLATFORM_FAMILY") + ".tar.gz"))).check
    4.88 +  }
    4.89 +
    4.90 +
    4.91 +
    4.92 +  /** command line entry point **/
    4.93 +
    4.94 +  def main(args: Array[String])
    4.95 +  {
    4.96 +    Command_Line.tool0 {
    4.97 +      var remote_mac = ""
    4.98 +      var official_release = false
    4.99 +      var release_name = ""
   4.100 +      var parallel_jobs = 1
   4.101 +      var build_library = false
   4.102 +      var rev = ""
   4.103 +
   4.104 +      val getopts = Getopts("""
   4.105 +Usage: Admin/build_release [OPTIONS] BASE_DIR
   4.106 +
   4.107 +  Options are:
   4.108 +    -M USER@HOST remote Mac OS X for dmg build
   4.109 +    -O           official release (not release-candidate)
   4.110 +    -R RELEASE   proper release with name
   4.111 +    -j INT       maximum number of parallel jobs (default 1)
   4.112 +    -l           build library
   4.113 +    -r REV       Mercurial changeset id (default: RELEASE or tip)
   4.114 +
   4.115 +  Build Isabelle release in base directory, using the local repository clone.
   4.116 +""",
   4.117 +        "M:" -> (arg => remote_mac = arg),
   4.118 +        "O" -> (_ => official_release = true),
   4.119 +        "R:" -> (arg => release_name = arg),
   4.120 +        "j:" -> (arg => parallel_jobs = Value.Int.parse(arg)),
   4.121 +        "l" -> (_ => build_library))
   4.122 +
   4.123 +      val more_args = getopts(args)
   4.124 +      val base_dir = more_args match { case List(base_dir) => base_dir case _ => getopts.usage() }
   4.125 +
   4.126 +      val progress = new Console_Progress()
   4.127 +
   4.128 +      build_release(Path.explode(base_dir), progress = progress, rev = rev,
   4.129 +        official_release = official_release, release_name = release_name,
   4.130 +        build_library = build_library, parallel_jobs = parallel_jobs, remote_mac = remote_mac)
   4.131 +    }
   4.132 +  }
   4.133 +}
     5.1 --- a/src/Pure/build-jars	Thu Oct 13 23:09:26 2016 +0200
     5.2 +++ b/src/Pure/build-jars	Thu Oct 13 23:44:40 2016 +0200
     5.3 @@ -12,6 +12,7 @@
     5.4    Admin/build_doc.scala
     5.5    Admin/build_history.scala
     5.6    Admin/build_log.scala
     5.7 +  Admin/build_release.scala
     5.8    Admin/build_stats.scala
     5.9    Admin/check_sources.scala
    5.10    Admin/ci_api.scala