author | wenzelm |
Tue, 11 Jul 2023 12:12:21 +0200 | |
changeset 78300 | ab95c9f2d55c |
parent 78158 | 8b5a2e4b16d4 |
child 79750 | f8fb4384180e |
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( |
78300 | 22 |
Download_Platform("arm64-darwin", "cvc5-macOS-arm64"), |
23 |
Download_Platform("x86_64-darwin", "cvc5-macOS"), |
|
24 |
Download_Platform("x86_64-linux", "cvc5-Linux"), |
|
25 |
Download_Platform("x86_64-windows", "cvc5-Win64.exe")) |
|
76017 | 26 |
|
27 |
||
28 |
/* build cvc5 */ |
|
29 |
||
30 |
val default_url = "https://github.com/cvc5/cvc5/releases/download" |
|
31 |
val default_version = "1.0.2" |
|
32 |
||
33 |
def build_cvc5( |
|
34 |
base_url: String = default_url, |
|
35 |
version: String = default_version, |
|
36 |
target_dir: Path = Path.current, |
|
37 |
progress: Progress = new Progress |
|
38 |
): Unit = { |
|
39 |
/* component name */ |
|
40 |
||
41 |
val component = "cvc5-" + version |
|
76518 | 42 |
val component_dir = |
76547 | 43 |
Components.Directory(target_dir + Path.basic(component)).create(progress = progress) |
76017 | 44 |
|
45 |
||
46 |
/* download executables */ |
|
47 |
||
48 |
for (platform <- platforms) { |
|
49 |
val url = base_url + "/cvc5-" + version + "/" + platform.download_name |
|
50 |
||
76518 | 51 |
val platform_dir = component_dir.path + Path.explode(platform.platform_name) |
76017 | 52 |
val platform_exe = platform_dir + Path.explode("cvc5").exe_if(platform.is_windows) |
53 |
||
54 |
Isabelle_System.make_directory(platform_dir) |
|
55 |
Isabelle_System.download_file(url, platform_exe, progress = progress) |
|
78158 | 56 |
File.set_executable(platform_exe) |
76017 | 57 |
} |
58 |
||
59 |
||
60 |
/* settings */ |
|
61 |
||
76548 | 62 |
component_dir.write_settings(""" |
76017 | 63 |
CVC5_HOME="$COMPONENT/${ISABELLE_WINDOWS_PLATFORM64:-${ISABELLE_APPLE_PLATFORM64:-$ISABELLE_PLATFORM64}}" |
64 |
CVC5_VERSION=""" + Bash.string(version) + """ |
|
65 |
||
66 |
CVC5_SOLVER="$CVC5_HOME/cvc5" |
|
67 |
||
68 |
if [ -e "$CVC5_HOME" ] |
|
69 |
then |
|
70 |
CVC5_INSTALLED="yes" |
|
71 |
fi |
|
72 |
""") |
|
73 |
||
74 |
||
75 |
/* README */ |
|
76 |
||
76518 | 77 |
File.write(component_dir.README, |
76017 | 78 |
"""This distribution of cvc5 was assembled from the official downloads |
76018 | 79 |
from """ + base_url + """ for 64bit macOS, |
80 |
Linux, and Windows. There is native support for macOS ARM64, but |
|
81 |
Linux ARM64 is missing. |
|
76017 | 82 |
|
83 |
The oldest supported version of macOS is 10.14 Mojave. |
|
84 |
||
85 |
The downloaded files were renamed and made executable. |
|
86 |
||
87 |
||
88 |
Makarius |
|
89 |
""" + Date.Format.date(Date.now()) + "\n") |
|
90 |
||
91 |
||
92 |
/* AUTHORS and COPYING */ |
|
93 |
||
94 |
// download "latest" versions as reasonable approximation |
|
95 |
def raw_download(name: String): Unit = |
|
96 |
Isabelle_System.download_file("https://raw.githubusercontent.com/cvc5/cvc5/main/" + name, |
|
76518 | 97 |
component_dir.path + Path.explode(name)) |
76017 | 98 |
|
99 |
raw_download("AUTHORS") |
|
100 |
raw_download("COPYING") |
|
101 |
} |
|
102 |
||
103 |
||
104 |
/* Isabelle tool wrapper */ |
|
105 |
||
106 |
val isabelle_tool = |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
107 |
Isabelle_Tool("component_cvc5", "build component for cvc5", Scala_Project.here, |
76017 | 108 |
{ args => |
109 |
var target_dir = Path.current |
|
110 |
var base_url = default_url |
|
111 |
var version = default_version |
|
112 |
||
113 |
val getopts = Getopts(""" |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
114 |
Usage: isabelle component_cvc5 [OPTIONS] |
76017 | 115 |
|
116 |
Options are: |
|
117 |
-D DIR target directory (default ".") |
|
118 |
-U URL download URL (default: """" + default_url + """") |
|
119 |
-V VERSION version (default: """" + default_version + """") |
|
120 |
||
76477 | 121 |
Build component for cvc5 solver. |
76017 | 122 |
""", |
123 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
|
124 |
"U:" -> (arg => base_url = arg), |
|
125 |
"V:" -> (arg => version = arg)) |
|
126 |
||
127 |
val more_args = getopts(args) |
|
128 |
if (more_args.nonEmpty) getopts.usage() |
|
129 |
||
130 |
val progress = new Console_Progress() |
|
131 |
||
132 |
build_cvc5(base_url = base_url, version = version, target_dir = target_dir, |
|
133 |
progress = progress) |
|
134 |
}) |
|
135 |
} |