| author | traytel | 
| Thu, 11 Mar 2021 10:25:04 +0100 | |
| changeset 73408 | be11fe268b33 | 
| parent 73340 | 0ffcad1f6130 | 
| child 73666 | 4d0df84a5b88 | 
| permissions | -rw-r--r-- | 
| 64483 | 1 | /* Title: Pure/Admin/build_polyml.scala | 
| 2 | Author: Makarius | |
| 3 | ||
| 4 | Build Poly/ML from sources. | |
| 5 | */ | |
| 6 | ||
| 7 | package isabelle | |
| 8 | ||
| 9 | ||
| 69704 | 10 | import scala.util.matching.Regex | 
| 11 | ||
| 12 | ||
| 64483 | 13 | object Build_PolyML | 
| 14 | {
 | |
| 65880 | 15 | /** platform-specific build **/ | 
| 64496 | 16 | |
| 64483 | 17 | sealed case class Platform_Info( | 
| 18 | options: List[String] = Nil, | |
| 64487 | 19 | setup: String = "", | 
| 72462 
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
 wenzelm parents: 
72455diff
changeset | 20 | libs: Set[String] = Set.empty) | 
| 64483 | 21 | |
| 22 | private val platform_info = Map( | |
| 69704 | 23 | "linux" -> | 
| 67580 
eb64467e8bcf
more robust access to shared libraries for poly executable: avoid global change of LD_LIBRARY_PATH (e.g. relevant for subprocesses);
 wenzelm parents: 
66998diff
changeset | 24 | Platform_Info( | 
| 69704 | 25 |         options = List("LDFLAGS=-Wl,-rpath,_DUMMY_"),
 | 
| 72462 
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
 wenzelm parents: 
72455diff
changeset | 26 |         libs = Set("libgmp")),
 | 
| 69704 | 27 | "darwin" -> | 
| 64483 | 28 | Platform_Info( | 
| 29 | options = | |
| 64484 | 30 |           List("--build=x86_64-darwin", "CFLAGS=-arch x86_64 -O3 -I../libffi/include",
 | 
| 31 | "CXXFLAGS=-arch x86_64 -O3 -I../libffi/include", "CCASFLAGS=-arch x86_64", | |
| 67600 
d515b6140381
no --enable-shared for x86_64-darwin: does not work on some test machine;
 wenzelm parents: 
67599diff
changeset | 32 | "LDFLAGS=-segprot POLY rwx rwx"), | 
| 69704 | 33 | setup = "PATH=/usr/bin:/bin:/usr/sbin:/sbin", | 
| 72462 
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
 wenzelm parents: 
72455diff
changeset | 34 |         libs = Set("libpolyml", "libgmp")),
 | 
| 69704 | 35 | "windows" -> | 
| 64483 | 36 | Platform_Info( | 
| 37 | options = | |
| 67597 | 38 |           List("--host=x86_64-w64-mingw32", "CPPFLAGS=-I/mingw64/include", "--disable-windows-gui"),
 | 
| 72427 | 39 | setup = MinGW.environment_export, | 
| 72468 | 40 |         libs = Set("libgcc_s_seh", "libgmp", "libstdc++", "libwinpthread")))
 | 
| 64483 | 41 | |
| 42 | def build_polyml( | |
| 64489 | 43 | root: Path, | 
| 64495 | 44 | sha1_root: Option[Path] = None, | 
| 71726 
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
 wenzelm parents: 
71686diff
changeset | 45 | progress: Progress = new Progress, | 
| 64493 | 46 | arch_64: Boolean = false, | 
| 64485 
e996c0a5eca9
support other bash executable (notably for msys on Windows);
 wenzelm parents: 
64484diff
changeset | 47 | options: List[String] = Nil, | 
| 73340 | 48 | mingw: MinGW = MinGW.none): Unit = | 
| 64483 | 49 |   {
 | 
| 64489 | 50 |     if (!((root + Path.explode("configure")).is_file && (root + Path.explode("PolyML")).is_dir))
 | 
| 51 |       error("Bad Poly/ML root directory: " + root)
 | |
| 64483 | 52 | |
| 72352 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 53 | val platform = Isabelle_Platform.self | 
| 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 54 | val platform_arch = | 
| 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 55 | if (arch_64) platform.arch_64 | 
| 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 56 | else if (platform.is_intel) "x86_64_32" | 
| 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 57 | else platform.arch_32 | 
| 69704 | 58 | |
| 72352 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 59 | val polyml_platform = platform_arch + "-" + platform.os_name | 
| 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 60 | val sha1_platform = platform.arch_64 + "-" + platform.os_name | 
| 64493 | 61 | |
| 64483 | 62 | val info = | 
| 72352 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 63 | platform_info.getOrElse(platform.os_name, | 
| 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 64 |         error("Bad OS platform: " + quote(platform.os_name)))
 | 
| 64483 | 65 | |
| 72455 | 66 |     if (platform.is_linux) Isabelle_System.require_command("chrpath")
 | 
| 70977 | 67 | |
| 64491 | 68 | |
| 64495 | 69 | /* bash */ | 
| 70 | ||
| 64504 | 71 | def bash( | 
| 72 | cwd: Path, script: String, redirect: Boolean = false, echo: Boolean = false): Process_Result = | |
| 73 |     {
 | |
| 72429 | 74 | progress.bash(mingw.bash_script(script), cwd = cwd.file, redirect = redirect, echo = echo) | 
| 64504 | 75 | } | 
| 64495 | 76 | |
| 77 | ||
| 64491 | 78 | /* configure and make */ | 
| 79 | ||
| 64483 | 80 | val configure_options = | 
| 67783 
839de121665c
more robust build: prevent problems seen with Poly/ML eb94e2820013 on Mac OS X;
 wenzelm parents: 
67609diff
changeset | 81 |       List("--disable-shared", "--enable-intinf-as-int", "--with-gmp") :::
 | 
| 69704 | 82 |         info.options ::: options ::: (if (arch_64) Nil else List("--enable-compact32bit"))
 | 
| 64483 | 83 | |
| 64495 | 84 | bash(root, | 
| 64487 | 85 | info.setup + "\n" + | 
| 64485 
e996c0a5eca9
support other bash executable (notably for msys on Windows);
 wenzelm parents: 
64484diff
changeset | 86 | """ | 
| 
e996c0a5eca9
support other bash executable (notably for msys on Windows);
 wenzelm parents: 
64484diff
changeset | 87 | [ -f Makefile ] && make distclean | 
| 
e996c0a5eca9
support other bash executable (notably for msys on Windows);
 wenzelm parents: 
64484diff
changeset | 88 |         {
 | 
| 
e996c0a5eca9
support other bash executable (notably for msys on Windows);
 wenzelm parents: 
64484diff
changeset | 89 | ./configure --prefix="$PWD/target" """ + Bash.strings(configure_options) + """ | 
| 
e996c0a5eca9
support other bash executable (notably for msys on Windows);
 wenzelm parents: 
64484diff
changeset | 90 | rm -rf target | 
| 
e996c0a5eca9
support other bash executable (notably for msys on Windows);
 wenzelm parents: 
64484diff
changeset | 91 | make compiler && make compiler && make install | 
| 
e996c0a5eca9
support other bash executable (notably for msys on Windows);
 wenzelm parents: 
64484diff
changeset | 92 |         } || { echo "Build failed" >&2; exit 2; }
 | 
| 64501 | 93 | """, redirect = true, echo = true).check | 
| 64485 
e996c0a5eca9
support other bash executable (notably for msys on Windows);
 wenzelm parents: 
64484diff
changeset | 94 | |
| 64491 | 95 | |
| 64495 | 96 | /* sha1 library */ | 
| 97 | ||
| 98 | val sha1_files = | |
| 99 |       if (sha1_root.isDefined) {
 | |
| 100 | val dir1 = sha1_root.get | |
| 72352 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 101 | bash(dir1, "./build " + sha1_platform, redirect = true, echo = true).check | 
| 64505 | 102 | |
| 72352 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 103 | val dir2 = dir1 + Path.explode(sha1_platform) | 
| 72462 
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
 wenzelm parents: 
72455diff
changeset | 104 | File.read_dir(dir2).map(entry => dir2 + Path.basic(entry)) | 
| 64495 | 105 | } | 
| 106 | else Nil | |
| 107 | ||
| 108 | ||
| 72462 
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
 wenzelm parents: 
72455diff
changeset | 109 | /* install */ | 
| 64484 | 110 | |
| 72462 
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
 wenzelm parents: 
72455diff
changeset | 111 | val platform_dir = Path.explode(polyml_platform) | 
| 
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
 wenzelm parents: 
72455diff
changeset | 112 | Isabelle_System.rm_tree(platform_dir) | 
| 
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
 wenzelm parents: 
72455diff
changeset | 113 | Isabelle_System.make_directory(platform_dir) | 
| 64483 | 114 | |
| 73317 | 115 | for (file <- sha1_files) Isabelle_System.copy_file(file, platform_dir) | 
| 67592 
66253039d5ca
enforce shared libpoly on all platforms, with File.copy before File.move;
 wenzelm parents: 
67589diff
changeset | 116 | |
| 64483 | 117 |     for {
 | 
| 64484 | 118 |       d <- List("target/bin", "target/lib")
 | 
| 64489 | 119 | dir = root + Path.explode(d) | 
| 64483 | 120 | entry <- File.read_dir(dir) | 
| 73317 | 121 | } Isabelle_System.move_file(dir + Path.explode(entry), platform_dir) | 
| 67584 | 122 | |
| 72469 | 123 | Executable.libraries_closure( | 
| 124 |       platform_dir + Path.basic("poly").platform_exe, mingw = mingw, filter = info.libs)
 | |
| 125 | ||
| 67584 | 126 | |
| 127 | /* polyc: directory prefix */ | |
| 128 | ||
| 72378 | 129 | val Header = "#! */bin/sh".r | 
| 72462 
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
 wenzelm parents: 
72455diff
changeset | 130 |     File.change(platform_dir + Path.explode("polyc"), txt =>
 | 
| 72378 | 131 |       split_lines(txt) match {
 | 
| 132 | case Header() :: lines => | |
| 133 | val lines1 = | |
| 134 | lines.map(line => | |
| 135 |               if (line.startsWith("prefix=")) "prefix=\"$(cd \"$(dirname \"$0\")\"; pwd)\""
 | |
| 136 |               else if (line.startsWith("BINDIR=")) "BINDIR=\"$prefix\""
 | |
| 137 |               else if (line.startsWith("LIBDIR=")) "LIBDIR=\"$prefix\""
 | |
| 138 | else line) | |
| 139 |           cat_lines("#!/usr/bin/env bash" ::lines1)
 | |
| 140 | case lines => | |
| 141 |           error(cat_lines("Cannot patch polyc -- undetected header:" :: lines.take(3)))
 | |
| 142 | } | |
| 143 | ) | |
| 64483 | 144 | } | 
| 145 | ||
| 146 | ||
| 64496 | 147 | |
| 65880 | 148 | /** skeleton for component **/ | 
| 149 | ||
| 73340 | 150 | private def extract_sources(source_archive: Path, component_dir: Path): Unit = | 
| 65880 | 151 |   {
 | 
| 71396 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 152 |     if (source_archive.get_ext == "zip") {
 | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 153 | Isabelle_System.bash( | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 154 | "unzip -x " + File.bash_path(source_archive.absolute), cwd = component_dir.file).check | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 155 | } | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 156 |     else {
 | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 157 |       Isabelle_System.gnutar("-xzf " + File.bash_path(source_archive), dir = component_dir).check
 | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 158 | } | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 159 | |
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 160 |     val src_dir = component_dir + Path.explode("src")
 | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 161 |     File.read_dir(component_dir) match {
 | 
| 73317 | 162 | case List(s) => Isabelle_System.move_file(component_dir + Path.basic(s), src_dir) | 
| 71396 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 163 |       case _ => error("Source archive contains multiple directories")
 | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 164 | } | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 165 | |
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 166 |     val lines = split_lines(File.read(src_dir + Path.explode("RootX86.ML")))
 | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 167 | val ml_files = | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 168 |       for {
 | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 169 | line <- lines | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 170 |         rest <- Library.try_unprefix("use", line)
 | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 171 | } yield "ML_file" + rest | 
| 65880 | 172 | |
| 71396 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 173 |     File.write(src_dir + Path.explode("ROOT.ML"),
 | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 174 | """(* Poly/ML Compiler root file. | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 175 | |
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 176 | When this file is open in the Prover IDE, the ML files of the Poly/ML | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 177 | compiler can be explored interactively. This is a separate copy: it does | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 178 | not affect the running ML session. *) | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 179 | """ + ml_files.mkString("\n", "\n", "\n"))
 | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 180 | } | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 181 | |
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 182 | def build_polyml_component( | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 183 | source_archive: Path, | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 184 | component_dir: Path, | 
| 73340 | 185 | sha1_root: Option[Path] = None): Unit = | 
| 71396 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 186 |   {
 | 
| 72377 | 187 | Isabelle_System.new_directory(component_dir) | 
| 71396 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 188 | extract_sources(source_archive, component_dir) | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 189 | |
| 73317 | 190 |     Isabelle_System.copy_file(Path.explode("~~/Admin/polyml/README"), component_dir)
 | 
| 71396 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 191 | |
| 72376 | 192 |     val etc_dir = Isabelle_System.make_directory(component_dir + Path.explode("etc"))
 | 
| 73317 | 193 |     Isabelle_System.copy_file(Path.explode("~~/Admin/polyml/settings"), etc_dir)
 | 
| 64483 | 194 | |
| 65880 | 195 |     sha1_root match {
 | 
| 196 | case Some(dir) => | |
| 71396 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 197 |         Mercurial.repository(dir).archive(File.standard_path(component_dir + Path.explode("sha1")))
 | 
| 65880 | 198 | case None => | 
| 199 | } | |
| 200 | } | |
| 201 | ||
| 202 | ||
| 203 | ||
| 204 | /** Isabelle tool wrappers **/ | |
| 205 | ||
| 206 | val isabelle_tool1 = | |
| 72763 | 207 |     Isabelle_Tool("build_polyml", "build Poly/ML from sources", Scala_Project.here, args =>
 | 
| 64500 
159ea1055b39
back to regular Isabelle tool (reverting abc34a149690);
 wenzelm parents: 
64499diff
changeset | 208 |     {
 | 
| 72429 | 209 | var mingw = MinGW.none | 
| 72352 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 210 | var arch_64 = Isabelle_Platform.self.is_arm | 
| 71686 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 211 | var sha1_root: Option[Path] = None | 
| 64483 | 212 | |
| 71686 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 213 |       val getopts = Getopts("""
 | 
| 64489 | 214 | Usage: isabelle build_polyml [OPTIONS] ROOT [CONFIGURE_OPTIONS] | 
| 64483 | 215 | |
| 216 | Options are: | |
| 72429 | 217 | -M DIR msys/mingw root specification for Windows | 
| 72352 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 218 | -m ARCH processor architecture (32 or 64, default: """ + | 
| 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 219 | (if (arch_64) "64" else "32") + """) | 
| 69691 | 220 | -s DIR sha1 sources, see https://isabelle.sketis.net/repos/sha1 | 
| 64483 | 221 | |
| 64499 | 222 | Build Poly/ML in the ROOT directory of its sources, with additional | 
| 67593 | 223 | CONFIGURE_OPTIONS (e.g. --without-gmp). | 
| 64483 | 224 | """, | 
| 72431 | 225 | "M:" -> (arg => mingw = MinGW(Path.explode(arg))), | 
| 71686 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 226 | "m:" -> | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 227 |           {
 | 
| 72352 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 228 | case "32" => arch_64 = false | 
| 
f4bd6f123fdf
more systematic platform support, including arm64-linux;
 wenzelm parents: 
72351diff
changeset | 229 | case "64" => arch_64 = true | 
| 71686 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 230 |             case bad => error("Bad processor architecture: " + quote(bad))
 | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 231 | }, | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 232 | "s:" -> (arg => sha1_root = Some(Path.explode(arg)))) | 
| 64483 | 233 | |
| 71686 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 234 | val more_args = getopts(args) | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 235 | val (root, options) = | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 236 |         more_args match {
 | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 237 | case root :: options => (Path.explode(root), options) | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 238 | case Nil => getopts.usage() | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 239 | } | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 240 | build_polyml(root, sha1_root = sha1_root, progress = new Console_Progress, | 
| 72429 | 241 | arch_64 = arch_64, options = options, mingw = mingw) | 
| 69277 
258bef08b31e
support for user-defined Isabelle/Scala command-line tools;
 wenzelm parents: 
67783diff
changeset | 242 | }) | 
| 65880 | 243 | |
| 244 | val isabelle_tool2 = | |
| 72763 | 245 |     Isabelle_Tool("build_polyml_component", "make skeleton for Poly/ML component",
 | 
| 246 | Scala_Project.here, args => | |
| 65880 | 247 |     {
 | 
| 71686 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 248 | var sha1_root: Option[Path] = None | 
| 65880 | 249 | |
| 71686 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 250 |       val getopts = Getopts("""
 | 
| 71396 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 251 | Usage: isabelle build_polyml_component [OPTIONS] SOURCE_ARCHIVE COMPONENT_DIR | 
| 65880 | 252 | |
| 253 | Options are: | |
| 69691 | 254 | -s DIR sha1 sources, see https://isabelle.sketis.net/repos/sha1 | 
| 65880 | 255 | |
| 71396 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 256 | Make skeleton for Poly/ML component, based on official source archive | 
| 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 257 | (zip or tar.gz). | 
| 65880 | 258 | """, | 
| 71686 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 259 | "s:" -> (arg => sha1_root = Some(Path.explode(arg)))) | 
| 65880 | 260 | |
| 71686 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 261 | val more_args = getopts(args) | 
| 71396 
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
 wenzelm parents: 
71117diff
changeset | 262 | |
| 71686 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 263 | val (source_archive, component_dir) = | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 264 |         more_args match {
 | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 265 | case List(archive, dir) => (Path.explode(archive), Path.explode(dir)) | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 266 | case _ => getopts.usage() | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 267 | } | 
| 
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
 wenzelm parents: 
71632diff
changeset | 268 | build_polyml_component(source_archive, component_dir, sha1_root = sha1_root) | 
| 69277 
258bef08b31e
support for user-defined Isabelle/Scala command-line tools;
 wenzelm parents: 
67783diff
changeset | 269 | }) | 
| 64483 | 270 | } |