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 |
{
|
64203
|
12 |
sealed case class Release_Info(
|
64221
|
13 |
date: Date, name: String, dist_dir: Path, dist_archive: Path, dist_library_archive: Path,
|
|
14 |
id: String)
|
64203
|
15 |
|
64208
|
16 |
private val default_platform_families = List("linux", "windows", "windows64", "macos")
|
64204
|
17 |
|
64202
|
18 |
def build_release(base_dir: Path,
|
|
19 |
progress: Progress = Ignore_Progress,
|
|
20 |
rev: String = "",
|
|
21 |
official_release: Boolean = false,
|
|
22 |
release_name: String = "",
|
64208
|
23 |
platform_families: List[String] = default_platform_families,
|
64211
|
24 |
website: Option[Path] = None,
|
64202
|
25 |
build_library: Boolean = false,
|
|
26 |
parallel_jobs: Int = 1,
|
64203
|
27 |
remote_mac: String = ""): Release_Info =
|
64202
|
28 |
{
|
|
29 |
/* release info */
|
|
30 |
|
64203
|
31 |
val release_info =
|
|
32 |
{
|
|
33 |
val date = Date.now()
|
|
34 |
val name = if (release_name != "") release_name else "Isabelle_" + Date.Format.date(date)
|
|
35 |
val dist_dir = base_dir + Path.explode("dist-" + name)
|
|
36 |
val dist_archive = dist_dir + Path.explode(name + ".tar.gz")
|
|
37 |
val dist_library_archive = dist_dir + Path.explode(name + "_library.tar.gz")
|
64221
|
38 |
Release_Info(date, name, dist_dir, dist_archive, dist_library_archive, "")
|
64203
|
39 |
}
|
64202
|
40 |
|
64208
|
41 |
val main_platform_bundles =
|
|
42 |
List("linux" -> (release_info.name + "_app.tar.gz"),
|
64204
|
43 |
"windows" -> (release_info.name + "-win32.exe"),
|
|
44 |
"windows64" -> (release_info.name + "-win64.exe"),
|
|
45 |
"macos" -> (release_info.name + ".dmg"))
|
|
46 |
|
64208
|
47 |
val fallback_platform_bundles =
|
|
48 |
List("macos" -> (release_info.name + "_dmg.tar.gz"))
|
|
49 |
|
64204
|
50 |
val platform_bundles =
|
|
51 |
for (platform_family <- platform_families) yield {
|
64208
|
52 |
main_platform_bundles.toMap.get(platform_family) match {
|
64204
|
53 |
case None => error("Unknown platform family " + quote(platform_family))
|
|
54 |
case Some(bundle) => (platform_family, bundle)
|
|
55 |
}
|
|
56 |
}
|
|
57 |
|
64202
|
58 |
|
|
59 |
/* make distribution */
|
|
60 |
|
64203
|
61 |
val jobs_option = " -j" + parallel_jobs.toString
|
|
62 |
|
64221
|
63 |
val release_id =
|
|
64 |
{
|
|
65 |
val isabelle_ident_file = base_dir + Path.explode("ISABELLE_IDENT")
|
|
66 |
val isabelle_dist_file = base_dir + Path.explode("ISABELLE_DIST")
|
|
67 |
|
|
68 |
if (release_info.dist_archive.is_file &&
|
|
69 |
isabelle_ident_file.is_file && isabelle_dist_file.is_file &&
|
|
70 |
File.eq(Path.explode(Library.trim_line(File.read(isabelle_dist_file))),
|
|
71 |
release_info.dist_archive)) {
|
|
72 |
progress.echo("### Release archive already exists: " + release_info.dist_archive.implode)
|
|
73 |
}
|
|
74 |
else {
|
|
75 |
progress.echo("Producing release archive " + release_info.dist_archive.implode + " ...")
|
|
76 |
progress.bash(
|
|
77 |
"isabelle makedist -d " + File.bash_path(base_dir) + jobs_option +
|
|
78 |
(if (official_release) " -O" else "") +
|
64304
|
79 |
(if (release_name != "") " -r " + Bash.string(release_name) else "") +
|
|
80 |
(if (rev != "") " " + Bash.string(rev) else ""),
|
64221
|
81 |
echo = true).check
|
|
82 |
}
|
|
83 |
Library.trim_line(File.read(isabelle_ident_file))
|
64203
|
84 |
}
|
64202
|
85 |
|
|
86 |
|
|
87 |
/* make application bundles */
|
|
88 |
|
64204
|
89 |
for ((platform_family, platform_bundle) <- platform_bundles) {
|
64203
|
90 |
val bundle_archive =
|
64210
|
91 |
release_info.dist_dir +
|
|
92 |
Path.explode(
|
|
93 |
(if (remote_mac.isEmpty) fallback_platform_bundles.toMap.get(platform_family) else None)
|
|
94 |
getOrElse platform_bundle)
|
64203
|
95 |
if (bundle_archive.is_file)
|
64209
|
96 |
progress.echo("### Application bundle already exists: " + bundle_archive.implode)
|
64203
|
97 |
else {
|
64209
|
98 |
progress.echo("\nApplication bundle for " + platform_family + ": " + bundle_archive.implode)
|
64203
|
99 |
progress.bash(
|
|
100 |
"isabelle makedist_bundle " + File.bash_path(release_info.dist_archive) +
|
64304
|
101 |
" " + Bash.string(platform_family) +
|
|
102 |
(if (remote_mac == "") "" else " " + Bash.string(remote_mac)),
|
64203
|
103 |
echo = true).check
|
|
104 |
}
|
64202
|
105 |
}
|
|
106 |
|
|
107 |
|
|
108 |
/* minimal website */
|
|
109 |
|
64211
|
110 |
website.foreach(dir =>
|
|
111 |
{
|
|
112 |
val website_platform_bundles =
|
|
113 |
Library.distinct(
|
|
114 |
for {
|
|
115 |
(a, b) <- main_platform_bundles ::: fallback_platform_bundles
|
|
116 |
p = release_info.dist_dir + Path.explode(b)
|
|
117 |
if p.is_file
|
|
118 |
} yield (a, b), (x: (String, String), y: (String, String)) => x._1 == y._1)
|
64206
|
119 |
|
64211
|
120 |
Isabelle_System.mkdirs(dir)
|
|
121 |
|
|
122 |
File.write(dir + Path.explode("index.html"),
|
64202
|
123 |
"""<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
124 |
<html>
|
|
125 |
<head>
|
64203
|
126 |
<title>""" + HTML.output(release_info.name) + """</title>
|
64202
|
127 |
</head>
|
|
128 |
|
|
129 |
<body>
|
64221
|
130 |
<h1>""" + HTML.output(release_info.name + " (" + release_id + ")") + """</h1>
|
64202
|
131 |
<ul>
|
64203
|
132 |
""" +
|
64211
|
133 |
cat_lines(website_platform_bundles.map({ case (a, b) =>
|
64212
|
134 |
"<li><a href=" + quote(HTML.output(b)) + ">" + HTML.output(Word.capitalize(a)) + "</a></li>" })) +
|
64203
|
135 |
"""
|
64202
|
136 |
</ul>
|
|
137 |
</body>
|
|
138 |
|
|
139 |
</html>
|
|
140 |
""")
|
64211
|
141 |
for ((_, b) <- website_platform_bundles)
|
|
142 |
File.copy(release_info.dist_dir + Path.explode(b), dir)
|
|
143 |
})
|
64202
|
144 |
|
|
145 |
|
|
146 |
/* HTML library */
|
|
147 |
|
64203
|
148 |
if (build_library) {
|
|
149 |
if (release_info.dist_library_archive.is_file)
|
64209
|
150 |
progress.echo("### Library archive already exists: " +
|
|
151 |
release_info.dist_library_archive.implode)
|
64203
|
152 |
else {
|
|
153 |
progress.bash("\"$ISABELLE_HOME/Admin/Release/build_library\"" + jobs_option + " " +
|
|
154 |
File.bash_path(release_info.dist_dir +
|
|
155 |
Path.explode(release_info.name + "_" +
|
|
156 |
Isabelle_System.getenv_strict("ISABELLE_PLATFORM_FAMILY") + ".tar.gz"))).check
|
|
157 |
}
|
|
158 |
}
|
|
159 |
|
|
160 |
|
64221
|
161 |
release_info.copy(id = release_id)
|
64202
|
162 |
}
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
/** command line entry point **/
|
|
167 |
|
|
168 |
def main(args: Array[String])
|
|
169 |
{
|
|
170 |
Command_Line.tool0 {
|
|
171 |
var remote_mac = ""
|
|
172 |
var official_release = false
|
|
173 |
var release_name = ""
|
64211
|
174 |
var website: Option[Path] = None
|
64202
|
175 |
var parallel_jobs = 1
|
|
176 |
var build_library = false
|
64208
|
177 |
var platform_families = default_platform_families
|
64202
|
178 |
var rev = ""
|
|
179 |
|
|
180 |
val getopts = Getopts("""
|
|
181 |
Usage: Admin/build_release [OPTIONS] BASE_DIR
|
|
182 |
|
|
183 |
Options are:
|
|
184 |
-M USER@HOST remote Mac OS X for dmg build
|
|
185 |
-O official release (not release-candidate)
|
|
186 |
-R RELEASE proper release with name
|
64211
|
187 |
-W WEBSITE produce minimal website in given directory
|
64202
|
188 |
-j INT maximum number of parallel jobs (default 1)
|
|
189 |
-l build library
|
64204
|
190 |
-p NAMES platform families (comma separated list, default: """ +
|
64208
|
191 |
default_platform_families.mkString(",") + """)
|
64202
|
192 |
-r REV Mercurial changeset id (default: RELEASE or tip)
|
|
193 |
|
|
194 |
Build Isabelle release in base directory, using the local repository clone.
|
|
195 |
""",
|
|
196 |
"M:" -> (arg => remote_mac = arg),
|
|
197 |
"O" -> (_ => official_release = true),
|
|
198 |
"R:" -> (arg => release_name = arg),
|
64211
|
199 |
"W:" -> (arg => website = Some(Path.explode(arg))),
|
64202
|
200 |
"j:" -> (arg => parallel_jobs = Value.Int.parse(arg)),
|
64204
|
201 |
"l" -> (_ => build_library),
|
|
202 |
"p:" -> (arg => platform_families = Library.space_explode(',', arg)),
|
|
203 |
"r:" -> (arg => rev = arg))
|
64202
|
204 |
|
|
205 |
val more_args = getopts(args)
|
|
206 |
val base_dir = more_args match { case List(base_dir) => base_dir case _ => getopts.usage() }
|
|
207 |
|
|
208 |
val progress = new Console_Progress()
|
|
209 |
|
|
210 |
build_release(Path.explode(base_dir), progress = progress, rev = rev,
|
64211
|
211 |
official_release = official_release, release_name = release_name, website = website,
|
64204
|
212 |
platform_families =
|
64208
|
213 |
if (platform_families.isEmpty) default_platform_families else platform_families,
|
64202
|
214 |
build_library = build_library, parallel_jobs = parallel_jobs, remote_mac = remote_mac)
|
|
215 |
}
|
|
216 |
}
|
|
217 |
}
|