author | wenzelm |
Wed, 06 Oct 2021 20:26:08 +0200 | |
changeset 74465 | 981e3b6b08a5 |
parent 74464 | c30906fbbe91 |
child 74480 | d8015e659e15 |
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 |
||
10 |
object Build_Vampire |
|
11 |
{ |
|
74465 | 12 |
val default_download_url = "https://github.com/vprover/vampire/archive/refs/tags/v4.6.tar.gz" |
72890 | 13 |
val default_jobs = 1 |
72887 | 14 |
|
74464 | 15 |
def make_component_name(version: String): String = |
16 |
"vampire-" + Library.try_unprefix("v", version).getOrElse(version) |
|
72886 | 17 |
|
18 |
||
19 |
/* build Vampire */ |
|
20 |
||
21 |
def build_vampire( |
|
74465 | 22 |
download_url: String = default_download_url, |
72890 | 23 |
jobs: Int = default_jobs, |
72887 | 24 |
component_name: String = "", |
72886 | 25 |
verbose: Boolean = false, |
26 |
progress: Progress = new Progress, |
|
73340 | 27 |
target_dir: Path = Path.current): Unit = |
72886 | 28 |
{ |
73650 | 29 |
Isabelle_System.require_command("cmake") |
72938 | 30 |
|
72886 | 31 |
Isabelle_System.with_tmp_dir("build")(tmp_dir => |
32 |
{ |
|
74465 | 33 |
/* component */ |
34 |
||
35 |
val Archive_Name = """^.*?([^/]+)$""".r |
|
36 |
val Version = """^v?([0-9.]+)\.tar.gz$""".r |
|
37 |
||
38 |
val archive_name = |
|
39 |
download_url match { |
|
40 |
case Archive_Name(name) => name |
|
41 |
case _ => error("Failed to determine source archive name from " + quote(download_url)) |
|
42 |
} |
|
43 |
||
44 |
val version = |
|
45 |
archive_name match { |
|
46 |
case Version(version) => version |
|
47 |
case _ => error("Failed to determine component version from " + quote(archive_name)) |
|
48 |
} |
|
72886 | 49 |
|
74464 | 50 |
val component = proper_string(component_name) getOrElse make_component_name(version) |
72887 | 51 |
val component_dir = Isabelle_System.new_directory(target_dir + Path.basic(component)) |
72886 | 52 |
progress.echo("Component " + component_dir) |
53 |
||
74465 | 54 |
|
55 |
/* platform */ |
|
56 |
||
72886 | 57 |
val platform_name = |
58 |
proper_string(Isabelle_System.getenv("ISABELLE_PLATFORM64")) getOrElse |
|
59 |
error("No 64bit platform") |
|
74465 | 60 |
|
72886 | 61 |
val platform_dir = Isabelle_System.make_directory(component_dir + Path.basic(platform_name)) |
62 |
||
63 |
||
74465 | 64 |
/* download source */ |
65 |
||
66 |
val archive_path = tmp_dir + Path.basic(archive_name) |
|
67 |
Isabelle_System.download_file(download_url, archive_path, progress = progress) |
|
72886 | 68 |
|
74465 | 69 |
Isabelle_System.bash("tar xzf " + File.bash_path(archive_path), cwd = tmp_dir.file).check |
70 |
val source_name = File.get_dir(tmp_dir) |
|
72886 | 71 |
|
74465 | 72 |
Isabelle_System.bash( |
73 |
"tar xzf " + archive_path + " && mv " + Bash.string(source_name) + " src", |
|
74 |
cwd = component_dir.file).check |
|
72888
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
75 |
|
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
76 |
|
74464 | 77 |
/* build */ |
72886 | 78 |
|
74465 | 79 |
progress.echo("Building Vampire for " + platform_name + " ...") |
72888
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
80 |
|
74465 | 81 |
val build_dir = tmp_dir + Path.basic(source_name) |
82 |
Isabelle_System.copy_file(build_dir + Path.explode("LICENCE"), component_dir) |
|
72888
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
83 |
|
74464 | 84 |
val cmake_opts = if (Platform.is_linux) "-DBUILD_SHARED_LIBS=0 " else "" |
85 |
val cmake_out = |
|
74465 | 86 |
progress.bash("cmake " + cmake_opts + """-G "Unix Makefiles" .""", |
74464 | 87 |
cwd = build_dir.file, echo = verbose).check.out |
72886 | 88 |
|
74464 | 89 |
val Pattern = """-- Setting binary name to '?([^\s']*)'?""".r |
90 |
val binary = |
|
91 |
split_lines(cmake_out).collectFirst({ case Pattern(name) => name }) |
|
92 |
.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
|
93 |
|
74464 | 94 |
progress.bash("make -j" + jobs, cwd = build_dir.file, echo = verbose).check |
72888
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
95 |
|
74464 | 96 |
Isabelle_System.copy_file(build_dir + Path.basic("bin") + Path.basic(binary).platform_exe, |
97 |
platform_dir + Path.basic("vampire").platform_exe) |
|
72888
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
98 |
|
74d785882737
prefer cmake build for standard version: more portable;
wenzelm
parents:
72887
diff
changeset
|
99 |
|
72886 | 100 |
/* settings */ |
101 |
||
102 |
val etc_dir = Isabelle_System.make_directory(component_dir + Path.basic("etc")) |
|
103 |
File.write(etc_dir + Path.basic("settings"), |
|
104 |
"""# -*- shell-script -*- :mode=shellscript: |
|
105 |
||
106 |
VAMPIRE_HOME="$COMPONENT/$ISABELLE_PLATFORM64" |
|
107 |
||
108 |
ISABELLE_VAMPIRE="$VAMPIRE_HOME/vampire" |
|
109 |
""") |
|
110 |
||
111 |
||
112 |
/* README */ |
|
113 |
||
114 |
File.write(component_dir + Path.basic("README"), |
|
74465 | 115 |
"This Isabelle component provides Vampire " + version + """using the |
116 |
original sources from """.stripMargin + download_url + """ |
|
72886 | 117 |
|
74465 | 118 |
The executables have been built via "cmake . && make" |
72886 | 119 |
|
120 |
||
121 |
Makarius |
|
122 |
""" + Date.Format.date(Date.now()) + "\n") |
|
123 |
}) |
|
124 |
} |
|
125 |
||
126 |
||
127 |
/* Isabelle tool wrapper */ |
|
128 |
||
129 |
val isabelle_tool = |
|
130 |
Isabelle_Tool("build_vampire", "build prover component from repository", Scala_Project.here, |
|
131 |
args => |
|
132 |
{ |
|
133 |
var target_dir = Path.current |
|
74465 | 134 |
var download_url = default_download_url |
72890 | 135 |
var jobs = default_jobs |
72887 | 136 |
var component_name = "" |
72886 | 137 |
var verbose = false |
138 |
||
139 |
val getopts = Getopts(""" |
|
140 |
Usage: isabelle build_vampire [OPTIONS] |
|
141 |
||
142 |
Options are: |
|
143 |
-D DIR target directory (default ".") |
|
74465 | 144 |
-U URL download URL |
145 |
(default: """" + default_download_url + """") |
|
72890 | 146 |
-j NUMBER parallel jobs for make (default: """ + default_jobs + """) |
74465 | 147 |
-n NAME component name (default: """" + make_component_name("VERSION") + """") |
72886 | 148 |
-v verbose |
149 |
||
150 |
Build prover component from official download. |
|
151 |
""", |
|
152 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
|
74465 | 153 |
"U:" -> (arg => download_url = arg), |
72890 | 154 |
"j:" -> (arg => jobs = Value.Nat.parse(arg)), |
72886 | 155 |
"n:" -> (arg => component_name = arg), |
156 |
"v" -> (_ => verbose = true)) |
|
157 |
||
158 |
val more_args = getopts(args) |
|
159 |
if (more_args.nonEmpty) getopts.usage() |
|
160 |
||
161 |
val progress = new Console_Progress() |
|
162 |
||
74465 | 163 |
build_vampire(download_url = download_url, component_name = component_name, |
74464 | 164 |
jobs = jobs, verbose = verbose, progress = progress, target_dir = target_dir) |
72886 | 165 |
}) |
166 |
} |