author | wenzelm |
Mon, 05 Oct 2020 22:23:17 +0200 | |
changeset 72377 | c7741f767e3e |
parent 72376 | 04bce3478688 |
child 72378 | 075f3cbc7546 |
permissions | -rw-r--r-- |
64483 | 1 |
/* Title: Pure/Admin/build_polyml.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Build Poly/ML from sources. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
69704 | 10 |
import scala.util.matching.Regex |
11 |
||
12 |
||
64483 | 13 |
object Build_PolyML |
14 |
{ |
|
65880 | 15 |
/** platform-specific build **/ |
64496 | 16 |
|
64483 | 17 |
sealed case class Platform_Info( |
18 |
options: List[String] = Nil, |
|
64487 | 19 |
setup: String = "", |
69704 | 20 |
copy_files: List[String] = Nil, |
21 |
ldd_pattern: Option[(String, Regex)] = None) |
|
64483 | 22 |
|
23 |
private val platform_info = Map( |
|
69704 | 24 |
"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
|
25 |
Platform_Info( |
69704 | 26 |
options = List("LDFLAGS=-Wl,-rpath,_DUMMY_"), |
27 |
ldd_pattern = Some(("ldd", """\s*libgmp.*=>\s*(\S+).*""".r))), |
|
28 |
"darwin" -> |
|
64483 | 29 |
Platform_Info( |
30 |
options = |
|
64484 | 31 |
List("--build=x86_64-darwin", "CFLAGS=-arch x86_64 -O3 -I../libffi/include", |
32 |
"CXXFLAGS=-arch x86_64 -O3 -I../libffi/include", "CCASFLAGS=-arch x86_64", |
|
67600
d515b6140381
no --enable-shared for x86_64-darwin: does not work on some test machine;
wenzelm
parents:
67599
diff
changeset
|
33 |
"LDFLAGS=-segprot POLY rwx rwx"), |
69704 | 34 |
setup = "PATH=/usr/bin:/bin:/usr/sbin:/sbin", |
35 |
ldd_pattern = Some(("otool -L", """\s*(\S+lib(?:polyml|gmp).*dylib).*""".r))), |
|
36 |
"windows" -> |
|
64483 | 37 |
Platform_Info( |
38 |
options = |
|
67597 | 39 |
List("--host=x86_64-w64-mingw32", "CPPFLAGS=-I/mingw64/include", "--disable-windows-gui"), |
64494 | 40 |
setup = |
41 |
"""PATH=/usr/bin:/bin:/mingw64/bin |
|
71117
2f6b092bbd25
updated MinGW installation: requires Cygwin from Isabelle2018 to avoid problems with address relocation;
wenzelm
parents:
70977
diff
changeset
|
42 |
export CONFIG_SITE=/mingw64/etc/config.site""", |
64483 | 43 |
copy_files = |
64504 | 44 |
List("$MSYS/mingw64/bin/libgcc_s_seh-1.dll", |
45 |
"$MSYS/mingw64/bin/libgmp-10.dll", |
|
71117
2f6b092bbd25
updated MinGW installation: requires Cygwin from Isabelle2018 to avoid problems with address relocation;
wenzelm
parents:
70977
diff
changeset
|
46 |
"$MSYS/mingw64/bin/libstdc++-6.dll", |
2f6b092bbd25
updated MinGW installation: requires Cygwin from Isabelle2018 to avoid problems with address relocation;
wenzelm
parents:
70977
diff
changeset
|
47 |
"$MSYS/mingw64/bin/libwinpthread-1.dll"))) |
64483 | 48 |
|
49 |
def build_polyml( |
|
64489 | 50 |
root: Path, |
64495 | 51 |
sha1_root: Option[Path] = None, |
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71686
diff
changeset
|
52 |
progress: Progress = new Progress, |
64493 | 53 |
arch_64: Boolean = false, |
64485
e996c0a5eca9
support other bash executable (notably for msys on Windows);
wenzelm
parents:
64484
diff
changeset
|
54 |
options: List[String] = Nil, |
65880 | 55 |
msys_root: Option[Path] = None) |
64483 | 56 |
{ |
64489 | 57 |
if (!((root + Path.explode("configure")).is_file && (root + Path.explode("PolyML")).is_dir)) |
58 |
error("Bad Poly/ML root directory: " + root) |
|
64483 | 59 |
|
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
60 |
val platform = Isabelle_Platform.self |
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
61 |
val platform_arch = |
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
62 |
if (arch_64) platform.arch_64 |
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
63 |
else if (platform.is_intel) "x86_64_32" |
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
64 |
else platform.arch_32 |
69704 | 65 |
|
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
66 |
val polyml_platform = platform_arch + "-" + platform.os_name |
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
67 |
val sha1_platform = platform.arch_64 + "-" + platform.os_name |
64493 | 68 |
|
64483 | 69 |
val info = |
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
70 |
platform_info.getOrElse(platform.os_name, |
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
71 |
error("Bad OS platform: " + quote(platform.os_name))) |
64483 | 72 |
|
64504 | 73 |
val settings = |
74 |
msys_root match { |
|
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
75 |
case None if platform.is_windows => |
64504 | 76 |
error("Windows requires specification of msys root directory") |
77 |
case None => Isabelle_System.settings() |
|
78 |
case Some(msys) => Isabelle_System.settings() + ("MSYS" -> msys.expand.implode) |
|
79 |
} |
|
64492 | 80 |
|
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
81 |
if (platform.is_linux && !Isabelle_System.bash("chrpath -v").ok) { |
70977 | 82 |
error("""Missing "chrpath" executable on Linux""") |
83 |
} |
|
84 |
||
64491 | 85 |
|
64495 | 86 |
/* bash */ |
87 |
||
64504 | 88 |
def bash( |
89 |
cwd: Path, script: String, redirect: Boolean = false, echo: Boolean = false): Process_Result = |
|
90 |
{ |
|
91 |
val script1 = |
|
92 |
msys_root match { |
|
93 |
case None => script |
|
94 |
case Some(msys) => |
|
95 |
File.bash_path(msys + Path.explode("usr/bin/bash")) + " -c " + Bash.string(script) |
|
96 |
} |
|
97 |
progress.bash(script1, cwd = cwd.file, redirect = redirect, echo = echo) |
|
98 |
} |
|
64495 | 99 |
|
100 |
||
64491 | 101 |
/* configure and make */ |
102 |
||
64483 | 103 |
val configure_options = |
67783
839de121665c
more robust build: prevent problems seen with Poly/ML eb94e2820013 on Mac OS X;
wenzelm
parents:
67609
diff
changeset
|
104 |
List("--disable-shared", "--enable-intinf-as-int", "--with-gmp") ::: |
69704 | 105 |
info.options ::: options ::: (if (arch_64) Nil else List("--enable-compact32bit")) |
64483 | 106 |
|
64495 | 107 |
bash(root, |
64487 | 108 |
info.setup + "\n" + |
64485
e996c0a5eca9
support other bash executable (notably for msys on Windows);
wenzelm
parents:
64484
diff
changeset
|
109 |
""" |
e996c0a5eca9
support other bash executable (notably for msys on Windows);
wenzelm
parents:
64484
diff
changeset
|
110 |
[ -f Makefile ] && make distclean |
e996c0a5eca9
support other bash executable (notably for msys on Windows);
wenzelm
parents:
64484
diff
changeset
|
111 |
{ |
e996c0a5eca9
support other bash executable (notably for msys on Windows);
wenzelm
parents:
64484
diff
changeset
|
112 |
./configure --prefix="$PWD/target" """ + Bash.strings(configure_options) + """ |
e996c0a5eca9
support other bash executable (notably for msys on Windows);
wenzelm
parents:
64484
diff
changeset
|
113 |
rm -rf target |
e996c0a5eca9
support other bash executable (notably for msys on Windows);
wenzelm
parents:
64484
diff
changeset
|
114 |
make compiler && make compiler && make install |
e996c0a5eca9
support other bash executable (notably for msys on Windows);
wenzelm
parents:
64484
diff
changeset
|
115 |
} || { echo "Build failed" >&2; exit 2; } |
64501 | 116 |
""", redirect = true, echo = true).check |
64485
e996c0a5eca9
support other bash executable (notably for msys on Windows);
wenzelm
parents:
64484
diff
changeset
|
117 |
|
64495 | 118 |
val ldd_files = |
66998 | 119 |
{ |
69704 | 120 |
info.ldd_pattern match { |
66998 | 121 |
case Some((ldd, pattern)) => |
122 |
val lines = bash(root, ldd + " target/bin/poly").check.out_lines |
|
123 |
for { line <- lines; List(lib) <- pattern.unapplySeq(line) } yield lib |
|
124 |
case None => Nil |
|
64491 | 125 |
} |
66998 | 126 |
} |
64491 | 127 |
|
128 |
||
64495 | 129 |
/* sha1 library */ |
130 |
||
131 |
val sha1_files = |
|
132 |
if (sha1_root.isDefined) { |
|
133 |
val dir1 = sha1_root.get |
|
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
134 |
bash(dir1, "./build " + sha1_platform, redirect = true, echo = true).check |
64505 | 135 |
|
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
136 |
val dir2 = dir1 + Path.explode(sha1_platform) |
64495 | 137 |
File.read_dir(dir2).map(entry => dir2.implode + "/" + entry) |
138 |
} |
|
139 |
else Nil |
|
140 |
||
141 |
||
64491 | 142 |
/* target */ |
64484 | 143 |
|
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
144 |
val target = Path.explode(polyml_platform) |
64488 | 145 |
Isabelle_System.rm_tree(target) |
72375 | 146 |
Isabelle_System.make_directory(target) |
64483 | 147 |
|
67592
66253039d5ca
enforce shared libpoly on all platforms, with File.copy before File.move;
wenzelm
parents:
67589
diff
changeset
|
148 |
for (file <- info.copy_files ::: ldd_files ::: sha1_files) |
66253039d5ca
enforce shared libpoly on all platforms, with File.copy before File.move;
wenzelm
parents:
67589
diff
changeset
|
149 |
File.copy(Path.explode(file).expand_env(settings), target) |
66253039d5ca
enforce shared libpoly on all platforms, with File.copy before File.move;
wenzelm
parents:
67589
diff
changeset
|
150 |
|
64483 | 151 |
for { |
64484 | 152 |
d <- List("target/bin", "target/lib") |
64489 | 153 |
dir = root + Path.explode(d) |
64483 | 154 |
entry <- File.read_dir(dir) |
155 |
} File.move(dir + Path.explode(entry), target) |
|
156 |
||
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
|
157 |
|
67584 | 158 |
/* poly: library path */ |
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
|
159 |
|
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
160 |
if (platform.is_linux) { |
67582
bf5c69acf2be
built-in library path for (optional) libgmp on macos;
wenzelm
parents:
67581
diff
changeset
|
161 |
bash(target, "chrpath -r '$ORIGIN' poly", echo = true).check |
bf5c69acf2be
built-in library path for (optional) libgmp on macos;
wenzelm
parents:
67581
diff
changeset
|
162 |
} |
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
163 |
else if (platform.is_macos) { |
67582
bf5c69acf2be
built-in library path for (optional) libgmp on macos;
wenzelm
parents:
67581
diff
changeset
|
164 |
for (file <- ldd_files) { |
bf5c69acf2be
built-in library path for (optional) libgmp on macos;
wenzelm
parents:
67581
diff
changeset
|
165 |
bash(target, |
bf5c69acf2be
built-in library path for (optional) libgmp on macos;
wenzelm
parents:
67581
diff
changeset
|
166 |
"""install_name_tool -change """ + Bash.string(file) + " " + |
69366 | 167 |
Bash.string("@executable_path/" + Path.explode(file).file_name) + " poly").check |
67582
bf5c69acf2be
built-in library path for (optional) libgmp on macos;
wenzelm
parents:
67581
diff
changeset
|
168 |
} |
bf5c69acf2be
built-in library path for (optional) libgmp on macos;
wenzelm
parents:
67581
diff
changeset
|
169 |
} |
67584 | 170 |
|
171 |
||
172 |
/* polyc: directory prefix */ |
|
173 |
||
174 |
{ |
|
175 |
val polyc_path = target + Path.explode("polyc") |
|
67587 | 176 |
|
177 |
val Header = "#! */bin/sh".r |
|
67584 | 178 |
val polyc_patched = |
179 |
split_lines(File.read(polyc_path)) match { |
|
67587 | 180 |
case Header() :: lines => |
181 |
val lines1 = |
|
182 |
lines.map(line => |
|
183 |
if (line.startsWith("prefix=")) "prefix=\"$(cd \"$(dirname \"$0\")\"; pwd)\"" |
|
184 |
else if (line.startsWith("BINDIR=")) "BINDIR=\"$prefix\"" |
|
67584 | 185 |
else if (line.startsWith("LIBDIR=")) "LIBDIR=\"$prefix\"" |
186 |
else line) |
|
67587 | 187 |
cat_lines("#!/usr/bin/env bash" ::lines1) |
67584 | 188 |
case lines => |
67587 | 189 |
error(cat_lines("Cannot patch polyc -- undetected header:" :: lines.take(3))) |
67584 | 190 |
} |
191 |
File.write(polyc_path, polyc_patched) |
|
192 |
} |
|
64483 | 193 |
} |
194 |
||
195 |
||
64496 | 196 |
|
65880 | 197 |
/** skeleton for component **/ |
198 |
||
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
199 |
private def extract_sources(source_archive: Path, component_dir: Path) = |
65880 | 200 |
{ |
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
201 |
if (source_archive.get_ext == "zip") { |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
202 |
Isabelle_System.bash( |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
203 |
"unzip -x " + File.bash_path(source_archive.absolute), cwd = component_dir.file).check |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
204 |
} |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
205 |
else { |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
206 |
Isabelle_System.gnutar("-xzf " + File.bash_path(source_archive), dir = component_dir).check |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
207 |
} |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
208 |
|
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
209 |
val src_dir = component_dir + Path.explode("src") |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
210 |
File.read_dir(component_dir) match { |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
211 |
case List(s) => File.move(component_dir + Path.basic(s), src_dir) |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
212 |
case _ => error("Source archive contains multiple directories") |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
213 |
} |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
214 |
|
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
215 |
val lines = split_lines(File.read(src_dir + Path.explode("RootX86.ML"))) |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
216 |
val ml_files = |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
217 |
for { |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
218 |
line <- lines |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
219 |
rest <- Library.try_unprefix("use", line) |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
220 |
} yield "ML_file" + rest |
65880 | 221 |
|
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
222 |
File.write(src_dir + Path.explode("ROOT.ML"), |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
223 |
"""(* Poly/ML Compiler root file. |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
224 |
|
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
225 |
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
|
226 |
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
|
227 |
not affect the running ML session. *) |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
228 |
""" + ml_files.mkString("\n", "\n", "\n")) |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
229 |
} |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
230 |
|
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
231 |
def build_polyml_component( |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
232 |
source_archive: Path, |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
233 |
component_dir: Path, |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
234 |
sha1_root: Option[Path] = None) |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
235 |
{ |
72377 | 236 |
Isabelle_System.new_directory(component_dir) |
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
237 |
extract_sources(source_archive, component_dir) |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
238 |
|
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
239 |
File.copy(Path.explode("~~/Admin/polyml/README"), component_dir) |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
240 |
|
72376 | 241 |
val etc_dir = Isabelle_System.make_directory(component_dir + Path.explode("etc")) |
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
242 |
File.copy(Path.explode("~~/Admin/polyml/settings"), etc_dir) |
64483 | 243 |
|
65880 | 244 |
sha1_root match { |
245 |
case Some(dir) => |
|
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
246 |
Mercurial.repository(dir).archive(File.standard_path(component_dir + Path.explode("sha1"))) |
65880 | 247 |
case None => |
248 |
} |
|
249 |
} |
|
250 |
||
251 |
||
252 |
||
253 |
/** Isabelle tool wrappers **/ |
|
254 |
||
255 |
val isabelle_tool1 = |
|
256 |
Isabelle_Tool("build_polyml", "build Poly/ML from sources", args => |
|
64500
159ea1055b39
back to regular Isabelle tool (reverting abc34a149690);
wenzelm
parents:
64499
diff
changeset
|
257 |
{ |
71686
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
258 |
var msys_root: Option[Path] = None |
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
259 |
var arch_64 = Isabelle_Platform.self.is_arm |
71686
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
260 |
var sha1_root: Option[Path] = None |
64483 | 261 |
|
71686
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
262 |
val getopts = Getopts(""" |
64489 | 263 |
Usage: isabelle build_polyml [OPTIONS] ROOT [CONFIGURE_OPTIONS] |
64483 | 264 |
|
265 |
Options are: |
|
64504 | 266 |
-M DIR msys root directory (for Windows) |
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
267 |
-m ARCH processor architecture (32 or 64, default: """ + |
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
268 |
(if (arch_64) "64" else "32") + """) |
69691 | 269 |
-s DIR sha1 sources, see https://isabelle.sketis.net/repos/sha1 |
64483 | 270 |
|
64499 | 271 |
Build Poly/ML in the ROOT directory of its sources, with additional |
67593 | 272 |
CONFIGURE_OPTIONS (e.g. --without-gmp). |
64483 | 273 |
""", |
71686
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
274 |
"M:" -> (arg => msys_root = Some(Path.explode(arg))), |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
275 |
"m:" -> |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
276 |
{ |
72352
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
277 |
case "32" => arch_64 = false |
f4bd6f123fdf
more systematic platform support, including arm64-linux;
wenzelm
parents:
72351
diff
changeset
|
278 |
case "64" => arch_64 = true |
71686
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
279 |
case bad => error("Bad processor architecture: " + quote(bad)) |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
280 |
}, |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
281 |
"s:" -> (arg => sha1_root = Some(Path.explode(arg)))) |
64483 | 282 |
|
71686
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
283 |
val more_args = getopts(args) |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
284 |
val (root, options) = |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
285 |
more_args match { |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
286 |
case root :: options => (Path.explode(root), options) |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
287 |
case Nil => getopts.usage() |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
288 |
} |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
289 |
build_polyml(root, sha1_root = sha1_root, progress = new Console_Progress, |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
290 |
arch_64 = arch_64, options = options, msys_root = msys_root) |
69277
258bef08b31e
support for user-defined Isabelle/Scala command-line tools;
wenzelm
parents:
67783
diff
changeset
|
291 |
}) |
65880 | 292 |
|
293 |
val isabelle_tool2 = |
|
294 |
Isabelle_Tool("build_polyml_component", "make skeleton for Poly/ML component", args => |
|
295 |
{ |
|
71686
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
296 |
var sha1_root: Option[Path] = None |
65880 | 297 |
|
71686
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
298 |
val getopts = Getopts(""" |
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
299 |
Usage: isabelle build_polyml_component [OPTIONS] SOURCE_ARCHIVE COMPONENT_DIR |
65880 | 300 |
|
301 |
Options are: |
|
69691 | 302 |
-s DIR sha1 sources, see https://isabelle.sketis.net/repos/sha1 |
65880 | 303 |
|
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
304 |
Make skeleton for Poly/ML component, based on official source archive |
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
305 |
(zip or tar.gz). |
65880 | 306 |
""", |
71686
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
307 |
"s:" -> (arg => sha1_root = Some(Path.explode(arg)))) |
65880 | 308 |
|
71686
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
309 |
val more_args = getopts(args) |
71396
c1c61d0d8e7c
clarified build_polyml_component: include IDE entry point for ML compiler;
wenzelm
parents:
71117
diff
changeset
|
310 |
|
71686
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
311 |
val (source_archive, component_dir) = |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
312 |
more_args match { |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
313 |
case List(archive, dir) => (Path.explode(archive), Path.explode(dir)) |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
314 |
case _ => getopts.usage() |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
315 |
} |
eb44cf7ae926
tuned -- Command_Line.tool is already part of Isabelle_Tool;
wenzelm
parents:
71632
diff
changeset
|
316 |
build_polyml_component(source_archive, component_dir, sha1_root = sha1_root) |
69277
258bef08b31e
support for user-defined Isabelle/Scala command-line tools;
wenzelm
parents:
67783
diff
changeset
|
317 |
}) |
64483 | 318 |
} |