author | wenzelm |
Thu, 10 Apr 2025 20:54:02 +0200 | |
changeset 82481 | 041d65893a85 |
parent 82480 | 489f4a79d215 |
child 82482 | 781be4a1c2b8 |
permissions | -rw-r--r-- |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77510
diff
changeset
|
1 |
/* Title: Pure/Admin/component_polyml.scala |
64483 | 2 |
Author: Makarius |
3 |
||
4 |
Build Poly/ML from sources. |
|
78772 | 5 |
|
6 |
Note: macOS 14 Sonoma requires "LDFLAGS=... -ld64". |
|
64483 | 7 |
*/ |
8 |
||
9 |
package isabelle |
|
10 |
||
11 |
||
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77510
diff
changeset
|
12 |
object Component_PolyML { |
82471 | 13 |
/** platform information **/ |
64496 | 14 |
|
64483 | 15 |
sealed case class Platform_Info( |
16 |
options: List[String] = Nil, |
|
64487 | 17 |
setup: String = "", |
72462
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
wenzelm
parents:
72455
diff
changeset
|
18 |
libs: Set[String] = Set.empty) |
64483 | 19 |
|
20 |
private val platform_info = Map( |
|
69704 | 21 |
"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
|
22 |
Platform_Info( |
69704 | 23 |
options = List("LDFLAGS=-Wl,-rpath,_DUMMY_"), |
72462
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
wenzelm
parents:
72455
diff
changeset
|
24 |
libs = Set("libgmp")), |
69704 | 25 |
"darwin" -> |
64483 | 26 |
Platform_Info( |
73666
4d0df84a5b88
clarified options: implicitly support both x86_64 and arm64;
wenzelm
parents:
73340
diff
changeset
|
27 |
options = List("CFLAGS=-O3", "CXXFLAGS=-O3", "LDFLAGS=-segprot POLY rwx rwx"), |
69704 | 28 |
setup = "PATH=/usr/bin:/bin:/usr/sbin:/sbin", |
72462
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
wenzelm
parents:
72455
diff
changeset
|
29 |
libs = Set("libpolyml", "libgmp")), |
69704 | 30 |
"windows" -> |
64483 | 31 |
Platform_Info( |
32 |
options = |
|
67597 | 33 |
List("--host=x86_64-w64-mingw32", "CPPFLAGS=-I/mingw64/include", "--disable-windows-gui"), |
82468
40a609d67b33
clarified Windows: always use MinGW version (it is unclear how to build libgmp-10.dll);
wenzelm
parents:
82465
diff
changeset
|
34 |
setup = MinGW.env_prefix, |
72468 | 35 |
libs = Set("libgcc_s_seh", "libgmp", "libstdc++", "libwinpthread"))) |
64483 | 36 |
|
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
37 |
sealed case class Platform_Context( |
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
38 |
platform: Isabelle_Platform = Isabelle_Platform.self, |
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
39 |
mingw: MinGW = MinGW.none, |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
40 |
progress: Progress = new Progress |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
41 |
) { |
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
42 |
def standard_path(path: Path): String = mingw.standard_path(path) |
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
43 |
|
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
44 |
def polyml(arch_64: Boolean): String = |
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
45 |
(if (arch_64) platform.arch_64 else platform.arch_64_32) + "-" + platform.os_name |
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
46 |
|
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
47 |
def sha1: String = platform.arch_64 + "-" + platform.os_name |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
48 |
|
82473 | 49 |
def execute(cwd: Path, script_lines: String*): Process_Result = { |
50 |
val script = cat_lines("set -e" :: script_lines.toList) |
|
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
51 |
val script1 = |
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
52 |
if (platform.is_arm && platform.is_macos) { |
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
53 |
"arch -arch arm64 bash -c " + Bash.string(script) |
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
54 |
} |
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
55 |
else mingw.bash_script(script) |
82473 | 56 |
progress.bash(script1, cwd = cwd, echo = progress.verbose).check |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
57 |
} |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
58 |
} |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
59 |
|
82471 | 60 |
|
61 |
||
62 |
/** build stages **/ |
|
63 |
||
82475 | 64 |
def make_polyml_gmp( |
65 |
platform_context: Platform_Context, |
|
66 |
root: Path, |
|
67 |
options: List[String] = Nil |
|
68 |
): Path = { |
|
69 |
val progress = platform_context.progress |
|
70 |
val platform = platform_context.platform |
|
71 |
||
72 |
val platform_arch = if (platform.is_arm) "aarch64" else "x86_64" |
|
73 |
val platform_os = |
|
74 |
if (platform.is_linux) "unknown-linux-gnu" |
|
75 |
else if (platform.is_windows) "w64-mingw32" |
|
76 |
else if (platform.is_macos) """apple-darwin"$(uname -r)"""" |
|
77 |
else error("Bad platform " + platform) |
|
78 |
||
79 |
val target_dir = root + Path.explode("target") |
|
80 |
||
81 |
progress.echo("Building GMP library ...") |
|
82 |
platform_context.execute(root, |
|
83 |
"[ -f Makefile ] && make distclean", |
|
82481
041d65893a85
clarified GMP build options, notably for Windows;
wenzelm
parents:
82480
diff
changeset
|
84 |
"./configure --disable-static --enable-shared --enable-cxx" + |
041d65893a85
clarified GMP build options, notably for Windows;
wenzelm
parents:
82480
diff
changeset
|
85 |
" --build=" + platform_arch + "-" + platform_os + |
82475 | 86 |
" --prefix=" + Bash.string(platform_context.standard_path(target_dir)) + |
87 |
if_proper(options, " " + Bash.strings(options)), |
|
88 |
"make", |
|
89 |
"make check", |
|
90 |
"make install") |
|
91 |
||
92 |
target_dir |
|
93 |
} |
|
94 |
||
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
95 |
def make_polyml( |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
96 |
platform_context: Platform_Context, |
64489 | 97 |
root: Path, |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
98 |
gmp_root: Option[Path] = None, |
64495 | 99 |
sha1_root: Option[Path] = None, |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
100 |
target_dir: Path = Path.current, |
64493 | 101 |
arch_64: Boolean = false, |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
102 |
options: List[String] = Nil |
75393 | 103 |
): Unit = { |
64489 | 104 |
if (!((root + Path.explode("configure")).is_file && (root + Path.explode("PolyML")).is_dir)) |
105 |
error("Bad Poly/ML root directory: " + root) |
|
64483 | 106 |
|
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
107 |
val platform = platform_context.platform |
64493 | 108 |
|
64483 | 109 |
val info = |
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
110 |
platform_info.getOrElse(platform.os_name, |
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
111 |
error("Bad OS platform: " + quote(platform.os_name))) |
64483 | 112 |
|
79499
d117821a5e82
always use patchelf on Linux: base-line is Ubuntu 18.04 where that works properly (see also e79294c4230c);
wenzelm
parents:
78775
diff
changeset
|
113 |
if (platform.is_linux) Isabelle_System.require_command("patchelf") |
70977 | 114 |
|
64491 | 115 |
|
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
116 |
/* configure and make */ |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
117 |
|
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
118 |
val configure_options = { |
82468
40a609d67b33
clarified Windows: always use MinGW version (it is unclear how to build libgmp-10.dll);
wenzelm
parents:
82465
diff
changeset
|
119 |
val options1 = |
40a609d67b33
clarified Windows: always use MinGW version (it is unclear how to build libgmp-10.dll);
wenzelm
parents:
82465
diff
changeset
|
120 |
if (gmp_root.nonEmpty || platform.is_windows) List("--with-gmp") |
40a609d67b33
clarified Windows: always use MinGW version (it is unclear how to build libgmp-10.dll);
wenzelm
parents:
82465
diff
changeset
|
121 |
else List("--without-gmp") |
64495 | 122 |
|
82480
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
123 |
def detect_CFLAGS(s: String): Boolean = s.startsWith("CFLAGS=") |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
124 |
|
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
125 |
val info_options = |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
126 |
if (info.options.exists(detect_CFLAGS)) info.options |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
127 |
else "CFLAGS=" :: info.options |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
128 |
|
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
129 |
val options2 = |
82480
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
130 |
for (opt <- info_options) yield { |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
131 |
if (opt.startsWith("CFLAGS=") && gmp_root.nonEmpty) { |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
132 |
val root0 = gmp_root.get.absolute |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
133 |
val root1 = platform_context.standard_path(root0) |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
134 |
require(root0.implode == File.bash_path(root0), "Bad directory name " + root0) |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
135 |
opt + " " + "-I" + root1 + "/include -L" + root1 + "/lib" |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
136 |
} |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
137 |
else opt |
73672
70d3c7009a65
proper support for macOS/Rosetta: let "uname -m" report arm64 instead of x86_64;
wenzelm
parents:
73667
diff
changeset
|
138 |
} |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
139 |
|
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
140 |
val options3 = if (arch_64) Nil else List("--enable-compact32bit") |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
141 |
|
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
142 |
List("--disable-shared", "--enable-intinf-as-int") ::: |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
143 |
options1 ::: options2 ::: options ::: options3 |
64504 | 144 |
} |
64495 | 145 |
|
82480
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
146 |
val gmp_setup = |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
147 |
gmp_root match { |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
148 |
case Some(dir) => |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
149 |
val v = Executable.library_path_variable(platform) |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
150 |
val p = Isabelle_System.getenv(v) |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
151 |
val s = platform_context.standard_path(dir) |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
152 |
Bash.exports(v + "=" + s + if_proper(p, ":" + p)) |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
153 |
case None => "" |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
154 |
} |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
155 |
|
82473 | 156 |
platform_context.execute(root, |
82480
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
157 |
info.setup + gmp_setup, |
82473 | 158 |
"[ -f Makefile ] && make distclean", |
159 |
"""./configure --prefix="$PWD/target" """ + Bash.strings(configure_options), |
|
160 |
"rm -rf target", |
|
161 |
"make", |
|
162 |
"make install") |
|
64485
e996c0a5eca9
support other bash executable (notably for msys on Windows);
wenzelm
parents:
64484
diff
changeset
|
163 |
|
64491 | 164 |
|
64495 | 165 |
/* sha1 library */ |
166 |
||
167 |
val sha1_files = |
|
82474 | 168 |
sha1_root match { |
169 |
case Some(dir) => |
|
170 |
val platform_path = Path.explode(platform_context.sha1) |
|
171 |
val platform_dir = dir + platform_path |
|
172 |
platform_context.execute(dir, "./build " + File.bash_path(platform_path)) |
|
173 |
File.read_dir(platform_dir).map(entry => platform_dir + Path.basic(entry)) |
|
174 |
case None => Nil |
|
64495 | 175 |
} |
176 |
||
177 |
||
72462
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
wenzelm
parents:
72455
diff
changeset
|
178 |
/* install */ |
64484 | 179 |
|
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
180 |
val platform_path = Path.explode(platform_context.polyml(arch_64)) |
82478 | 181 |
val platform_dir = target_dir + platform_path |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
182 |
|
72462
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
wenzelm
parents:
72455
diff
changeset
|
183 |
Isabelle_System.rm_tree(platform_dir) |
7c552a256ca5
misc tuning and clarification: prefer Executable.libraries_closure;
wenzelm
parents:
72455
diff
changeset
|
184 |
Isabelle_System.make_directory(platform_dir) |
64483 | 185 |
|
82478 | 186 |
for (d <- List("target/bin", "target/lib")) { |
187 |
Isabelle_System.copy_dir(root + Path.explode(d), platform_dir, direct = true) |
|
188 |
} |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
189 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
190 |
for (file <- sha1_files) Isabelle_System.copy_file(file, platform_dir) |
67584 | 191 |
|
72469 | 192 |
Executable.libraries_closure( |
82480
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
193 |
platform_dir + Path.basic("poly").platform_exe, |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
194 |
env_prefix = gmp_setup, |
489f4a79d215
more robust access to GMP library that is provided here;
wenzelm
parents:
82479
diff
changeset
|
195 |
mingw = platform_context.mingw, |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
196 |
filter = info.libs) |
72469 | 197 |
|
67584 | 198 |
|
199 |
/* polyc: directory prefix */ |
|
200 |
||
72378 | 201 |
val Header = "#! */bin/sh".r |
75205 | 202 |
File.change_lines(platform_dir + Path.explode("polyc")) { |
203 |
case Header() :: lines => |
|
204 |
val lines1 = |
|
205 |
lines.map(line => |
|
206 |
if (line.startsWith("prefix=")) "prefix=\"$(cd \"$(dirname \"$0\")\"; pwd)\"" |
|
207 |
else if (line.startsWith("BINDIR=")) "BINDIR=\"$prefix\"" |
|
208 |
else if (line.startsWith("LIBDIR=")) "LIBDIR=\"$prefix\"" |
|
209 |
else line) |
|
210 |
"#!/usr/bin/env bash" :: lines1 |
|
211 |
case lines => |
|
212 |
error(cat_lines("Cannot patch polyc -- undetected header:" :: lines.take(3))) |
|
75202 | 213 |
} |
64483 | 214 |
} |
215 |
||
216 |
||
64496 | 217 |
|
65880 | 218 |
/** skeleton for component **/ |
219 |
||
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
220 |
val standard_gmp_url = "https://gmplib.org/download/gmp/gmp-6.3.0.tar.bz2" |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
221 |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
222 |
val default_polyml_url = "https://github.com/polyml/polyml/archive" |
78774 | 223 |
val default_polyml_version = "90c0dbb2514e" |
224 |
val default_polyml_name = "polyml-5.9.1" |
|
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
225 |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
226 |
val default_sha1_url = "https://isabelle.sketis.net/repos/sha1/archive" |
78775 | 227 |
val default_sha1_version = "0ce12663fe76" |
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
228 |
|
77191 | 229 |
private def init_src_root(src_dir: Path, input: String, output: String): Unit = { |
230 |
val lines = split_lines(File.read(src_dir + Path.explode(input))) |
|
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
231 |
val ml_files = |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
232 |
for { |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
233 |
line <- lines |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
234 |
rest <- Library.try_unprefix("use", line) |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
235 |
} yield "ML_file" + rest |
65880 | 236 |
|
77191 | 237 |
File.write(src_dir + Path.explode(output), |
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
238 |
"""(* Poly/ML Compiler root file. |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
239 |
|
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
240 |
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
|
241 |
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
|
242 |
not affect the running ML session. *) |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
243 |
""" + ml_files.mkString("\n", "\n", "\n")) |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
244 |
} |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
245 |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
246 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
247 |
def build_polyml( |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
248 |
platform_context: Platform_Context, |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
249 |
options: List[String] = Nil, |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
250 |
component_name: String = "", |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
251 |
gmp_url: String = "", |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
252 |
polyml_url: String = default_polyml_url, |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
253 |
polyml_version: String = default_polyml_version, |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
254 |
polyml_name: String = default_polyml_name, |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
255 |
sha1_url: String = default_sha1_url, |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
256 |
sha1_version: String = default_sha1_version, |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
257 |
target_dir: Path = Path.current |
75393 | 258 |
): Unit = { |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
259 |
val platform = platform_context.platform |
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
260 |
val progress = platform_context.progress |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
261 |
|
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
262 |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
263 |
/* component */ |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
264 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
265 |
val component_name1 = if (component_name.isEmpty) "polyml-" + polyml_version else component_name |
81927 | 266 |
val component_dir = |
267 |
Components.Directory(target_dir + Path.basic(component_name1)).create(progress = progress) |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
268 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
269 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
270 |
/* download and build */ |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
271 |
|
82477 | 272 |
Isabelle_System.with_tmp_dir("build") { build_dir => |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
273 |
/* GMP library */ |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
274 |
|
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
275 |
val gmp_root: Option[Path] = |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
276 |
if (gmp_url.isEmpty) None |
82468
40a609d67b33
clarified Windows: always use MinGW version (it is unclear how to build libgmp-10.dll);
wenzelm
parents:
82465
diff
changeset
|
277 |
else if (platform.is_windows) error("Bad GMP source for Windows: use MinGW version instead") |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
278 |
else { |
82477 | 279 |
val gmp_dir = Isabelle_System.make_directory(build_dir + Path.basic("gmp")) |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
280 |
|
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
281 |
val archive_name = |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
282 |
Url.get_base_name(gmp_url).getOrElse(error("No base name in " + quote(gmp_url))) |
82477 | 283 |
val archive = build_dir + Path.basic(archive_name) |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
284 |
Isabelle_System.download_file(gmp_url, archive, progress = progress) |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
285 |
Isabelle_System.extract(archive, gmp_dir, strip = true) |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
286 |
|
82475 | 287 |
Some(make_polyml_gmp(platform_context, gmp_dir)) |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
288 |
} |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
289 |
|
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
290 |
|
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
291 |
/* Poly/ML */ |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
292 |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
293 |
val List(polyml_download, sha1_download) = |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
294 |
for { |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
295 |
(url, version, target) <- |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
296 |
List((polyml_url, polyml_version, "src"), (sha1_url, sha1_version, "sha1")) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
297 |
} yield { |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
298 |
val remote = Url.append_path(url, version + ".tar.gz") |
82477 | 299 |
val download = build_dir + Path.basic(version) |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
300 |
Isabelle_System.download_file(remote, download.tar.gz, progress = progress) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
301 |
Isabelle_System.extract(download.tar.gz, download, strip = true) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
302 |
Isabelle_System.extract( |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
303 |
download.tar.gz, component_dir.path + Path.basic(target), strip = true) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
304 |
download |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
305 |
} |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
306 |
|
77191 | 307 |
init_src_root(component_dir.src, "RootArm64.ML", "ROOT0.ML") |
308 |
init_src_root(component_dir.src, "RootX86.ML", "ROOT.ML") |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
309 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
310 |
for (arch_64 <- List(false, true)) { |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
311 |
progress.echo("Building " + platform_context.polyml(arch_64)) |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
312 |
make_polyml( |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
313 |
platform_context, |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
314 |
root = polyml_download, |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
315 |
gmp_root = gmp_root, |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
316 |
sha1_root = Some(sha1_download), |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
317 |
target_dir = component_dir.path, |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
318 |
arch_64 = arch_64, |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
319 |
options = options) |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
320 |
} |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
321 |
} |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
322 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
323 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
324 |
/* settings */ |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
325 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
326 |
component_dir.write_settings("""# -*- shell-script -*- :mode=shellscript: |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
327 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
328 |
POLYML_HOME="$COMPONENT" |
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
329 |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
330 |
if [ -n "$ISABELLE_APPLE_PLATFORM64" ] |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
331 |
then |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
332 |
if grep "ML_system_apple.*=.*false" "$ISABELLE_HOME_USER/etc/preferences" >/dev/null 2>/dev/null |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
333 |
then |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
334 |
ML_PLATFORM="$ISABELLE_PLATFORM64" |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
335 |
else |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
336 |
ML_PLATFORM="$ISABELLE_APPLE_PLATFORM64" |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
337 |
fi |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
338 |
else |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
339 |
ML_PLATFORM="${ISABELLE_WINDOWS_PLATFORM64:-$ISABELLE_PLATFORM64}" |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
340 |
fi |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
341 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
342 |
if grep "ML_system_64.*=.*true" "$ISABELLE_HOME_USER/etc/preferences" >/dev/null 2>/dev/null |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
343 |
then |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
344 |
ML_OPTIONS="--minheap 1000" |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
345 |
else |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
346 |
ML_PLATFORM="${ML_PLATFORM/64/64_32}" |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
347 |
ML_OPTIONS="--minheap 500" |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
348 |
fi |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
349 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
350 |
ML_SYSTEM=""" + Bash.string(polyml_name) + """ |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
351 |
ML_HOME="$POLYML_HOME/$ML_PLATFORM" |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
352 |
ML_SOURCES="$POLYML_HOME/src" |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
353 |
|
77191 | 354 |
case "$ML_PLATFORM" in |
355 |
*arm64*) |
|
356 |
ISABELLE_DOCS_EXAMPLES="$ISABELLE_DOCS_EXAMPLES:\$ML_SOURCES/ROOT0.ML" |
|
357 |
;; |
|
358 |
*) |
|
359 |
ISABELLE_DOCS_EXAMPLES="$ISABELLE_DOCS_EXAMPLES:\$ML_SOURCES/ROOT.ML" |
|
360 |
;; |
|
361 |
esac |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
362 |
""") |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
363 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
364 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
365 |
/* README */ |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
366 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
367 |
File.write(component_dir.README, |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
368 |
"""Poly/ML for Isabelle |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
369 |
==================== |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
370 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
371 |
This compilation of Poly/ML (https://www.polyml.org) is based on the |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
372 |
source distribution from |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
373 |
https://github.com/polyml/polyml/commit/""" + polyml_version + """ |
64483 | 374 |
|
78774 | 375 |
This coincides with the official release of Poly/ML 5.9.1, see also |
376 |
https://github.com/polyml/polyml/releases/tag/v5.9.1 |
|
377 |
||
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
378 |
The Isabelle repository provides an administrative tool "isabelle |
78482 | 379 |
component_polyml", which can be used in the polyml component directory as |
380 |
follows: |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
381 |
|
78482 | 382 |
* Linux and macOS |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
383 |
|
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
384 |
$ isabelle component_polyml -G: |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
385 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
386 |
* Windows (Cygwin shell) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
387 |
|
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
388 |
$ isabelle component_polyml -G: -M /cygdrive/c/msys64 |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
389 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
390 |
|
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
391 |
Makarius |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
392 |
""" + Date.Format.date(Date.now()) + "\n") |
65880 | 393 |
} |
394 |
||
395 |
||
396 |
||
397 |
/** Isabelle tool wrappers **/ |
|
398 |
||
399 |
val isabelle_tool1 = |
|
82475 | 400 |
Isabelle_Tool("make_polyml_gmp", "make GMP library from existing sources", Scala_Project.here, |
401 |
{ args => |
|
402 |
var mingw = MinGW.none |
|
82476 | 403 |
var verbose = false |
82475 | 404 |
|
405 |
val getopts = Getopts(""" |
|
406 |
Usage: isabelle make_polyml_gmp [OPTIONS] ROOT [CONFIGURE_OPTIONS] |
|
407 |
||
408 |
Options are: |
|
409 |
-M DIR msys/mingw root specification for Windows |
|
410 |
||
411 |
Make GMP library in the ROOT directory of its sources, with additional |
|
412 |
CONFIGURE_OPTIONS. |
|
413 |
""", |
|
82476 | 414 |
"M:" -> (arg => mingw = MinGW(Path.explode(arg))), |
415 |
"v" -> (_ => verbose = true)) |
|
82475 | 416 |
|
417 |
val more_args = getopts(args) |
|
418 |
val (root, options) = |
|
419 |
more_args match { |
|
420 |
case root :: options => (Path.explode(root), options) |
|
421 |
case Nil => getopts.usage() |
|
422 |
} |
|
82476 | 423 |
|
424 |
val progress = new Console_Progress(verbose = verbose) |
|
425 |
make_polyml_gmp(Platform_Context(mingw = mingw, progress = progress), |
|
82475 | 426 |
root, options = options) |
427 |
}) |
|
428 |
||
429 |
val isabelle_tool2 = |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
430 |
Isabelle_Tool("make_polyml", "make Poly/ML from existing sources", Scala_Project.here, |
75394 | 431 |
{ args => |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
432 |
var gmp_root: Option[Path] = None |
75394 | 433 |
var mingw = MinGW.none |
434 |
var arch_64 = false |
|
435 |
var sha1_root: Option[Path] = None |
|
82476 | 436 |
var verbose = false |
64483 | 437 |
|
75394 | 438 |
val getopts = Getopts(""" |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
439 |
Usage: isabelle make_polyml [OPTIONS] ROOT [CONFIGURE_OPTIONS] |
64483 | 440 |
|
441 |
Options are: |
|
72429 | 442 |
-M DIR msys/mingw root specification for Windows |
82479 | 443 |
-g DIR GMP library root |
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
444 |
-m ARCH processor architecture (32 or 64, default: """ + |
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
445 |
(if (arch_64) "64" else "32") + """) |
69691 | 446 |
-s DIR sha1 sources, see https://isabelle.sketis.net/repos/sha1 |
64483 | 447 |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
448 |
Make Poly/ML in the ROOT directory of its sources, with additional |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
449 |
CONFIGURE_OPTIONS. |
64483 | 450 |
""", |
75394 | 451 |
"M:" -> (arg => mingw = MinGW(Path.explode(arg))), |
82479 | 452 |
"g:" -> (arg => gmp_root = Some(Path.explode(arg))), |
75394 | 453 |
"m:" -> |
454 |
{ |
|
455 |
case "32" => arch_64 = false |
|
456 |
case "64" => arch_64 = true |
|
457 |
case bad => error("Bad processor architecture: " + quote(bad)) |
|
458 |
}, |
|
82476 | 459 |
"s:" -> (arg => sha1_root = Some(Path.explode(arg))), |
460 |
"v" -> (_ => verbose = true)) |
|
64483 | 461 |
|
75394 | 462 |
val more_args = getopts(args) |
463 |
val (root, options) = |
|
464 |
more_args match { |
|
465 |
case root :: options => (Path.explode(root), options) |
|
466 |
case Nil => getopts.usage() |
|
467 |
} |
|
82476 | 468 |
|
469 |
val progress = new Console_Progress(verbose = verbose) |
|
470 |
make_polyml(Platform_Context(mingw = mingw, progress = progress), |
|
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
471 |
root, gmp_root = gmp_root, sha1_root = sha1_root, arch_64 = arch_64, options = options) |
75394 | 472 |
}) |
65880 | 473 |
|
82475 | 474 |
val isabelle_tool3 = |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77510
diff
changeset
|
475 |
Isabelle_Tool("component_polyml", "build Poly/ML component from official repository", |
75394 | 476 |
Scala_Project.here, |
477 |
{ args => |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
478 |
var target_dir = Path.current |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
479 |
var gmp_url = "" |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
480 |
var mingw = MinGW.none |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
481 |
var component_name = "" |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
482 |
var sha1_url = default_sha1_url |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
483 |
var sha1_version = default_sha1_version |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
484 |
var polyml_url = default_polyml_url |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
485 |
var polyml_version = default_polyml_version |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
486 |
var polyml_name = default_polyml_name |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
487 |
var verbose = false |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
488 |
|
75394 | 489 |
val getopts = Getopts(""" |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77510
diff
changeset
|
490 |
Usage: isabelle component_polyml [OPTIONS] [CONFIGURE_OPTIONS] |
65880 | 491 |
|
492 |
Options are: |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
493 |
-D DIR target directory (default ".") |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
494 |
-G URL build GMP library from source: explicit URL or ":" for |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
495 |
""" + standard_gmp_url + """ |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
496 |
-M DIR msys/mingw root specification for Windows |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
497 |
-N NAME component name (default: derived from Poly/ML version) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
498 |
-S URL SHA1 repository archive area |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
499 |
(default: """ + quote(default_sha1_url) + """) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
500 |
-T VERSION SHA1 version (default: """ + quote(default_sha1_version) + """) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
501 |
-U URL Poly/ML repository archive area |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
502 |
(default: """ + quote(default_polyml_url) + """) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
503 |
-V VERSION Poly/ML version (default: """ + quote(default_polyml_version) + """) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
504 |
-W NAME Poly/ML name (default: """ + quote(default_polyml_name) + """) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
505 |
-v verbose |
65880 | 506 |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
507 |
Download and build Poly/ML component from source repositories, with additional |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
508 |
CONFIGURE_OPTIONS. |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
509 |
""", |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
510 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
511 |
"G:" -> (arg => gmp_url = if (arg == ":") standard_gmp_url else arg), |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
512 |
"M:" -> (arg => mingw = MinGW(Path.explode(arg))), |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
513 |
"N:" -> (arg => component_name = arg), |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
514 |
"S:" -> (arg => sha1_url = arg), |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
515 |
"T:" -> (arg => sha1_version = arg), |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
516 |
"U:" -> (arg => polyml_url = arg), |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
517 |
"V:" -> (arg => polyml_version = arg), |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
518 |
"W:" -> (arg => polyml_name = arg), |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
519 |
"v" -> (_ => verbose = true)) |
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
520 |
|
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
521 |
val options = getopts(args) |
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
522 |
|
77510
f5d6cd98b16a
clarified signature: manage "verbose" flag via "progress";
wenzelm
parents:
77191
diff
changeset
|
523 |
val progress = new Console_Progress(verbose = verbose) |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
524 |
val platform_context = Platform_Context(mingw = mingw, progress = progress) |
77190
f6ba88f23135
clarified "isabelle build_polyml": download and build everything for current platform;
wenzelm
parents:
76547
diff
changeset
|
525 |
|
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
526 |
build_polyml(platform_context, options = options, component_name = component_name, |
82463
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
527 |
gmp_url = gmp_url, polyml_url = polyml_url, polyml_version = polyml_version, |
3125fd1ee69c
added option -G to build GMP library from sources;
wenzelm
parents:
82142
diff
changeset
|
528 |
polyml_name = polyml_name, sha1_url = sha1_url, sha1_version = sha1_version, |
82464
7c9fcf2d6706
clarified signature: more explicit type Platform_Context;
wenzelm
parents:
82463
diff
changeset
|
529 |
target_dir = target_dir) |
75394 | 530 |
}) |
64483 | 531 |
} |