| author | wenzelm | 
| Sat, 01 Jun 2024 15:13:03 +0200 | |
| changeset 80231 | a2cf0318db4a | 
| parent 80224 | db92e0b6a11a | 
| child 82467 | b0740dce1f1d | 
| permissions | -rw-r--r-- | 
| 77570 | 1  | 
/* Title: Pure/Admin/component_verit.scala  | 
| 72439 | 2  | 
Author: Makarius  | 
3  | 
||
4  | 
Build Isabelle veriT component from official download.  | 
|
5  | 
*/  | 
|
6  | 
||
7  | 
package isabelle  | 
|
8  | 
||
9  | 
||
| 
77566
 
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
 
wenzelm 
parents: 
77510 
diff
changeset
 | 
10  | 
object Component_VeriT {
 | 
| 74819 | 11  | 
val default_download_url = "https://verit.loria.fr/rmx/2021.06.2/verit-2021.06.2-rmx.tar.gz"  | 
| 72439 | 12  | 
|
13  | 
||
14  | 
/* build veriT */  | 
|
15  | 
||
16  | 
def build_verit(  | 
|
17  | 
download_url: String = default_download_url,  | 
|
18  | 
progress: Progress = new Progress,  | 
|
| 72476 | 19  | 
target_dir: Path = Path.current,  | 
| 75393 | 20  | 
mingw: MinGW = MinGW.none  | 
21  | 
  ): Unit = {
 | 
|
| 72476 | 22  | 
mingw.check  | 
23  | 
||
| 75394 | 24  | 
    Isabelle_System.with_tmp_dir("build") { tmp_dir =>
 | 
| 72439 | 25  | 
/* component */  | 
26  | 
||
27  | 
val Archive_Name = """^.*?([^/]+)$""".r  | 
|
28  | 
val Version = """^[^-]+-(.+)\.tar.gz$""".r  | 
|
29  | 
||
30  | 
val archive_name =  | 
|
31  | 
        download_url match {
 | 
|
32  | 
case Archive_Name(name) => name  | 
|
33  | 
          case _ => error("Failed to determine source archive name from " + quote(download_url))
 | 
|
34  | 
}  | 
|
35  | 
||
36  | 
val version =  | 
|
37  | 
        archive_name match {
 | 
|
38  | 
case Version(version) => version  | 
|
39  | 
          case _ => error("Failed to determine component version from " + quote(archive_name))
 | 
|
40  | 
}  | 
|
41  | 
||
42  | 
val component_name = "verit-" + version  | 
|
| 76518 | 43  | 
val component_dir =  | 
| 76547 | 44  | 
Components.Directory(target_dir + Path.basic(component_name)).create(progress = progress)  | 
| 72439 | 45  | 
|
46  | 
||
47  | 
/* platform */  | 
|
48  | 
||
| 80049 | 49  | 
val platform_name = Isabelle_Platform.self.ISABELLE_PLATFORM(windows = true)  | 
| 76518 | 50  | 
val platform_dir =  | 
51  | 
Isabelle_System.make_directory(component_dir.path + Path.basic(platform_name))  | 
|
| 72439 | 52  | 
|
53  | 
||
54  | 
/* download source */  | 
|
55  | 
||
56  | 
val archive_path = tmp_dir + Path.basic(archive_name)  | 
|
| 73566 | 57  | 
Isabelle_System.download_file(download_url, archive_path, progress = progress)  | 
| 72439 | 58  | 
|
| 
76540
 
83de6e9ae983
clarified signature: prefer Scala functions instead of shell scripts;
 
wenzelm 
parents: 
76529 
diff
changeset
 | 
59  | 
Isabelle_System.extract(archive_path, tmp_dir)  | 
| 76529 | 60  | 
val source_dir = File.get_dir(tmp_dir, title = download_url)  | 
| 72439 | 61  | 
|
| 76541 | 62  | 
Isabelle_System.extract(archive_path, component_dir.src, strip = true)  | 
| 72439 | 63  | 
|
64  | 
||
65  | 
/* build */  | 
|
66  | 
||
| 72440 | 67  | 
      progress.echo("Building veriT for " + platform_name + " ...")
 | 
| 72439 | 68  | 
|
| 72475 | 69  | 
val configure_options =  | 
70  | 
if (Platform.is_linux) "LDFLAGS=-Wl,-rpath,_DUMMY_" else ""  | 
|
71  | 
||
| 72476 | 72  | 
      progress.bash(mingw.bash_script("set -e\n./configure " + configure_options + "\nmake"),
 | 
| 
80224
 
db92e0b6a11a
clarified signature: prefer symbolic isabelle.Path over physical java.io.File;
 
wenzelm 
parents: 
80049 
diff
changeset
 | 
73  | 
cwd = source_dir, echo = progress.verbose).check  | 
| 72439 | 74  | 
|
75  | 
||
76  | 
/* install */  | 
|
77  | 
||
| 76529 | 78  | 
      Isabelle_System.copy_file(source_dir + Path.explode("LICENSE"), component_dir.path)
 | 
| 72475 | 79  | 
|
80  | 
      val exe_path = Path.basic("veriT").platform_exe
 | 
|
| 76529 | 81  | 
Isabelle_System.copy_file(source_dir + exe_path, platform_dir)  | 
| 72476 | 82  | 
      Executable.libraries_closure(platform_dir + exe_path, filter = Set("libgmp"), mingw = mingw)
 | 
| 72475 | 83  | 
|
| 72439 | 84  | 
|
85  | 
/* settings */  | 
|
86  | 
||
| 76548 | 87  | 
      component_dir.write_settings("""
 | 
| 
72478
 
b452242dce36
proper Isabelle component settings: prefer standard terminology "ISABELLE_VERIT", avoid conflict of "VERIT_VERSION" with processing of implicit options by veriT;
 
wenzelm 
parents: 
72476 
diff
changeset
 | 
88  | 
ISABELLE_VERIT="$COMPONENT/${ISABELLE_WINDOWS_PLATFORM64:-$ISABELLE_PLATFORM64}/veriT"
 | 
| 72439 | 89  | 
""")  | 
90  | 
||
91  | 
||
92  | 
/* README */  | 
|
93  | 
||
| 76518 | 94  | 
File.write(component_dir.README,  | 
| 72439 | 95  | 
"""This is veriT """ + version + """ from  | 
96  | 
""" + download_url + """  | 
|
97  | 
||
98  | 
It has been built from sources like this:  | 
|
| 72475 | 99  | 
|
100  | 
cd src  | 
|
101  | 
./configure  | 
|
102  | 
make  | 
|
103  | 
||
| 72439 | 104  | 
|
| 
72443
 
ff5e700ed490
more robust: ignore existing gmp installation, but let veriT incorporate extern/gmp;
 
wenzelm 
parents: 
72442 
diff
changeset
 | 
105  | 
Makarius  | 
| 
 
ff5e700ed490
more robust: ignore existing gmp installation, but let veriT incorporate extern/gmp;
 
wenzelm 
parents: 
72442 
diff
changeset
 | 
106  | 
""" + Date.Format.date(Date.now()) + "\n")  | 
| 75394 | 107  | 
}  | 
| 72439 | 108  | 
}  | 
109  | 
||
110  | 
||
111  | 
/* Isabelle tool wrapper */  | 
|
112  | 
||
113  | 
val isabelle_tool =  | 
|
| 
77566
 
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
 
wenzelm 
parents: 
77510 
diff
changeset
 | 
114  | 
    Isabelle_Tool("component_verit", "build prover component from official download",
 | 
| 75394 | 115  | 
Scala_Project.here,  | 
116  | 
      { args =>
 | 
|
117  | 
var target_dir = Path.current  | 
|
118  | 
var mingw = MinGW.none  | 
|
119  | 
var download_url = default_download_url  | 
|
120  | 
var verbose = false  | 
|
| 72439 | 121  | 
|
| 75394 | 122  | 
        val getopts = Getopts("""
 | 
| 
77566
 
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
 
wenzelm 
parents: 
77510 
diff
changeset
 | 
123  | 
Usage: isabelle component_verit [OPTIONS]  | 
| 72439 | 124  | 
|
125  | 
Options are:  | 
|
126  | 
-D DIR target directory (default ".")  | 
|
| 72476 | 127  | 
-M DIR msys/mingw root specification for Windows  | 
| 72439 | 128  | 
-U URL download URL  | 
129  | 
(default: """" + default_download_url + """")  | 
|
130  | 
-v verbose  | 
|
131  | 
||
132  | 
Build prover component from official download.  | 
|
133  | 
""",  | 
|
| 75394 | 134  | 
"D:" -> (arg => target_dir = Path.explode(arg)),  | 
135  | 
"M:" -> (arg => mingw = MinGW(Path.explode(arg))),  | 
|
136  | 
"U:" -> (arg => download_url = arg),  | 
|
137  | 
"v" -> (_ => verbose = true))  | 
|
| 72439 | 138  | 
|
| 75394 | 139  | 
val more_args = getopts(args)  | 
140  | 
if (more_args.nonEmpty) getopts.usage()  | 
|
| 72439 | 141  | 
|
| 
77510
 
f5d6cd98b16a
clarified signature: manage "verbose" flag via "progress";
 
wenzelm 
parents: 
76548 
diff
changeset
 | 
142  | 
val progress = new Console_Progress(verbose = verbose)  | 
| 72439 | 143  | 
|
| 
77510
 
f5d6cd98b16a
clarified signature: manage "verbose" flag via "progress";
 
wenzelm 
parents: 
76548 
diff
changeset
 | 
144  | 
build_verit(download_url = download_url, progress = progress,  | 
| 75394 | 145  | 
target_dir = target_dir, mingw = mingw)  | 
146  | 
})  | 
|
| 72439 | 147  | 
}  |