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