64202
|
1 |
/* Title: Pure/Admin/build_release.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Build full Isabelle distribution from repository.
|
|
5 |
*/
|
|
6 |
|
|
7 |
package isabelle
|
|
8 |
|
|
9 |
|
|
10 |
object Build_Release
|
|
11 |
{
|
64361
|
12 |
sealed case class Bundle_Info(
|
|
13 |
platform_family: String,
|
|
14 |
platform_description: String,
|
|
15 |
main_bundle: String,
|
|
16 |
fallback_bundle: Option[String])
|
|
17 |
{
|
|
18 |
def all_bundles: List[String] = main_bundle :: fallback_bundle.toList
|
|
19 |
}
|
|
20 |
|
64203
|
21 |
sealed case class Release_Info(
|
64221
|
22 |
date: Date, name: String, dist_dir: Path, dist_archive: Path, dist_library_archive: Path,
|
|
23 |
id: String)
|
64361
|
24 |
{
|
|
25 |
val bundle_infos: List[Bundle_Info] =
|
|
26 |
List(Bundle_Info("linux", "Linux", name + "_app.tar.gz", None),
|
|
27 |
Bundle_Info("windows", "Windows (32bit)", name + "-win32.exe", None),
|
|
28 |
Bundle_Info("windows64", "Windows (64bit)", name + "-win64.exe", None),
|
|
29 |
Bundle_Info("macos", "Mac OS X", name + ".dmg", Some(name + "_dmg.tar.gz")))
|
|
30 |
|
|
31 |
def bundle_info(platform_family: String): Bundle_Info =
|
|
32 |
bundle_infos.find(info => info.platform_family == platform_family) getOrElse
|
|
33 |
error("Unknown platform family " + quote(platform_family))
|
|
34 |
}
|
|
35 |
|
64203
|
36 |
|
64208
|
37 |
private val default_platform_families = List("linux", "windows", "windows64", "macos")
|
64204
|
38 |
|
64202
|
39 |
def build_release(base_dir: Path,
|
|
40 |
progress: Progress = Ignore_Progress,
|
|
41 |
rev: String = "",
|
|
42 |
official_release: Boolean = false,
|
|
43 |
release_name: String = "",
|
64208
|
44 |
platform_families: List[String] = default_platform_families,
|
64211
|
45 |
website: Option[Path] = None,
|
64202
|
46 |
build_library: Boolean = false,
|
|
47 |
parallel_jobs: Int = 1,
|
64203
|
48 |
remote_mac: String = ""): Release_Info =
|
64202
|
49 |
{
|
|
50 |
/* release info */
|
|
51 |
|
64203
|
52 |
val release_info =
|
|
53 |
{
|
|
54 |
val date = Date.now()
|
|
55 |
val name = if (release_name != "") release_name else "Isabelle_" + Date.Format.date(date)
|
|
56 |
val dist_dir = base_dir + Path.explode("dist-" + name)
|
|
57 |
val dist_archive = dist_dir + Path.explode(name + ".tar.gz")
|
|
58 |
val dist_library_archive = dist_dir + Path.explode(name + "_library.tar.gz")
|
64221
|
59 |
Release_Info(date, name, dist_dir, dist_archive, dist_library_archive, "")
|
64203
|
60 |
}
|
64202
|
61 |
|
64361
|
62 |
val bundle_infos = platform_families.map(release_info.bundle_info(_))
|
64204
|
63 |
|
64202
|
64 |
|
|
65 |
/* make distribution */
|
|
66 |
|
64203
|
67 |
val jobs_option = " -j" + parallel_jobs.toString
|
|
68 |
|
64221
|
69 |
val release_id =
|
|
70 |
{
|
|
71 |
val isabelle_ident_file = base_dir + Path.explode("ISABELLE_IDENT")
|
|
72 |
val isabelle_dist_file = base_dir + Path.explode("ISABELLE_DIST")
|
|
73 |
|
|
74 |
if (release_info.dist_archive.is_file &&
|
|
75 |
isabelle_ident_file.is_file && isabelle_dist_file.is_file &&
|
|
76 |
File.eq(Path.explode(Library.trim_line(File.read(isabelle_dist_file))),
|
|
77 |
release_info.dist_archive)) {
|
|
78 |
progress.echo("### Release archive already exists: " + release_info.dist_archive.implode)
|
|
79 |
}
|
|
80 |
else {
|
|
81 |
progress.echo("Producing release archive " + release_info.dist_archive.implode + " ...")
|
|
82 |
progress.bash(
|
|
83 |
"isabelle makedist -d " + File.bash_path(base_dir) + jobs_option +
|
|
84 |
(if (official_release) " -O" else "") +
|
64304
|
85 |
(if (release_name != "") " -r " + Bash.string(release_name) else "") +
|
|
86 |
(if (rev != "") " " + Bash.string(rev) else ""),
|
64221
|
87 |
echo = true).check
|
|
88 |
}
|
|
89 |
Library.trim_line(File.read(isabelle_ident_file))
|
64203
|
90 |
}
|
64202
|
91 |
|
|
92 |
|
|
93 |
/* make application bundles */
|
|
94 |
|
64361
|
95 |
for (info <- bundle_infos) {
|
|
96 |
val bundle =
|
|
97 |
(if (remote_mac.isEmpty) info.fallback_bundle else None) getOrElse info.main_bundle
|
|
98 |
val bundle_archive = release_info.dist_dir + Path.explode(bundle)
|
64203
|
99 |
if (bundle_archive.is_file)
|
64209
|
100 |
progress.echo("### Application bundle already exists: " + bundle_archive.implode)
|
64203
|
101 |
else {
|
64361
|
102 |
progress.echo(
|
|
103 |
"\nApplication bundle for " + info.platform_family + ": " + bundle_archive.implode)
|
64203
|
104 |
progress.bash(
|
|
105 |
"isabelle makedist_bundle " + File.bash_path(release_info.dist_archive) +
|
64361
|
106 |
" " + Bash.string(info.platform_family) +
|
64304
|
107 |
(if (remote_mac == "") "" else " " + Bash.string(remote_mac)),
|
64203
|
108 |
echo = true).check
|
|
109 |
}
|
64202
|
110 |
}
|
|
111 |
|
|
112 |
|
|
113 |
/* minimal website */
|
|
114 |
|
64361
|
115 |
for (dir <- website) {
|
|
116 |
val website_platform_bundles =
|
|
117 |
for {
|
|
118 |
info <- bundle_infos
|
|
119 |
bundle <-
|
|
120 |
info.all_bundles.find(name => (release_info.dist_dir + Path.explode(name)).is_file)
|
|
121 |
} yield (bundle, info)
|
64206
|
122 |
|
64361
|
123 |
Isabelle_System.mkdirs(dir)
|
64211
|
124 |
|
64361
|
125 |
File.write(dir + Path.explode("index.html"),
|
|
126 |
HTML.output_document(
|
|
127 |
List(HTML.title(release_info.name)),
|
|
128 |
List(
|
|
129 |
HTML.chapter(release_info.name + " (" + release_id + ")"),
|
|
130 |
HTML.itemize(
|
|
131 |
website_platform_bundles.map({ case (bundle, info) =>
|
|
132 |
List(HTML.link(bundle, HTML.text(info.platform_description))) })))))
|
64202
|
133 |
|
64361
|
134 |
for ((bundle, _) <- website_platform_bundles)
|
|
135 |
File.copy(release_info.dist_dir + Path.explode(bundle), dir)
|
|
136 |
}
|
64202
|
137 |
|
|
138 |
|
|
139 |
/* HTML library */
|
|
140 |
|
64203
|
141 |
if (build_library) {
|
|
142 |
if (release_info.dist_library_archive.is_file)
|
64209
|
143 |
progress.echo("### Library archive already exists: " +
|
|
144 |
release_info.dist_library_archive.implode)
|
64203
|
145 |
else {
|
64316
|
146 |
Isabelle_System.with_tmp_dir("build_release")(tmp_dir =>
|
|
147 |
{
|
|
148 |
def execute(script: String): Unit =
|
|
149 |
Isabelle_System.bash(script, cwd = tmp_dir.file).check
|
|
150 |
|
|
151 |
val name = release_info.name
|
|
152 |
val platform = Isabelle_System.getenv_strict("ISABELLE_PLATFORM_FAMILY")
|
|
153 |
val bundle = release_info.dist_dir + Path.explode(name + "_" + platform + ".tar.gz")
|
|
154 |
execute("tar xzf " + File.bash_path(bundle))
|
|
155 |
|
|
156 |
val other_isabelle =
|
|
157 |
new Other_Isabelle(progress, tmp_dir + Path.explode(name), name + "-build")
|
|
158 |
|
|
159 |
other_isabelle.bash("bin/isabelle build" + jobs_option +
|
|
160 |
" -o browser_info -o document=pdf -o document_variants=document:outline=/proof,/ML" +
|
|
161 |
" -s -c -a -d '~~/src/Benchmarks'", echo = true).check
|
|
162 |
other_isabelle.isabelle_home_user.file.delete
|
|
163 |
|
|
164 |
execute("chmod -R a+r " + Bash.string(name))
|
|
165 |
execute("chmod -R g=o " + Bash.string(name))
|
|
166 |
execute("tar czf " + File.bash_path(release_info.dist_library_archive) +
|
|
167 |
" " + Bash.string(name + "/browser_info"))
|
|
168 |
})
|
64203
|
169 |
}
|
|
170 |
}
|
|
171 |
|
|
172 |
|
64221
|
173 |
release_info.copy(id = release_id)
|
64202
|
174 |
}
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
/** command line entry point **/
|
|
179 |
|
|
180 |
def main(args: Array[String])
|
|
181 |
{
|
|
182 |
Command_Line.tool0 {
|
|
183 |
var remote_mac = ""
|
|
184 |
var official_release = false
|
|
185 |
var release_name = ""
|
64211
|
186 |
var website: Option[Path] = None
|
64202
|
187 |
var parallel_jobs = 1
|
|
188 |
var build_library = false
|
64208
|
189 |
var platform_families = default_platform_families
|
64202
|
190 |
var rev = ""
|
|
191 |
|
|
192 |
val getopts = Getopts("""
|
|
193 |
Usage: Admin/build_release [OPTIONS] BASE_DIR
|
|
194 |
|
|
195 |
Options are:
|
|
196 |
-M USER@HOST remote Mac OS X for dmg build
|
|
197 |
-O official release (not release-candidate)
|
|
198 |
-R RELEASE proper release with name
|
64211
|
199 |
-W WEBSITE produce minimal website in given directory
|
64202
|
200 |
-j INT maximum number of parallel jobs (default 1)
|
|
201 |
-l build library
|
64204
|
202 |
-p NAMES platform families (comma separated list, default: """ +
|
64208
|
203 |
default_platform_families.mkString(",") + """)
|
64202
|
204 |
-r REV Mercurial changeset id (default: RELEASE or tip)
|
|
205 |
|
|
206 |
Build Isabelle release in base directory, using the local repository clone.
|
|
207 |
""",
|
|
208 |
"M:" -> (arg => remote_mac = arg),
|
|
209 |
"O" -> (_ => official_release = true),
|
|
210 |
"R:" -> (arg => release_name = arg),
|
64211
|
211 |
"W:" -> (arg => website = Some(Path.explode(arg))),
|
64202
|
212 |
"j:" -> (arg => parallel_jobs = Value.Int.parse(arg)),
|
64316
|
213 |
"l" -> (_ => build_library = true),
|
64204
|
214 |
"p:" -> (arg => platform_families = Library.space_explode(',', arg)),
|
|
215 |
"r:" -> (arg => rev = arg))
|
64202
|
216 |
|
|
217 |
val more_args = getopts(args)
|
|
218 |
val base_dir = more_args match { case List(base_dir) => base_dir case _ => getopts.usage() }
|
|
219 |
|
|
220 |
val progress = new Console_Progress()
|
|
221 |
|
|
222 |
build_release(Path.explode(base_dir), progress = progress, rev = rev,
|
64211
|
223 |
official_release = official_release, release_name = release_name, website = website,
|
64204
|
224 |
platform_families =
|
64208
|
225 |
if (platform_families.isEmpty) default_platform_families else platform_families,
|
64202
|
226 |
build_library = build_library, parallel_jobs = parallel_jobs, remote_mac = remote_mac)
|
|
227 |
}
|
|
228 |
}
|
|
229 |
}
|