forked from tuna/thuthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.lua
103 lines (85 loc) · 2.75 KB
/
build.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env texlua
module = "thuthesis"
supportdir = "./testfiles/support"
checksuppfiles = {"*.tex"}
demofiles = {"latexmkrc", "Makefile"}
docfiles = {
"CHANGELOG.md",
"thusetup.tex",
"data", "ref",
}
installfiles = {"*.cls", "*.bst", "*.bbx", "*.cbx", "tsinghua-name-bachelor.pdf"}
sourcefiles = {"*.dtx", "*.ins", "*.bst", "*.bbx", "*.cbx", "tsinghua-name-bachelor.pdf"}
tagfiles = {"*.dtx", "CHANGELOG.md", "package.json"}
textfiles = {"*.md","LICENSE"}
typesetdemofiles = {"thuthesis-example.tex", "spine.tex"}
excludetests = {
"06-*",
"07-*",
"09-*",
"*-hyperref",
}
checkengines = {"xetex"}
stdengine = "xetex"
checkconfigs = {
"build",
"testfiles/config-title-page",
"testfiles/config-title-page-en",
"testfiles/config-crossref",
"testfiles/config-nomencl",
"testfiles/config-bibtex",
"testfiles/config-biblatex",
}
-- include .tds.zip in build output
packtdszip = true
-- specify some files of their correct TDS locations
tdslocations = {
"bibtex/bst/thuthesis/*.bst",
"tex/latex/thuthesis/tsinghua-name-bachelor.pdf",
}
typesetexe = "xelatex"
unpackexe = "xetex"
bibtexexe = "bibtex"
bibtexopts = ""
biberopts = "--quiet"
checkopts = "-file-line-error -halt-on-error -interaction=nonstopmode"
typesetopts = "-shell-escape -file-line-error -halt-on-error -interaction=nonstopmode"
lvtext = ".tex"
maxprintline = 79 -- keep compatibility with existing test files
function docinit_hook()
for _, file in pairs({"dtx-style.sty"}) do
cp(file, unpackdir, typesetdir)
end
return 0
end
function update_tag(file, content, tagname, tagdate)
local url = "https://github.com/tuna/thuthesis"
local date = string.gsub(tagdate, "%-", "/")
if string.match(file, "%.dtx$") then
if string.match(content, "%d%d%d%d/%d%d/%d%d [0-9.]+") then
content = string.gsub(content, "%d%d%d%d/%d%d/%d%d [0-9.]+",
date .. " " .. tagname)
end
if string.match(content, "\\def\\version{[0-9.]+}") then
content = string.gsub(content, "\\def\\version{[0-9.]+}",
"\\def\\version{" .. tagname .. "}")
end
elseif string.match(file, "CHANGELOG.md") then
local previous = string.match(content, "/compare/(.*)%.%.%.HEAD")
local gittag = 'v' .. tagname
if gittag == previous then return content end
content = string.gsub(content,
"## %[Unreleased%]",
"## [Unreleased]\n\n## [" .. gittag .."] - " .. tagdate)
content = string.gsub(content,
previous .. "%.%.%.HEAD",
gittag .. "...HEAD\n" ..
string.format("%-14s", "[" .. gittag .. "]:") .. url .. "/compare/"
.. previous .. "..." .. gittag)
elseif string.match(file, "package.json") then
content = string.gsub(content,
"\"version\": \"[0-9.]+\"",
"\"version\": \"" .. tagname .. "\"")
end
return content
end