76478
|
1 |
/* Title: Pure/Admin/build_eptcs.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
76479
|
4 |
Build Isabelle component for EPTCS LaTeX style.
|
76478
|
5 |
|
|
6 |
See also:
|
|
7 |
- http://style.eptcs.org
|
|
8 |
- https://github.com/EPTCS/style/releases
|
|
9 |
*/
|
|
10 |
|
|
11 |
package isabelle
|
|
12 |
|
|
13 |
|
|
14 |
object Build_EPTCS {
|
|
15 |
/* build eptcs component */
|
|
16 |
|
|
17 |
val default_url = "https://github.com/EPTCS/style/releases/download"
|
|
18 |
val default_version = "1.7.0"
|
|
19 |
|
|
20 |
def build_eptcs(
|
|
21 |
base_url: String = default_url,
|
|
22 |
version: String = default_version,
|
|
23 |
target_dir: Path = Path.current,
|
|
24 |
progress: Progress = new Progress
|
|
25 |
): Unit = {
|
|
26 |
/* component */
|
|
27 |
|
|
28 |
val component = "eptcs-" + version
|
76518
|
29 |
val component_dir =
|
76547
|
30 |
Components.Directory(target_dir + Path.basic(component)).create(progress = progress)
|
76478
|
31 |
|
|
32 |
|
|
33 |
/* download */
|
|
34 |
|
|
35 |
val download_url = base_url + "/v" + version + "/eptcsstyle.zip"
|
|
36 |
|
|
37 |
Isabelle_System.with_tmp_file("download", ext = "zip") { download_file =>
|
|
38 |
Isabelle_System.download_file(download_url, download_file, progress = progress)
|
76530
|
39 |
Isabelle_System.extract(download_file, component_dir.path)
|
76478
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
/* settings */
|
|
44 |
|
76548
|
45 |
component_dir.write_settings("""
|
76478
|
46 |
ISABELLE_EPTCS_HOME="$COMPONENT"
|
|
47 |
""")
|
|
48 |
|
|
49 |
|
|
50 |
/* README */
|
|
51 |
|
76518
|
52 |
File.write(component_dir.README,
|
76478
|
53 |
"""This is the EPTCS style from
|
|
54 |
""" + download_url + """
|
|
55 |
|
|
56 |
|
|
57 |
Makarius
|
|
58 |
""" + Date.Format.date(Date.now()) + "\n")
|
|
59 |
}
|
|
60 |
|
|
61 |
|
|
62 |
/* Isabelle tool wrapper */
|
|
63 |
|
|
64 |
val isabelle_tool =
|
76479
|
65 |
Isabelle_Tool("build_eptcs", "build component for EPTCS LaTeX style",
|
76478
|
66 |
Scala_Project.here,
|
|
67 |
{ args =>
|
|
68 |
var target_dir = Path.current
|
|
69 |
var base_url = default_url
|
|
70 |
var version = default_version
|
|
71 |
|
|
72 |
val getopts = Getopts("""
|
|
73 |
Usage: isabelle build_eptcs [OPTIONS]
|
|
74 |
|
|
75 |
Options are:
|
|
76 |
-D DIR target directory (default ".")
|
|
77 |
-U URL download URL (default: """" + default_url + """")
|
|
78 |
-V VERSION version (default: """" + default_version + """")
|
|
79 |
|
76479
|
80 |
Build component for EPTCS LaTeX style.
|
76478
|
81 |
""",
|
|
82 |
"D:" -> (arg => target_dir = Path.explode(arg)),
|
|
83 |
"U:" -> (arg => base_url = arg),
|
|
84 |
"V:" -> (arg => version = arg))
|
|
85 |
|
|
86 |
val more_args = getopts(args)
|
|
87 |
if (more_args.nonEmpty) getopts.usage()
|
|
88 |
|
|
89 |
val progress = new Console_Progress()
|
|
90 |
|
|
91 |
build_eptcs(base_url = base_url, version = version, target_dir = target_dir,
|
|
92 |
progress = progress)
|
|
93 |
})
|
|
94 |
}
|