| author | wenzelm |
| Wed, 28 Aug 2024 22:54:45 +0200 | |
| changeset 80786 | 70076ba563d2 |
| parent 79944 | 67d28b35c5d8 |
| child 81578 | 78b746a99211 |
| permissions | -rw-r--r-- |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
1 |
/* Title: Pure/Admin/component_cvc5.scala |
| 76017 | 2 |
Author: Makarius |
3 |
||
4 |
Build Isabelle component for cvc5. See also: |
|
5 |
||
6 |
- https://cvc5.github.io/ |
|
7 |
- https://github.com/cvc5/cvc5 |
|
8 |
*/ |
|
9 |
||
10 |
package isabelle |
|
11 |
||
12 |
||
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
13 |
object Component_CVC5 {
|
| 76017 | 14 |
/* platform information */ |
15 |
||
| 78300 | 16 |
sealed case class Download_Platform(platform_name: String, download_name: String) {
|
| 76017 | 17 |
def is_windows: Boolean = platform_name.endsWith("-windows")
|
18 |
} |
|
19 |
||
| 78300 | 20 |
val platforms: List[Download_Platform] = |
| 76017 | 21 |
List( |
| 79944 | 22 |
Download_Platform("arm64-darwin", "cvc5-macOS-arm64-static-2024-03-20-ef2bc3f.zip"),
|
23 |
Download_Platform("arm64-linux", "cvc5-Linux-arm64-static-2024-03-20-ef2bc3f.zip"),
|
|
24 |
Download_Platform("x86_64-darwin", "cvc5-macOS-static-2024-03-20-ef2bc3f.zip"),
|
|
25 |
Download_Platform("x86_64-linux", "cvc5-Linux-static-2024-03-20-ef2bc3f.zip"),
|
|
26 |
Download_Platform("x86_64-windows", "cvc5-Win64-static-2024-03-20-ef2bc3f.zip"))
|
|
| 76017 | 27 |
|
28 |
||
29 |
/* build cvc5 */ |
|
30 |
||
31 |
val default_url = "https://github.com/cvc5/cvc5/releases/download" |
|
| 79944 | 32 |
val default_version = "latest" |
| 76017 | 33 |
|
34 |
def build_cvc5( |
|
35 |
base_url: String = default_url, |
|
36 |
version: String = default_version, |
|
37 |
target_dir: Path = Path.current, |
|
38 |
progress: Progress = new Progress |
|
39 |
): Unit = {
|
|
40 |
/* component name */ |
|
41 |
||
42 |
val component = "cvc5-" + version |
|
| 76518 | 43 |
val component_dir = |
| 76547 | 44 |
Components.Directory(target_dir + Path.basic(component)).create(progress = progress) |
| 76017 | 45 |
|
46 |
||
47 |
/* download executables */ |
|
48 |
||
49 |
for (platform <- platforms) {
|
|
|
79750
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
50 |
Isabelle_System.with_tmp_dir("download") { download_dir =>
|
| 79944 | 51 |
val download = base_url + "/" + version + "/" + platform.download_name |
|
79750
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
52 |
|
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
53 |
val archive_name = |
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
54 |
Url.get_base_name(platform.download_name) getOrElse |
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
55 |
error("Malformed download name " + quote(platform.download_name))
|
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
56 |
val archive_path = download_dir + Path.basic(archive_name) |
| 76017 | 57 |
|
|
79750
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
58 |
val platform_dir = component_dir.path + Path.explode(platform.platform_name) |
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
59 |
Isabelle_System.make_directory(platform_dir) |
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
60 |
|
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
61 |
val exe_path = Path.explode("cvc5").exe_if(platform.is_windows)
|
| 76017 | 62 |
|
|
79750
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
63 |
Isabelle_System.download_file(download, archive_path, progress = progress) |
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
64 |
Isabelle_System.extract(archive_path, download_dir, strip = true) |
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
65 |
Isabelle_System.copy_file(download_dir + Path.basic("bin") + exe_path, platform_dir)
|
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
66 |
File.set_executable(platform_dir + exe_path) |
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
67 |
} |
| 76017 | 68 |
} |
69 |
||
70 |
||
|
79750
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
71 |
/* settings */ |
| 76017 | 72 |
|
| 76548 | 73 |
component_dir.write_settings("""
|
| 76017 | 74 |
CVC5_HOME="$COMPONENT/${ISABELLE_WINDOWS_PLATFORM64:-${ISABELLE_APPLE_PLATFORM64:-$ISABELLE_PLATFORM64}}"
|
75 |
CVC5_VERSION=""" + Bash.string(version) + """ |
|
76 |
||
77 |
CVC5_SOLVER="$CVC5_HOME/cvc5" |
|
78 |
||
79 |
if [ -e "$CVC5_HOME" ] |
|
80 |
then |
|
81 |
CVC5_INSTALLED="yes" |
|
82 |
fi |
|
83 |
""") |
|
84 |
||
85 |
||
86 |
/* README */ |
|
87 |
||
| 76518 | 88 |
File.write(component_dir.README, |
| 79944 | 89 |
"""This distribution of cvc5 was assembled from official downloads |
90 |
from """ + base_url + """ for macOS, Linux, |
|
91 |
and Windows, with ARM64 support on macOS and Linux. |
|
92 |
||
93 |
The change id is ef2bc3f735df (3 weeks after cvc5-1.1.2). |
|
| 76017 | 94 |
|
95 |
The downloaded files were renamed and made executable. |
|
96 |
||
97 |
||
98 |
Makarius |
|
99 |
""" + Date.Format.date(Date.now()) + "\n") |
|
100 |
||
101 |
||
102 |
/* AUTHORS and COPYING */ |
|
103 |
||
104 |
// download "latest" versions as reasonable approximation |
|
105 |
def raw_download(name: String): Unit = |
|
106 |
Isabelle_System.download_file("https://raw.githubusercontent.com/cvc5/cvc5/main/" + name,
|
|
| 76518 | 107 |
component_dir.path + Path.explode(name)) |
| 76017 | 108 |
|
109 |
raw_download("AUTHORS")
|
|
110 |
raw_download("COPYING")
|
|
111 |
} |
|
112 |
||
113 |
||
114 |
/* Isabelle tool wrapper */ |
|
115 |
||
116 |
val isabelle_tool = |
|
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
117 |
Isabelle_Tool("component_cvc5", "build component for cvc5", Scala_Project.here,
|
| 76017 | 118 |
{ args =>
|
119 |
var target_dir = Path.current |
|
120 |
var base_url = default_url |
|
121 |
var version = default_version |
|
122 |
||
123 |
val getopts = Getopts("""
|
|
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
124 |
Usage: isabelle component_cvc5 [OPTIONS] |
| 76017 | 125 |
|
126 |
Options are: |
|
127 |
-D DIR target directory (default ".") |
|
128 |
-U URL download URL (default: """" + default_url + """") |
|
129 |
-V VERSION version (default: """" + default_version + """") |
|
130 |
||
| 76477 | 131 |
Build component for cvc5 solver. |
| 76017 | 132 |
""", |
133 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
|
134 |
"U:" -> (arg => base_url = arg), |
|
135 |
"V:" -> (arg => version = arg)) |
|
136 |
||
137 |
val more_args = getopts(args) |
|
138 |
if (more_args.nonEmpty) getopts.usage() |
|
139 |
||
140 |
val progress = new Console_Progress() |
|
141 |
||
142 |
build_cvc5(base_url = base_url, version = version, target_dir = target_dir, |
|
143 |
progress = progress) |
|
144 |
}) |
|
145 |
} |