author | wenzelm |
Mon, 13 Mar 2023 11:02:26 +0100 | |
changeset 77622 | f458547b4f0f |
parent 77566 | 2a99fcb283ee |
child 78823 | 893049a842b5 |
permissions | -rw-r--r-- |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77510
diff
changeset
|
1 |
/* Title: Pure/Admin/component_minisat.scala |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
3 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
4 |
Build Isabelle Minisat from sources. |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
6 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
8 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
9 |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77510
diff
changeset
|
10 |
object Component_Minisat { |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
11 |
val default_download_url = "https://github.com/stp/minisat/archive/releases/2.2.1.tar.gz" |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
12 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
13 |
def make_component_name(version: String): String = "minisat-" + version |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
14 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
15 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
16 |
/* build Minisat */ |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
17 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
18 |
def build_minisat( |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
19 |
download_url: String = default_download_url, |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
20 |
component_name: String = "", |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
21 |
progress: Progress = new Progress, |
75393 | 22 |
target_dir: Path = Path.current |
23 |
): Unit = { |
|
75394 | 24 |
Isabelle_System.with_tmp_dir("build") { tmp_dir => |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
25 |
/* component */ |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
26 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
27 |
val Archive_Name = """^.*?([^/]+)$""".r |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
28 |
val Version = """^v?([0-9.]+)\.tar.gz$""".r |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
29 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
30 |
val archive_name = |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
31 |
download_url match { |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
32 |
case Archive_Name(name) => name |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
33 |
case _ => error("Failed to determine source archive name from " + quote(download_url)) |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
34 |
} |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
35 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
36 |
val version = |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
37 |
archive_name match { |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
38 |
case Version(version) => version |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
39 |
case _ => error("Failed to determine component version from " + quote(archive_name)) |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
40 |
} |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
41 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
42 |
val component = proper_string(component_name) getOrElse make_component_name(version) |
76518 | 43 |
val component_dir = |
76547 | 44 |
Components.Directory(target_dir + Path.basic(component)).create(progress = progress) |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
45 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
46 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
47 |
/* platform */ |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
48 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
49 |
val platform_name = |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
50 |
proper_string(Isabelle_System.getenv("ISABELLE_PLATFORM64")) getOrElse |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
51 |
error("No 64bit platform") |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
52 |
|
76518 | 53 |
val platform_dir = |
54 |
Isabelle_System.make_directory(component_dir.path + Path.basic(platform_name)) |
|
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
55 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
56 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
57 |
/* download source */ |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
58 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
59 |
val archive_path = tmp_dir + Path.basic(archive_name) |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
60 |
Isabelle_System.download_file(download_url, archive_path, progress = progress) |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
61 |
|
76540
83de6e9ae983
clarified signature: prefer Scala functions instead of shell scripts;
wenzelm
parents:
76529
diff
changeset
|
62 |
Isabelle_System.extract(archive_path, tmp_dir) |
76529 | 63 |
val source_dir = File.get_dir(tmp_dir, title = download_url) |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
64 |
|
76541 | 65 |
Isabelle_System.extract(archive_path, component_dir.src, strip = true) |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
66 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
67 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
68 |
/* build */ |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
69 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
70 |
progress.echo("Building Minisat for " + platform_name + " ...") |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
71 |
|
76529 | 72 |
Isabelle_System.copy_file(source_dir + Path.explode("LICENSE"), component_dir.path) |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
73 |
|
74483 | 74 |
if (Platform.is_macos) { |
76529 | 75 |
File.change(source_dir + Path.explode("Makefile")) { |
75202 | 76 |
_.replaceAll("--static", "").replaceAll("-Wl,-soname\\S+", "") |
77 |
} |
|
74483 | 78 |
} |
77510
f5d6cd98b16a
clarified signature: manage "verbose" flag via "progress";
wenzelm
parents:
76548
diff
changeset
|
79 |
progress.bash("make r", source_dir.file, echo = progress.verbose).check |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
80 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
81 |
Isabelle_System.copy_file( |
76529 | 82 |
source_dir + Path.explode("build/release/bin/minisat").platform_exe, platform_dir) |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
83 |
|
74734
f345da8defff
repackage minisat-2.2.1 with cygwin1.dll: required to run the executable without existing Cygwin context (normally provided by bash_process);
wenzelm
parents:
74484
diff
changeset
|
84 |
if (Platform.is_windows) { |
f345da8defff
repackage minisat-2.2.1 with cygwin1.dll: required to run the executable without existing Cygwin context (normally provided by bash_process);
wenzelm
parents:
74484
diff
changeset
|
85 |
Isabelle_System.copy_file(Path.explode("/bin/cygwin1.dll"), platform_dir) |
f345da8defff
repackage minisat-2.2.1 with cygwin1.dll: required to run the executable without existing Cygwin context (normally provided by bash_process);
wenzelm
parents:
74484
diff
changeset
|
86 |
} |
f345da8defff
repackage minisat-2.2.1 with cygwin1.dll: required to run the executable without existing Cygwin context (normally provided by bash_process);
wenzelm
parents:
74484
diff
changeset
|
87 |
|
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
88 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
89 |
/* settings */ |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
90 |
|
76548 | 91 |
component_dir.write_settings(""" |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
92 |
MINISAT_HOME="$COMPONENT/$ISABELLE_PLATFORM64" |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
93 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
94 |
ISABELLE_MINISAT="$MINISAT_HOME/minisat" |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
95 |
""") |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
96 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
97 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
98 |
/* README */ |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
99 |
|
76518 | 100 |
File.write(component_dir.README, |
74484 | 101 |
"This Isabelle component provides Minisat " + version + """ using the |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
102 |
sources from """.stripMargin + download_url + """ |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
103 |
|
74483 | 104 |
The executables have been built via "make r"; macOS requires to |
105 |
remove options "--static" and "-Wl,-soname,..." from the Makefile. |
|
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
106 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
107 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
108 |
Makarius |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
109 |
""" + Date.Format.date(Date.now()) + "\n") |
75394 | 110 |
} |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
111 |
} |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
112 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
113 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
114 |
/* Isabelle tool wrapper */ |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
115 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
116 |
val isabelle_tool = |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77510
diff
changeset
|
117 |
Isabelle_Tool("component_minisat", "build prover component from sources", Scala_Project.here, |
75394 | 118 |
{ args => |
119 |
var target_dir = Path.current |
|
120 |
var download_url = default_download_url |
|
121 |
var component_name = "" |
|
122 |
var verbose = false |
|
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
123 |
|
75394 | 124 |
val getopts = Getopts(""" |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
77510
diff
changeset
|
125 |
Usage: isabelle component_minisat [OPTIONS] |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
126 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
127 |
Options are: |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
128 |
-D DIR target directory (default ".") |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
129 |
-U URL download URL |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
130 |
(default: """" + default_download_url + """") |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
131 |
-n NAME component name (default: """" + make_component_name("VERSION") + """") |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
132 |
-v verbose |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
133 |
|
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
134 |
Build prover component from official download. |
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
135 |
""", |
75394 | 136 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
137 |
"U:" -> (arg => download_url = arg), |
|
138 |
"n:" -> (arg => component_name = arg), |
|
139 |
"v" -> (_ => verbose = true)) |
|
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
140 |
|
75394 | 141 |
val more_args = getopts(args) |
142 |
if (more_args.nonEmpty) getopts.usage() |
|
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
143 |
|
77510
f5d6cd98b16a
clarified signature: manage "verbose" flag via "progress";
wenzelm
parents:
76548
diff
changeset
|
144 |
val progress = new Console_Progress(verbose = verbose) |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
145 |
|
75394 | 146 |
build_minisat(download_url = download_url, component_name = component_name, |
77510
f5d6cd98b16a
clarified signature: manage "verbose" flag via "progress";
wenzelm
parents:
76548
diff
changeset
|
147 |
progress = progress, target_dir = target_dir) |
75394 | 148 |
}) |
74482
bd5998580edb
build minisat, using recent fork from original sources;
wenzelm
parents:
diff
changeset
|
149 |
} |