| author | wenzelm |
| Sat, 11 Feb 2023 20:54:24 +0100 | |
| changeset 77246 | 173c2fb78290 |
| parent 76548 | 0af64cc2eee9 |
| child 77510 | f5d6cd98b16a |
| permissions | -rw-r--r-- |
| 72886 | 1 |
/* Title: Pure/Admin/build_vampire.scala |
2 |
Author: Makarius |
|
3 |
||
| 74465 | 4 |
Build Isabelle Vampire component from official download. |
| 72886 | 5 |
*/ |
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
| 75393 | 10 |
object Build_Vampire {
|
| 74465 | 11 |
val default_download_url = "https://github.com/vprover/vampire/archive/refs/tags/v4.6.tar.gz" |
| 72890 | 12 |
val default_jobs = 1 |
| 72887 | 13 |
|
| 74464 | 14 |
def make_component_name(version: String): String = |
15 |
"vampire-" + Library.try_unprefix("v", version).getOrElse(version)
|
|
| 72886 | 16 |
|
17 |
||
18 |
/* build Vampire */ |
|
19 |
||
20 |
def build_vampire( |
|
| 74465 | 21 |
download_url: String = default_download_url, |
| 72890 | 22 |
jobs: Int = default_jobs, |
| 72887 | 23 |
component_name: String = "", |
| 72886 | 24 |
verbose: Boolean = false, |
25 |
progress: Progress = new Progress, |
|
| 75393 | 26 |
target_dir: Path = Path.current |
27 |
): Unit = {
|
|
| 73650 | 28 |
Isabelle_System.require_command("cmake")
|
| 72938 | 29 |
|
| 75394 | 30 |
Isabelle_System.with_tmp_dir("build") { tmp_dir =>
|
| 74465 | 31 |
/* component */ |
32 |
||
33 |
val Archive_Name = """^.*?([^/]+)$""".r |
|
34 |
val Version = """^v?([0-9.]+)\.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 |
} |
|
| 72886 | 47 |
|
| 74464 | 48 |
val component = proper_string(component_name) getOrElse make_component_name(version) |
| 76518 | 49 |
val component_dir = |
| 76547 | 50 |
Components.Directory(target_dir + Path.basic(component)).create(progress = progress) |
| 72886 | 51 |
|
| 74465 | 52 |
|
53 |
/* platform */ |
|
54 |
||
| 72886 | 55 |
val platform_name = |
56 |
proper_string(Isabelle_System.getenv("ISABELLE_PLATFORM64")) getOrElse
|
|
57 |
error("No 64bit platform")
|
|
| 74465 | 58 |
|
| 76518 | 59 |
val platform_dir = |
60 |
Isabelle_System.make_directory(component_dir.path + Path.basic(platform_name)) |
|
| 72886 | 61 |
|
62 |
||
| 74465 | 63 |
/* download source */ |
64 |
||
65 |
val archive_path = tmp_dir + Path.basic(archive_name) |
|
66 |
Isabelle_System.download_file(download_url, archive_path, progress = progress) |
|
| 72886 | 67 |
|
|
76540
83de6e9ae983
clarified signature: prefer Scala functions instead of shell scripts;
wenzelm
parents:
76529
diff
changeset
|
68 |
Isabelle_System.extract(archive_path, tmp_dir) |
| 76529 | 69 |
val source_dir = File.get_dir(tmp_dir, title = download_url) |
| 72886 | 70 |
|
| 76541 | 71 |
Isabelle_System.extract(archive_path, component_dir.src, strip = true) |
|
72888
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
72 |
|
|
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
73 |
|
| 74464 | 74 |
/* build */ |
| 72886 | 75 |
|
| 74465 | 76 |
progress.echo("Building Vampire for " + platform_name + " ...")
|
|
72888
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
77 |
|
| 76529 | 78 |
Isabelle_System.copy_file(source_dir + Path.explode("LICENCE"), component_dir.path)
|
|
72888
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
79 |
|
| 74464 | 80 |
val cmake_opts = if (Platform.is_linux) "-DBUILD_SHARED_LIBS=0 " else "" |
81 |
val cmake_out = |
|
| 74465 | 82 |
progress.bash("cmake " + cmake_opts + """-G "Unix Makefiles" .""",
|
| 76529 | 83 |
cwd = source_dir.file, echo = verbose).check.out |
| 72886 | 84 |
|
| 74464 | 85 |
val Pattern = """-- Setting binary name to '?([^\s']*)'?""".r |
86 |
val binary = |
|
87 |
split_lines(cmake_out).collectFirst({ case Pattern(name) => name })
|
|
88 |
.getOrElse(error("Failed to determine binary name from cmake output:\n" + cmake_out))
|
|
|
72888
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
89 |
|
| 76529 | 90 |
progress.bash("make -j" + jobs, cwd = source_dir.file, echo = verbose).check
|
|
72888
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
91 |
|
| 76529 | 92 |
Isabelle_System.copy_file(source_dir + Path.basic("bin") + Path.basic(binary).platform_exe,
|
| 74464 | 93 |
platform_dir + Path.basic("vampire").platform_exe)
|
|
72888
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
94 |
|
|
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
95 |
|
| 72886 | 96 |
/* settings */ |
97 |
||
| 76548 | 98 |
component_dir.write_settings("""
|
| 72886 | 99 |
VAMPIRE_HOME="$COMPONENT/$ISABELLE_PLATFORM64" |
100 |
||
101 |
ISABELLE_VAMPIRE="$VAMPIRE_HOME/vampire" |
|
102 |
""") |
|
103 |
||
104 |
||
105 |
/* README */ |
|
106 |
||
| 76518 | 107 |
File.write(component_dir.README, |
| 74465 | 108 |
"This Isabelle component provides Vampire " + version + """using the |
109 |
original sources from """.stripMargin + download_url + """ |
|
| 72886 | 110 |
|
| 74465 | 111 |
The executables have been built via "cmake . && make" |
| 72886 | 112 |
|
113 |
||
114 |
Makarius |
|
115 |
""" + Date.Format.date(Date.now()) + "\n") |
|
| 75394 | 116 |
} |
| 72886 | 117 |
} |
118 |
||
119 |
||
120 |
/* Isabelle tool wrapper */ |
|
121 |
||
122 |
val isabelle_tool = |
|
| 74480 | 123 |
Isabelle_Tool("build_vampire", "build prover component from official download",
|
| 75394 | 124 |
Scala_Project.here, |
125 |
{ args =>
|
|
| 72886 | 126 |
var target_dir = Path.current |
| 74465 | 127 |
var download_url = default_download_url |
| 72890 | 128 |
var jobs = default_jobs |
| 72887 | 129 |
var component_name = "" |
| 72886 | 130 |
var verbose = false |
131 |
||
132 |
val getopts = Getopts("""
|
|
133 |
Usage: isabelle build_vampire [OPTIONS] |
|
134 |
||
135 |
Options are: |
|
136 |
-D DIR target directory (default ".") |
|
| 74465 | 137 |
-U URL download URL |
138 |
(default: """" + default_download_url + """") |
|
| 72890 | 139 |
-j NUMBER parallel jobs for make (default: """ + default_jobs + """) |
| 74465 | 140 |
-n NAME component name (default: """" + make_component_name("VERSION") + """")
|
| 72886 | 141 |
-v verbose |
142 |
||
143 |
Build prover component from official download. |
|
144 |
""", |
|
145 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
|
| 74465 | 146 |
"U:" -> (arg => download_url = arg), |
| 72890 | 147 |
"j:" -> (arg => jobs = Value.Nat.parse(arg)), |
| 72886 | 148 |
"n:" -> (arg => component_name = arg), |
149 |
"v" -> (_ => verbose = true)) |
|
150 |
||
151 |
val more_args = getopts(args) |
|
152 |
if (more_args.nonEmpty) getopts.usage() |
|
153 |
||
154 |
val progress = new Console_Progress() |
|
155 |
||
| 74465 | 156 |
build_vampire(download_url = download_url, component_name = component_name, |
| 74464 | 157 |
jobs = jobs, verbose = verbose, progress = progress, target_dir = target_dir) |
| 72886 | 158 |
}) |
159 |
} |