author | wenzelm |
Fri, 01 Apr 2022 23:19:12 +0200 | |
changeset 75394 | 42267c650205 |
parent 75393 | 87ebf5a50283 |
child 76518 | b30b8e23383c |
permissions | -rw-r--r-- |
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
1 |
/* Title: Pure/Admin/build_zipperposition.scala |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
3 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
4 |
Build Isabelle Zipperposition component from OPAM repository. |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
6 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
8 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
9 |
|
75393 | 10 |
object Build_Zipperposition { |
74368 | 11 |
val default_version = "2.1" |
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
12 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
13 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
14 |
/* build Zipperposition */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
15 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
16 |
def build_zipperposition( |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
17 |
version: String = default_version, |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
18 |
verbose: Boolean = false, |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
19 |
progress: Progress = new Progress, |
75393 | 20 |
target_dir: Path = Path.current |
21 |
): Unit = { |
|
75394 | 22 |
Isabelle_System.with_tmp_dir("build") { build_dir => |
74457
4e317412db48
no patchelf on macOS (undetected due to cached executables?);
wenzelm
parents:
74368
diff
changeset
|
23 |
if (Platform.is_linux) Isabelle_System.require_command("patchelf") |
72471 | 24 |
|
25 |
||
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
26 |
/* component */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
27 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
28 |
val component_name = "zipperposition-" + version |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
29 |
val component_dir = Isabelle_System.new_directory(target_dir + Path.basic(component_name)) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
30 |
progress.echo("Component " + component_dir) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
31 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
32 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
33 |
/* platform */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
34 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
35 |
val platform_name = |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
36 |
proper_string(Isabelle_System.getenv("ISABELLE_PLATFORM64")) getOrElse |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
37 |
error("No 64bit platform") |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
38 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
39 |
val platform_dir = Isabelle_System.make_directory(component_dir + Path.basic(platform_name)) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
40 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
41 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
42 |
/* build */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
43 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
44 |
progress.echo("OCaml/OPAM setup ...") |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
45 |
progress.bash("isabelle ocaml_setup", echo = verbose).check |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
46 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
47 |
progress.echo("Building Zipperposition for " + platform_name + " ...") |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
48 |
progress.bash(cwd = build_dir.file, echo = verbose, |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
49 |
script = "isabelle_opam install -y --destdir=" + File.bash_path(build_dir) + |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
50 |
" zipperposition=" + Bash.string(version)).check |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
51 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
52 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
53 |
/* install */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
54 |
|
73317 | 55 |
Isabelle_System.copy_file(build_dir + Path.explode("doc/zipperposition/LICENSE"), |
56 |
component_dir) |
|
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
57 |
|
72467
0822ff79eed8
proper support for Windows/Cygwin: "zipperposition" vs. "zipperposition.exe";
wenzelm
parents:
72466
diff
changeset
|
58 |
val prg_path = Path.basic("zipperposition") |
0822ff79eed8
proper support for Windows/Cygwin: "zipperposition" vs. "zipperposition.exe";
wenzelm
parents:
72466
diff
changeset
|
59 |
val exe_path = prg_path.platform_exe |
73317 | 60 |
Isabelle_System.copy_file(build_dir + Path.basic("bin") + prg_path, platform_dir + exe_path) |
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
61 |
|
72940 | 62 |
if (!Platform.is_windows) { |
63 |
Executable.libraries_closure( |
|
64 |
platform_dir + exe_path, filter = Set("libgmp"), patchelf = true) |
|
65 |
} |
|
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
66 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
67 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
68 |
/* settings */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
69 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
70 |
val etc_dir = Isabelle_System.make_directory(component_dir + Path.basic("etc")) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
71 |
File.write(etc_dir + Path.basic("settings"), |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
72 |
"""# -*- shell-script -*- :mode=shellscript: |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
73 |
|
72971
162b71f7e554
rebuild component with proper ZIPPERPOSITION_HOME for sledgehammer;
wenzelm
parents:
72940
diff
changeset
|
74 |
ZIPPERPOSITION_HOME="$COMPONENT/$ISABELLE_PLATFORM64" |
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
75 |
""") |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
76 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
77 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
78 |
/* README */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
79 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
80 |
File.write(component_dir + Path.basic("README"), |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
81 |
"""This is Zipperposition """ + version + """ from the OCaml/OPAM repository. |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
82 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
83 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
84 |
Makarius |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
85 |
""" + Date.Format.date(Date.now()) + "\n") |
75394 | 86 |
} |
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
87 |
} |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
88 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
89 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
90 |
/* Isabelle tool wrapper */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
91 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
92 |
val isabelle_tool = |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
93 |
Isabelle_Tool("build_zipperposition", "build prover component from OPAM repository", |
75394 | 94 |
Scala_Project.here, |
95 |
{ args => |
|
96 |
var target_dir = Path.current |
|
97 |
var version = default_version |
|
98 |
var verbose = false |
|
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
99 |
|
75394 | 100 |
val getopts = Getopts(""" |
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
101 |
Usage: isabelle build_zipperposition [OPTIONS] |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
102 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
103 |
Options are: |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
104 |
-D DIR target directory (default ".") |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
105 |
-V VERSION version (default: """" + default_version + """") |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
106 |
-v verbose |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
107 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
108 |
Build prover component from OPAM repository. |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
109 |
""", |
75394 | 110 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
111 |
"V:" -> (arg => version = arg), |
|
112 |
"v" -> (_ => verbose = true)) |
|
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
113 |
|
75394 | 114 |
val more_args = getopts(args) |
115 |
if (more_args.nonEmpty) getopts.usage() |
|
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
116 |
|
75394 | 117 |
val progress = new Console_Progress() |
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
118 |
|
75394 | 119 |
build_zipperposition(version = version, verbose = verbose, progress = progress, |
120 |
target_dir = target_dir) |
|
121 |
}) |
|
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
122 |
} |