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 |
/* flags */
|
|
16 |
|
|
17 |
sealed case class Flags(platform: String, configure: String = "")
|
|
18 |
{
|
|
19 |
def print: Option[String] =
|
|
20 |
if (configure.isEmpty) None
|
|
21 |
else Some(" * " + platform + ":\n ./configure " + configure)
|
|
22 |
}
|
|
23 |
|
|
24 |
val build_flags: List[Flags] =
|
|
25 |
List(
|
|
26 |
Flags("arm64-linux", configure = "--enable-static"),
|
|
27 |
Flags("x86_64-linux", configure = "--enable-static"),
|
|
28 |
Flags("x86_64-darwin"),
|
|
29 |
Flags("x86_64-cygwin"))
|
|
30 |
|
|
31 |
|
|
32 |
/* build veriT */
|
|
33 |
|
|
34 |
def build_verit(
|
|
35 |
download_url: String = default_download_url,
|
|
36 |
verbose: Boolean = false,
|
|
37 |
progress: Progress = new Progress,
|
|
38 |
target_dir: Path = Path.current)
|
|
39 |
{
|
|
40 |
Isabelle_System.with_tmp_dir("build")(tmp_dir =>
|
|
41 |
{
|
|
42 |
/* required commands */
|
|
43 |
|
|
44 |
List("autoconf", "bison", "flex").foreach(cmd =>
|
|
45 |
if (!Isabelle_System.bash(cmd + " --version").ok) error("Missing command: " + cmd))
|
|
46 |
|
|
47 |
|
|
48 |
/* component */
|
|
49 |
|
|
50 |
val Archive_Name = """^.*?([^/]+)$""".r
|
|
51 |
val Version = """^[^-]+-(.+)\.tar.gz$""".r
|
|
52 |
|
|
53 |
val archive_name =
|
|
54 |
download_url match {
|
|
55 |
case Archive_Name(name) => name
|
|
56 |
case _ => error("Failed to determine source archive name from " + quote(download_url))
|
|
57 |
}
|
|
58 |
|
|
59 |
val version =
|
|
60 |
archive_name match {
|
|
61 |
case Version(version) => version
|
|
62 |
case _ => error("Failed to determine component version from " + quote(archive_name))
|
|
63 |
}
|
|
64 |
|
|
65 |
val component_name = "verit-" + version
|
|
66 |
val component_dir = Isabelle_System.new_directory(target_dir + Path.basic(component_name))
|
|
67 |
progress.echo("Component " + component_dir)
|
|
68 |
|
|
69 |
|
|
70 |
/* platform */
|
|
71 |
|
|
72 |
val platform_name =
|
|
73 |
proper_string(Isabelle_System.getenv("ISABELLE_PLATFORM64")) getOrElse
|
|
74 |
error("No 64bit platform")
|
|
75 |
|
|
76 |
val platform_dir = Isabelle_System.make_directory(component_dir + Path.basic(platform_name))
|
|
77 |
|
|
78 |
|
|
79 |
/* download source */
|
|
80 |
|
|
81 |
val archive_path = tmp_dir + Path.basic(archive_name)
|
|
82 |
Isabelle_System.download(download_url, archive_path, progress = progress)
|
|
83 |
|
|
84 |
Isabelle_System.bash("tar xzf " + File.bash_path(archive_path), cwd = tmp_dir.file).check
|
72442
|
85 |
val source_name = File.get_dir(tmp_dir)
|
72439
|
86 |
|
|
87 |
Isabelle_System.bash(
|
|
88 |
"tar xzf " + archive_path + " && mv " + Bash.string(source_name) + " src",
|
|
89 |
cwd = component_dir.file).check
|
|
90 |
|
|
91 |
|
|
92 |
/* build */
|
|
93 |
|
72440
|
94 |
progress.echo("Building veriT for " + platform_name + " ...")
|
72439
|
95 |
|
|
96 |
val build_dir = tmp_dir + Path.basic(source_name)
|
|
97 |
|
|
98 |
val platform_build_flags =
|
|
99 |
build_flags.find(flags => flags.platform == platform_name) match {
|
|
100 |
case None => error("No build flags for platform " + quote(platform_name))
|
|
101 |
case Some(flags) => flags
|
|
102 |
}
|
|
103 |
|
|
104 |
val build_script =
|
|
105 |
"""
|
|
106 |
set -e
|
|
107 |
autoconf
|
|
108 |
./configure """ + platform_build_flags.configure + """
|
|
109 |
make
|
|
110 |
"""
|
|
111 |
progress.bash(build_script, cwd = build_dir.file, echo = verbose).check
|
|
112 |
|
|
113 |
|
|
114 |
/* install */
|
|
115 |
|
|
116 |
File.copy(build_dir + Path.explode("LICENSE"), component_dir)
|
|
117 |
File.copy(build_dir + Path.explode("veriT"), platform_dir)
|
|
118 |
|
|
119 |
|
|
120 |
/* settings */
|
|
121 |
|
|
122 |
val etc_dir = Isabelle_System.make_directory(component_dir + Path.basic("etc"))
|
|
123 |
File.write(etc_dir + Path.basic("settings"),
|
|
124 |
"""# -*- shell-script -*- :mode=shellscript:
|
|
125 |
|
|
126 |
VERIT_HOME="$COMPONENT/$ISABELLE_PLATFORM64"
|
|
127 |
VERIT_VERSION=""" + quote(version) + """
|
|
128 |
|
|
129 |
VERIT_SOLVER="$VERIT_HOME/veriT"
|
|
130 |
|
|
131 |
if [ -e "$VERIT_HOME" ]
|
|
132 |
then
|
|
133 |
VERIT_INSTALLED="yes"
|
|
134 |
fi
|
|
135 |
""")
|
|
136 |
|
|
137 |
|
|
138 |
/* README */
|
|
139 |
|
|
140 |
File.write(component_dir + Path.basic("README"),
|
|
141 |
"""This is veriT """ + version + """ from
|
|
142 |
""" + download_url + """
|
|
143 |
|
|
144 |
It has been built from sources like this:
|
|
145 |
|
|
146 |
autoconf && ./configure && make
|
|
147 |
|
|
148 |
Some platforms require specific flags as follows:
|
|
149 |
|
|
150 |
""" + build_flags.flatMap(_.print).mkString("\n\n") + """
|
|
151 |
|
|
152 |
|
|
153 |
Makarius
|
|
154 |
""" + Date.Format.date(Date.now()) + "\n")
|
|
155 |
})
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
/* Isabelle tool wrapper */
|
|
160 |
|
|
161 |
val isabelle_tool =
|
|
162 |
Isabelle_Tool("build_verit", "build prover component from official download",
|
|
163 |
args =>
|
|
164 |
{
|
|
165 |
var target_dir = Path.current
|
|
166 |
var download_url = default_download_url
|
|
167 |
var verbose = false
|
|
168 |
|
|
169 |
val getopts = Getopts("""
|
|
170 |
Usage: isabelle build_verit [OPTIONS]
|
|
171 |
|
|
172 |
Options are:
|
|
173 |
-D DIR target directory (default ".")
|
|
174 |
-U URL download URL
|
|
175 |
(default: """" + default_download_url + """")
|
|
176 |
-v verbose
|
|
177 |
|
|
178 |
Build prover component from official download.
|
|
179 |
""",
|
|
180 |
"D:" -> (arg => target_dir = Path.explode(arg)),
|
|
181 |
"U:" -> (arg => download_url = arg),
|
|
182 |
"v" -> (_ => verbose = true))
|
|
183 |
|
|
184 |
val more_args = getopts(args)
|
|
185 |
if (more_args.nonEmpty) getopts.usage()
|
|
186 |
|
|
187 |
val progress = new Console_Progress()
|
|
188 |
|
|
189 |
build_verit(download_url = download_url, verbose = verbose, progress = progress,
|
|
190 |
target_dir = target_dir)
|
|
191 |
})
|
|
192 |
}
|