author | wenzelm |
Wed, 16 Dec 2020 23:11:54 +0100 | |
changeset 72940 | 4a652d3f4522 |
parent 72939 | dc858da93233 |
child 72971 | 162b71f7e554 |
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 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
10 |
object Build_Zipperposition |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
11 |
{ |
72939
dc858da93233
updated to zipperposition-2.0 and ocaml-4.07, which is required for it;
wenzelm
parents:
72763
diff
changeset
|
12 |
val default_version = "2.0" |
72466
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 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
15 |
/* build Zipperposition */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
16 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
17 |
def build_zipperposition( |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
18 |
version: String = default_version, |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
19 |
verbose: Boolean = false, |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
20 |
progress: Progress = new Progress, |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
21 |
target_dir: Path = Path.current) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
22 |
{ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
23 |
Isabelle_System.with_tmp_dir("build")(build_dir => |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
24 |
{ |
72940 | 25 |
if (!Platform.is_windows) Isabelle_System.require_command("patchelf") |
72471 | 26 |
|
27 |
||
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
28 |
/* component */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
29 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
30 |
val component_name = "zipperposition-" + version |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
31 |
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
|
32 |
progress.echo("Component " + component_dir) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
33 |
|
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 |
/* platform */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
36 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
37 |
val platform_name = |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
38 |
proper_string(Isabelle_System.getenv("ISABELLE_PLATFORM64")) getOrElse |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
39 |
error("No 64bit platform") |
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 |
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
|
42 |
|
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 |
/* build */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
45 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
46 |
progress.echo("OCaml/OPAM setup ...") |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
47 |
progress.bash("isabelle ocaml_setup", echo = verbose).check |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
48 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
49 |
progress.echo("Building Zipperposition for " + platform_name + " ...") |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
50 |
progress.bash(cwd = build_dir.file, echo = verbose, |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
51 |
script = "isabelle_opam install -y --destdir=" + File.bash_path(build_dir) + |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
52 |
" zipperposition=" + Bash.string(version)).check |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
53 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
54 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
55 |
/* install */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
56 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
57 |
File.copy(build_dir + Path.explode("doc/zipperposition/LICENSE"), component_dir) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
58 |
|
72467
0822ff79eed8
proper support for Windows/Cygwin: "zipperposition" vs. "zipperposition.exe";
wenzelm
parents:
72466
diff
changeset
|
59 |
val prg_path = Path.basic("zipperposition") |
0822ff79eed8
proper support for Windows/Cygwin: "zipperposition" vs. "zipperposition.exe";
wenzelm
parents:
72466
diff
changeset
|
60 |
val exe_path = prg_path.platform_exe |
0822ff79eed8
proper support for Windows/Cygwin: "zipperposition" vs. "zipperposition.exe";
wenzelm
parents:
72466
diff
changeset
|
61 |
File.copy(build_dir + Path.basic("bin") + prg_path, platform_dir + exe_path) |
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
62 |
|
72940 | 63 |
if (!Platform.is_windows) { |
64 |
Executable.libraries_closure( |
|
65 |
platform_dir + exe_path, filter = Set("libgmp"), patchelf = true) |
|
66 |
} |
|
72466
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 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
69 |
/* settings */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
70 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
71 |
val etc_dir = Isabelle_System.make_directory(component_dir + Path.basic("etc")) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
72 |
File.write(etc_dir + Path.basic("settings"), |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
73 |
"""# -*- shell-script -*- :mode=shellscript: |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
74 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
75 |
ISABELLE_ZIPPERPOSITION="$COMPONENT/$ISABELLE_PLATFORM64/zipperposition" |
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 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
79 |
/* README */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
80 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
81 |
File.write(component_dir + Path.basic("README"), |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
82 |
"""This is Zipperposition """ + version + """ from the OCaml/OPAM repository. |
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 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
85 |
Makarius |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
86 |
""" + Date.Format.date(Date.now()) + "\n") |
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 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
91 |
/* Isabelle tool wrapper */ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
92 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
93 |
val isabelle_tool = |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
94 |
Isabelle_Tool("build_zipperposition", "build prover component from OPAM repository", |
72763 | 95 |
Scala_Project.here, args => |
72466
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
96 |
{ |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
97 |
var target_dir = Path.current |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
98 |
var version = default_version |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
99 |
var verbose = false |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
100 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
101 |
val getopts = Getopts(""" |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
102 |
Usage: isabelle build_zipperposition [OPTIONS] |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
103 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
104 |
Options are: |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
105 |
-D DIR target directory (default ".") |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
106 |
-V VERSION version (default: """" + default_version + """") |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
107 |
-v verbose |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
108 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
109 |
Build prover component from OPAM repository. |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
110 |
""", |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
111 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
112 |
"V:" -> (arg => version = arg), |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
113 |
"v" -> (_ => verbose = true)) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
114 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
115 |
val more_args = getopts(args) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
116 |
if (more_args.nonEmpty) getopts.usage() |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
117 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
118 |
val progress = new Console_Progress() |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
119 |
|
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
120 |
build_zipperposition(version = version, verbose = verbose, progress = progress, |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
121 |
target_dir = target_dir) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
122 |
}) |
04403e1ef176
build Isabelle Zipperposition component from OPAM repository;
wenzelm
parents:
diff
changeset
|
123 |
} |