author | nipkow |
Tue, 17 Jun 2025 06:29:55 +0200 | |
changeset 82732 | 71574900b6ba |
parent 81750 | 377887fbc968 |
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) { |
81707
f135e0693202
provide component cvc5-1.2.0, including arm64-linux;
wenzelm
parents:
81578
diff
changeset
|
17 |
def is_arm: Boolean = platform_name.startsWith("arm64-") |
76017 | 18 |
def is_windows: Boolean = platform_name.endsWith("-windows") |
19 |
} |
|
20 |
||
78300 | 21 |
val platforms: List[Download_Platform] = |
76017 | 22 |
List( |
81578 | 23 |
Download_Platform("arm64-darwin", "cvc5-macOS-arm64-static.zip"), |
24 |
Download_Platform("arm64-linux", "cvc5-Linux-arm64-static.zip"), |
|
25 |
Download_Platform("x86_64-darwin", "cvc5-macOS-x86_64-static.zip"), |
|
26 |
Download_Platform("x86_64-linux", "cvc5-Linux-x86_64-static.zip"), |
|
27 |
Download_Platform("x86_64-windows", "cvc5-Win64-x86_64-static.zip")) |
|
76017 | 28 |
|
29 |
||
30 |
/* build cvc5 */ |
|
31 |
||
32 |
val default_url = "https://github.com/cvc5/cvc5/releases/download" |
|
81578 | 33 |
val default_version = "1.2.0" |
76017 | 34 |
|
35 |
def build_cvc5( |
|
36 |
base_url: String = default_url, |
|
37 |
version: String = default_version, |
|
38 |
target_dir: Path = Path.current, |
|
39 |
progress: Progress = new Progress |
|
40 |
): Unit = { |
|
41 |
/* component name */ |
|
42 |
||
43 |
val component = "cvc5-" + version |
|
76518 | 44 |
val component_dir = |
76547 | 45 |
Components.Directory(target_dir + Path.basic(component)).create(progress = progress) |
76017 | 46 |
|
47 |
||
48 |
/* download executables */ |
|
49 |
||
50 |
for (platform <- platforms) { |
|
79750
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
51 |
Isabelle_System.with_tmp_dir("download") { download_dir => |
81578 | 52 |
val download = base_url + "/cvc5-" + version + "/" + platform.download_name |
79750
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
53 |
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
54 |
val archive_name = |
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
55 |
Url.get_base_name(platform.download_name) getOrElse |
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
56 |
error("Malformed download name " + quote(platform.download_name)) |
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
57 |
val archive_path = download_dir + Path.basic(archive_name) |
76017 | 58 |
|
79750
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
59 |
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
|
60 |
Isabelle_System.make_directory(platform_dir) |
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
61 |
|
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
62 |
val exe_path = Path.explode("cvc5").exe_if(platform.is_windows) |
81750 | 63 |
val exe_bin_path = Path.explode("cvc5-bin").exe_if(platform.is_windows) |
64 |
||
81707
f135e0693202
provide component cvc5-1.2.0, including arm64-linux;
wenzelm
parents:
81578
diff
changeset
|
65 |
val exe = platform_dir + exe_path |
81750 | 66 |
val exe_bin = platform_dir + exe_bin_path |
76017 | 67 |
|
79750
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
68 |
Isabelle_System.download_file(download, archive_path, progress = progress) |
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
69 |
Isabelle_System.extract(archive_path, download_dir, strip = true) |
81750 | 70 |
|
71 |
Isabelle_System.copy_file(download_dir + Path.basic("bin") + exe_path, exe_bin) |
|
72 |
File.set_executable(exe_bin) |
|
81707
f135e0693202
provide component cvc5-1.2.0, including arm64-linux;
wenzelm
parents:
81578
diff
changeset
|
73 |
|
81750 | 74 |
File.write(exe, """#!/usr/bin/env bash |
81707
f135e0693202
provide component cvc5-1.2.0, including arm64-linux;
wenzelm
parents:
81578
diff
changeset
|
75 |
|
81750 | 76 |
"$CVC5_HOME/cvc5-bin" "$@" |
81707
f135e0693202
provide component cvc5-1.2.0, including arm64-linux;
wenzelm
parents:
81578
diff
changeset
|
77 |
""") |
81750 | 78 |
File.set_executable(exe) |
79750
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
79 |
} |
76017 | 80 |
} |
81 |
||
82 |
||
79750
f8fb4384180e
provide cvc5-1.1.1 for testing --- still inactive;
wenzelm
parents:
78300
diff
changeset
|
83 |
/* settings */ |
76017 | 84 |
|
76548 | 85 |
component_dir.write_settings(""" |
76017 | 86 |
CVC5_HOME="$COMPONENT/${ISABELLE_WINDOWS_PLATFORM64:-${ISABELLE_APPLE_PLATFORM64:-$ISABELLE_PLATFORM64}}" |
87 |
CVC5_VERSION=""" + Bash.string(version) + """ |
|
88 |
||
89 |
CVC5_SOLVER="$CVC5_HOME/cvc5" |
|
90 |
||
91 |
if [ -e "$CVC5_HOME" ] |
|
92 |
then |
|
93 |
CVC5_INSTALLED="yes" |
|
94 |
fi |
|
95 |
""") |
|
96 |
||
97 |
||
98 |
/* README */ |
|
99 |
||
76518 | 100 |
File.write(component_dir.README, |
81578 | 101 |
"""This distribution of cvc5 was assembled from official downloads from |
102 |
""" + base_url + """ --- the static.zip variants |
|
103 |
for macOS, Linux, and Windows, with ARM64 support on macOS and Linux. |
|
76017 | 104 |
|
105 |
The downloaded files were renamed and made executable. |
|
106 |
||
107 |
||
108 |
Makarius |
|
109 |
""" + Date.Format.date(Date.now()) + "\n") |
|
110 |
||
111 |
||
112 |
/* AUTHORS and COPYING */ |
|
113 |
||
114 |
// download "latest" versions as reasonable approximation |
|
115 |
def raw_download(name: String): Unit = |
|
116 |
Isabelle_System.download_file("https://raw.githubusercontent.com/cvc5/cvc5/main/" + name, |
|
76518 | 117 |
component_dir.path + Path.explode(name)) |
76017 | 118 |
|
119 |
raw_download("AUTHORS") |
|
120 |
raw_download("COPYING") |
|
121 |
} |
|
122 |
||
123 |
||
124 |
/* Isabelle tool wrapper */ |
|
125 |
||
126 |
val isabelle_tool = |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
127 |
Isabelle_Tool("component_cvc5", "build component for cvc5", Scala_Project.here, |
76017 | 128 |
{ args => |
129 |
var target_dir = Path.current |
|
130 |
var base_url = default_url |
|
131 |
var version = default_version |
|
132 |
||
133 |
val getopts = Getopts(""" |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
134 |
Usage: isabelle component_cvc5 [OPTIONS] |
76017 | 135 |
|
136 |
Options are: |
|
137 |
-D DIR target directory (default ".") |
|
138 |
-U URL download URL (default: """" + default_url + """") |
|
139 |
-V VERSION version (default: """" + default_version + """") |
|
140 |
||
76477 | 141 |
Build component for cvc5 solver. |
76017 | 142 |
""", |
143 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
|
144 |
"U:" -> (arg => base_url = arg), |
|
145 |
"V:" -> (arg => version = arg)) |
|
146 |
||
147 |
val more_args = getopts(args) |
|
148 |
if (more_args.nonEmpty) getopts.usage() |
|
149 |
||
150 |
val progress = new Console_Progress() |
|
151 |
||
152 |
build_cvc5(base_url = base_url, version = version, target_dir = target_dir, |
|
153 |
progress = progress) |
|
154 |
}) |
|
155 |
} |