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