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