81607
|
1 |
/* Title: Pure/Admin/component_xz.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Build Isabelle xz-java component from official download.
|
|
5 |
*/
|
|
6 |
|
|
7 |
package isabelle
|
|
8 |
|
|
9 |
|
|
10 |
object Component_XZ {
|
|
11 |
/* build xz */
|
|
12 |
|
|
13 |
val main_url = "https://tukaani.org/xz/java.html"
|
|
14 |
val default_source_url = "https://github.com/tukaani-project/xz-java/releases/download"
|
|
15 |
val default_download_url = "https://repo1.maven.org/maven2/org/tukaani/xz"
|
|
16 |
val default_version = "1.10"
|
|
17 |
|
|
18 |
def build_xz(
|
|
19 |
target_dir: Path = Path.current,
|
|
20 |
source_url: String = default_source_url,
|
|
21 |
download_url: String = default_download_url,
|
|
22 |
version: String = default_version,
|
|
23 |
progress: Progress = new Progress,
|
|
24 |
): Unit = {
|
|
25 |
/* component */
|
|
26 |
|
|
27 |
val component_name = "xz-java-" + version
|
|
28 |
val component_dir =
|
|
29 |
Components.Directory(target_dir + Path.basic(component_name)).create(progress = progress)
|
|
30 |
|
|
31 |
File.write(component_dir.README,
|
|
32 |
"This is " + component_name + " from " + main_url +
|
|
33 |
"\n\n Makarius\n " + Date.Format.date(Date.now()) + "\n")
|
|
34 |
|
|
35 |
Isabelle_System.with_tmp_file("tmp", ext = "zip") { tmp =>
|
|
36 |
Isabelle_System.download_file(
|
|
37 |
source_url + "/v" + version + "/xz-java-" + version + ".zip", tmp, progress = progress)
|
|
38 |
Isabelle_System.extract(tmp, component_dir.path)
|
|
39 |
}
|
|
40 |
|
|
41 |
|
|
42 |
/* lib */
|
|
43 |
|
|
44 |
val jar_name = "xz-" + version + ".jar"
|
|
45 |
|
|
46 |
Isabelle_System.make_directory(component_dir.lib)
|
|
47 |
Isabelle_System.download_file(
|
|
48 |
download_url + "/" + version + "/" + jar_name,
|
|
49 |
component_dir.lib + Path.basic(jar_name), progress = progress)
|
|
50 |
|
|
51 |
|
|
52 |
/* settings */
|
|
53 |
|
|
54 |
component_dir.write_settings("""
|
|
55 |
ISABELLE_XZ_HOME="$COMPONENT"
|
|
56 |
|
|
57 |
classpath "$ISABELLE_XZ_HOME/lib/""" + jar_name + """"
|
|
58 |
""")
|
|
59 |
}
|
|
60 |
|
|
61 |
|
|
62 |
/* Isabelle tool wrapper */
|
|
63 |
|
|
64 |
val isabelle_tool =
|
|
65 |
Isabelle_Tool("component_xz", "build Isabelle xz-java component from official download",
|
|
66 |
Scala_Project.here,
|
|
67 |
{ args =>
|
|
68 |
var target_dir = Path.current
|
|
69 |
var source_url = default_source_url
|
|
70 |
var download_url = default_download_url
|
|
71 |
var version = default_version
|
|
72 |
|
|
73 |
val getopts = Getopts("""
|
|
74 |
Usage: isabelle component_xz [OPTIONS]
|
|
75 |
|
|
76 |
Options are:
|
|
77 |
-D DIR target directory (default ".")
|
|
78 |
-S URL source URL (default: """ + quote(default_source_url) + """)
|
|
79 |
-U URL download URL (default: """ + quote(default_download_url) + """)
|
|
80 |
-V VERSION version (default: """ + quote(default_version) + """)
|
|
81 |
|
81608
|
82 |
Build xz-java component from the specified download base URL and VERSION,
|
81607
|
83 |
see also """ + main_url + "\n",
|
|
84 |
"D:" -> (arg => target_dir = Path.explode(arg)),
|
|
85 |
"S:" -> (arg => source_url = arg),
|
|
86 |
"U:" -> (arg => download_url = arg),
|
|
87 |
"V:" -> (arg => version = arg))
|
|
88 |
|
|
89 |
val more_args = getopts(args)
|
|
90 |
if (more_args.nonEmpty) getopts.usage()
|
|
91 |
|
|
92 |
val progress = new Console_Progress()
|
|
93 |
|
|
94 |
build_xz(target_dir = target_dir, source_url = source_url,
|
|
95 |
download_url = download_url, version = version, progress = progress)
|
|
96 |
})
|
|
97 |
}
|