author | wenzelm |
Sun, 11 Oct 2020 17:17:19 +0200 | |
changeset 72443 | ff5e700ed490 |
parent 72442 | 90868036d693 |
child 72455 | 7bf67a58f54a |
permissions | -rw-r--r-- |
72439 | 1 |
/* Title: Pure/Admin/build_csdp.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Build Isabelle veriT component from official download. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
10 |
object Build_VeriT |
|
11 |
{ |
|
12 |
val default_download_url = "https://verit.loria.fr/distrib/veriT-stable2016.tar.gz" |
|
13 |
||
14 |
||
15 |
/* build veriT */ |
|
16 |
||
17 |
def build_verit( |
|
18 |
download_url: String = default_download_url, |
|
19 |
verbose: Boolean = false, |
|
20 |
progress: Progress = new Progress, |
|
21 |
target_dir: Path = Path.current) |
|
22 |
{ |
|
23 |
Isabelle_System.with_tmp_dir("build")(tmp_dir => |
|
24 |
{ |
|
25 |
/* required commands */ |
|
26 |
||
72443
ff5e700ed490
more robust: ignore existing gmp installation, but let veriT incorporate extern/gmp;
wenzelm
parents:
72442
diff
changeset
|
27 |
List("autoconf", "bison", "flex", "wget").foreach(cmd => |
72439 | 28 |
if (!Isabelle_System.bash(cmd + " --version").ok) error("Missing command: " + cmd)) |
29 |
||
30 |
||
31 |
/* component */ |
|
32 |
||
33 |
val Archive_Name = """^.*?([^/]+)$""".r |
|
34 |
val Version = """^[^-]+-(.+)\.tar.gz$""".r |
|
35 |
||
36 |
val archive_name = |
|
37 |
download_url match { |
|
38 |
case Archive_Name(name) => name |
|
39 |
case _ => error("Failed to determine source archive name from " + quote(download_url)) |
|
40 |
} |
|
41 |
||
42 |
val version = |
|
43 |
archive_name match { |
|
44 |
case Version(version) => version |
|
45 |
case _ => error("Failed to determine component version from " + quote(archive_name)) |
|
46 |
} |
|
47 |
||
48 |
val component_name = "verit-" + version |
|
49 |
val component_dir = Isabelle_System.new_directory(target_dir + Path.basic(component_name)) |
|
50 |
progress.echo("Component " + component_dir) |
|
51 |
||
52 |
||
53 |
/* platform */ |
|
54 |
||
55 |
val platform_name = |
|
56 |
proper_string(Isabelle_System.getenv("ISABELLE_PLATFORM64")) getOrElse |
|
57 |
error("No 64bit platform") |
|
58 |
||
59 |
val platform_dir = Isabelle_System.make_directory(component_dir + Path.basic(platform_name)) |
|
60 |
||
61 |
||
62 |
/* download source */ |
|
63 |
||
64 |
val archive_path = tmp_dir + Path.basic(archive_name) |
|
65 |
Isabelle_System.download(download_url, archive_path, progress = progress) |
|
66 |
||
67 |
Isabelle_System.bash("tar xzf " + File.bash_path(archive_path), cwd = tmp_dir.file).check |
|
72442 | 68 |
val source_name = File.get_dir(tmp_dir) |
72439 | 69 |
|
70 |
Isabelle_System.bash( |
|
71 |
"tar xzf " + archive_path + " && mv " + Bash.string(source_name) + " src", |
|
72 |
cwd = component_dir.file).check |
|
73 |
||
74 |
||
75 |
/* build */ |
|
76 |
||
72440 | 77 |
progress.echo("Building veriT for " + platform_name + " ...") |
72439 | 78 |
|
79 |
val build_dir = tmp_dir + Path.basic(source_name) |
|
80 |
val build_script = |
|
81 |
""" |
|
72443
ff5e700ed490
more robust: ignore existing gmp installation, but let veriT incorporate extern/gmp;
wenzelm
parents:
72442
diff
changeset
|
82 |
autoconf |
ff5e700ed490
more robust: ignore existing gmp installation, but let veriT incorporate extern/gmp;
wenzelm
parents:
72442
diff
changeset
|
83 |
./configure |
ff5e700ed490
more robust: ignore existing gmp installation, but let veriT incorporate extern/gmp;
wenzelm
parents:
72442
diff
changeset
|
84 |
ln -s gmp-local extern/gmp |
ff5e700ed490
more robust: ignore existing gmp installation, but let veriT incorporate extern/gmp;
wenzelm
parents:
72442
diff
changeset
|
85 |
make |
72439 | 86 |
""" |
72443
ff5e700ed490
more robust: ignore existing gmp installation, but let veriT incorporate extern/gmp;
wenzelm
parents:
72442
diff
changeset
|
87 |
progress.bash("set -e\n" + build_script, cwd = build_dir.file, echo = verbose).check |
72439 | 88 |
|
89 |
||
90 |
/* install */ |
|
91 |
||
92 |
File.copy(build_dir + Path.explode("LICENSE"), component_dir) |
|
93 |
File.copy(build_dir + Path.explode("veriT"), platform_dir) |
|
94 |
||
95 |
||
96 |
/* settings */ |
|
97 |
||
98 |
val etc_dir = Isabelle_System.make_directory(component_dir + Path.basic("etc")) |
|
99 |
File.write(etc_dir + Path.basic("settings"), |
|
100 |
"""# -*- shell-script -*- :mode=shellscript: |
|
101 |
||
102 |
VERIT_HOME="$COMPONENT/$ISABELLE_PLATFORM64" |
|
103 |
VERIT_VERSION=""" + quote(version) + """ |
|
104 |
||
105 |
VERIT_SOLVER="$VERIT_HOME/veriT" |
|
106 |
||
107 |
if [ -e "$VERIT_HOME" ] |
|
108 |
then |
|
109 |
VERIT_INSTALLED="yes" |
|
110 |
fi |
|
111 |
""") |
|
112 |
||
113 |
||
114 |
/* README */ |
|
115 |
||
116 |
File.write(component_dir + Path.basic("README"), |
|
117 |
"""This is veriT """ + version + """ from |
|
118 |
""" + download_url + """ |
|
119 |
||
120 |
It has been built from sources like this: |
|
72443
ff5e700ed490
more robust: ignore existing gmp installation, but let veriT incorporate extern/gmp;
wenzelm
parents:
72442
diff
changeset
|
121 |
""" + build_script + """ |
72439 | 122 |
|
72443
ff5e700ed490
more robust: ignore existing gmp installation, but let veriT incorporate extern/gmp;
wenzelm
parents:
72442
diff
changeset
|
123 |
Makarius |
ff5e700ed490
more robust: ignore existing gmp installation, but let veriT incorporate extern/gmp;
wenzelm
parents:
72442
diff
changeset
|
124 |
""" + Date.Format.date(Date.now()) + "\n") |
72439 | 125 |
}) |
126 |
} |
|
127 |
||
128 |
||
129 |
/* Isabelle tool wrapper */ |
|
130 |
||
131 |
val isabelle_tool = |
|
132 |
Isabelle_Tool("build_verit", "build prover component from official download", |
|
133 |
args => |
|
134 |
{ |
|
135 |
var target_dir = Path.current |
|
136 |
var download_url = default_download_url |
|
137 |
var verbose = false |
|
138 |
||
139 |
val getopts = Getopts(""" |
|
140 |
Usage: isabelle build_verit [OPTIONS] |
|
141 |
||
142 |
Options are: |
|
143 |
-D DIR target directory (default ".") |
|
144 |
-U URL download URL |
|
145 |
(default: """" + default_download_url + """") |
|
146 |
-v verbose |
|
147 |
||
148 |
Build prover component from official download. |
|
149 |
""", |
|
150 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
|
151 |
"U:" -> (arg => download_url = arg), |
|
152 |
"v" -> (_ => verbose = true)) |
|
153 |
||
154 |
val more_args = getopts(args) |
|
155 |
if (more_args.nonEmpty) getopts.usage() |
|
156 |
||
157 |
val progress = new Console_Progress() |
|
158 |
||
159 |
build_verit(download_url = download_url, verbose = verbose, progress = progress, |
|
160 |
target_dir = target_dir) |
|
161 |
}) |
|
162 |
} |