76443
|
1 |
/* Title: Pure/Admin/build_llncs.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Build Isabelle component for Springer LaTeX LNCS style.
|
|
5 |
|
|
6 |
See also:
|
|
7 |
|
|
8 |
- https://ctan.org/pkg/llncs?lang=en
|
|
9 |
- https://www.springer.com/gp/computer-science/lncs/conference-proceedings-guidelines
|
|
10 |
*/
|
|
11 |
|
|
12 |
package isabelle
|
|
13 |
|
|
14 |
|
|
15 |
object Build_LLNCS {
|
|
16 |
/* build llncs component */
|
|
17 |
|
|
18 |
val default_url = "https://mirrors.ctan.org/macros/latex/contrib/llncs.zip"
|
|
19 |
|
|
20 |
def build_llncs(
|
|
21 |
download_url: String = default_url,
|
|
22 |
target_dir: Path = Path.current,
|
|
23 |
progress: Progress = new Progress
|
|
24 |
): Unit = {
|
|
25 |
Isabelle_System.with_tmp_file("download", ext = "zip") { download_file =>
|
|
26 |
Isabelle_System.with_tmp_dir("download") { download_dir =>
|
|
27 |
|
|
28 |
/* download */
|
|
29 |
|
|
30 |
Isabelle_System.download_file(download_url, download_file, progress = progress)
|
76530
|
31 |
Isabelle_System.extract(download_file, download_dir)
|
76443
|
32 |
|
76529
|
33 |
val llncs_dir = File.get_dir(download_dir, title = download_url)
|
76443
|
34 |
|
|
35 |
|
|
36 |
/* component */
|
|
37 |
|
76546
|
38 |
val README_md = Path.explode("README.md")
|
76443
|
39 |
val version = {
|
|
40 |
val Version = """^_.* v(.*)_$""".r
|
76546
|
41 |
split_lines(File.read(llncs_dir + README_md))
|
76443
|
42 |
.collectFirst({ case Version(v) => v })
|
76546
|
43 |
.getOrElse(error("Failed to detect version in " + README_md))
|
76443
|
44 |
}
|
|
45 |
|
|
46 |
val component = "llncs-" + version
|
76518
|
47 |
val component_dir =
|
|
48 |
Components.Directory.create(target_dir + Path.basic(component), progress = progress)
|
76443
|
49 |
|
76546
|
50 |
Isabelle_System.extract(download_file, component_dir.path, strip = true)
|
76443
|
51 |
|
|
52 |
|
|
53 |
/* settings */
|
|
54 |
|
76518
|
55 |
File.write(component_dir.settings,
|
76443
|
56 |
"""# -*- shell-script -*- :mode=shellscript:
|
|
57 |
|
|
58 |
ISABELLE_LLNCS_HOME="$COMPONENT"
|
|
59 |
""")
|
|
60 |
|
|
61 |
|
|
62 |
/* README */
|
|
63 |
|
76546
|
64 |
File.change(component_dir.path + README_md)(_.replace(" ", "\u00a0"))
|
|
65 |
|
76518
|
66 |
File.write(component_dir.README,
|
76443
|
67 |
"""This is the Springer LaTeX LNCS style for authors from
|
|
68 |
""" + download_url + """
|
|
69 |
|
|
70 |
|
|
71 |
Makarius
|
|
72 |
""" + Date.Format.date(Date.now()) + "\n")
|
|
73 |
}
|
|
74 |
}
|
|
75 |
}
|
|
76 |
|
|
77 |
|
|
78 |
/* Isabelle tool wrapper */
|
|
79 |
|
|
80 |
val isabelle_tool =
|
|
81 |
Isabelle_Tool("build_llncs", "build component for Springer LaTeX LNCS style",
|
|
82 |
Scala_Project.here,
|
|
83 |
{ args =>
|
|
84 |
var target_dir = Path.current
|
|
85 |
var download_url = default_url
|
|
86 |
|
|
87 |
val getopts = Getopts("""
|
|
88 |
Usage: isabelle build_llncs [OPTIONS]
|
|
89 |
|
|
90 |
Options are:
|
|
91 |
-D DIR target directory (default ".")
|
|
92 |
-U URL download URL (default: """" + default_url + """")
|
|
93 |
|
|
94 |
Build component for Springer LaTeX LNCS style.
|
|
95 |
""",
|
|
96 |
"D:" -> (arg => target_dir = Path.explode(arg)),
|
|
97 |
"U:" -> (arg => download_url = arg))
|
|
98 |
|
|
99 |
val more_args = getopts(args)
|
|
100 |
if (more_args.nonEmpty) getopts.usage()
|
|
101 |
|
|
102 |
val progress = new Console_Progress()
|
|
103 |
|
|
104 |
build_llncs(download_url = download_url, target_dir = target_dir, progress = progress)
|
|
105 |
})
|
|
106 |
}
|