-
Notifications
You must be signed in to change notification settings - Fork 29
/
build.lua
executable file
·375 lines (324 loc) · 10.7 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
--[================[--
PARAMETERS
--]================]--
math.randomseed( os.time() )
module = "unicode-math"
sourcefiles = {"*.dtx","*.ins","unicode-math-table.tex"}
installfiles = {"*.sty","unicode-math-table.tex"}
typesetfiles = {"*.ltx"}
docfiles = {"um-doc-*.tex"}
textfiles = {"*.md","LICENSE"}
tagfiles = {"unicode-math.dtx","CHANGES.md"}
checkengines = {"xetex","luatex"}
typesetexe = "xelatex"
typesetopts = " -shell-escape -interaction=nonstopmode "
packtdszip = true
recordstatus = true
--[===[
DEV
--]===]
function os.capture(cmd)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
gitbranch = os.capture('git rev-parse --abbrev-ref HEAD')
specialformats = specialformats or {}
if gitbranch == "develop" then
specialformats.latex = {
xetex = {binary = "xetex", format = "xelatex-dev"},
luatex = {binary = "luahbtex", format = "lualatex-dev"},
}
end
--[=============[--
VERSION
--]=============]--
changeslisting = nil
do
local f = assert(io.open("CHANGES.md", "r"))
changeslisting = f:read("*all")
f:close()
end
currentchanges = string.match(changeslisting,"(## %S+ %(.-%).-)%s*## %S+ %(.-%)")
pkgversion = string.match(changeslisting,"## v(%S+) %(.-%)")
gittag = 'v'..pkgversion
print('Current version (from first entry in CHANGES.md): '..pkgversion)
--[=================[--
CTAN UPLOAD
--]=================]--
local pkgdesc = [[
This package provides a comprehensive implementation of unicode maths for XeLaTeX and LuaLaTeX. Unicode maths requires an OpenType mathematics font, of which there are now a number of available via CTAN.
While backwards compatibility is strived for, there are some differences between the legacy mathematical definitions in LaTeX and amsmath, and the Unicode mathematics definitions. Care should be taken when transitioning from a legacy workflow to a Unicode-based one.
]]
uploadconfig = {
version = pkgversion,
author = "Will Robertson",
license = "lppl1.3c",
summary = "Unicode mathematics support for XeLaTeX and LuaLaTeX",
ctanPath = "/macros/latex/contrib/unicode-math",
repository = "https://github.com/wspr/unicode-math/",
bugtracker = "https://github.com/wspr/unicode-math/issues",
announcement = currentchanges,
description = pkgdesc,
}
local function prequire(m) -- from: https://stackoverflow.com/a/17878208
local ok, err = pcall(require, m)
if not ok then return nil, err end
return err
end
prequire("l3build-wspr.lua")
--[=============[--
TAGGING
--]=============]--
function update_tag(file, content, tagname, tagdate)
local date = string.gsub(tagdate, "%-", "/")
if string.match(content, "{%d%d%d%d/%d%d/%d%d}%s*{[^}]+}%s*{[^}]+}") then
print("Found expl3 version line in file: "..file)
content = content:gsub("{%d%d%d%d/%d%d/%d%d}(%s*){[^}]+}(%s*){([^}]+)}",
"{"..date.."}%1{"..pkgversion.."}%2{%3}")
end
if string.match(content, "\\def\\filedate{%d%d%d%d/%d%d/%d%d}") then
print("Found filedate line in file: "..file)
content = content:gsub("\\def\\filedate{[^}]+}", "\\def\\filedate{"..date.."}")
end
if string.match(content, "\\def\\fileversion{[^}]+}") then
print("Found fileversion line in file: "..file)
content = content:gsub("\\def\\fileversion{[^}]+}", "\\def\\fileversion{"..pkgversion.."}")
end
if string.match(content, "## (%S+) %([^)]+%)") then
print("Found changes line in file: "..file)
content = content:gsub("## (%S+) %([^)]+%)","## %1 ("..date..")",1)
end
return content
end
--[==============[--
MANIFEST
--]==============]--
manifest_setup = manifest_setup or function()
local groups = {
{
subheading = "Repository manifest",
description = [[
The following groups list the files included in the development repository of the package.
Files listed with a ‘†’ marker are included in the TDS but not CTAN files, and files listed
with ‘‡’ are included in both.
]],
},
{
name = "Source files",
description = [[
These are source files for a number of purposes, including the `unpack` process which
generates the installation files of the package. Additional files included here will also
be installed for processing such as testing.
]],
files = {sourcefiles},
dir = sourcefiledir or maindir, -- TODO: remove "or maindir" after rebasing onto master
},
{
name = "Typeset documentation source files",
description = [[
These files are typeset using LaTeX to produce the PDF documentation for the package.
]],
files = {typesetfiles,typesetsourcefiles,typesetdemofiles},
},
{
name = "Documentation files",
description = [[
These files form part of the documentation but are not typeset. Generally they will be
additional input files for the typeset documentation files listed above.
]],
files = {docfiles},
dir = docfiledir or maindir, -- TODO: remove "or maindir" after rebasing onto master
},
{
name = "Text files",
description = [[
Plain text files included as documentation or metadata.
]],
files = {textfiles},
skipfiledescription = true,
},
{
name = "Demo files",
description = [[
Files included to demonstrate package functionality. These files are *not*
typeset or compiled in any way.
]],
files = {demofiles},
},
{
name = "Bibliography and index files",
description = [[
Supplementary files used for compiling package documentation.
]],
files = {bibfiles,bstfiles,makeindexfiles},
},
{
name = "Derived files",
description = [[
The files created by ‘unpacking’ the package sources. This typically includes
`.sty` and `.cls` files created from DocStrip `.dtx` files.
]],
files = {installfiles},
exclude = {excludefiles,sourcefiles},
dir = unpackdir,
skipfiledescription = true,
},
{
name = "Typeset documents",
description = [[
The output files (PDF, essentially) from typesetting the various source, demo,
etc., package files.
]],
files = {typesetfiles,typesetsourcefiles,typesetdemofiles},
rename = {"%.%w+$", ".pdf"},
skipfiledescription = true,
},
{
name = "Support files",
description = [[
These files are used for unpacking, typesetting, or checking purposes.
]],
files = {unpacksuppfiles,typesetsuppfiles,checksuppfiles},
dir = supportdir,
},
{
name = "Release files",
description = [[
These files are used to manage the package behind the scenes. Not part of a CTAN release.
]],
files = {"*.lua"},
dir = maindir,
},
{
name = "Travis files",
description = [[
These are used to set up Travis CI. Not part of a CTAN release.
]],
files = {"texlive.*",".travis.yml"},
dir = maindir,
},
{
name = "Checking-specific support files",
description = [[
Support files for checking the test suite. Not part of a CTAN release.
]],
files = {"*.*"},
exclude = {{".",".."},excludefiles},
dir = testsuppdir,
},
{
name = "Test files",
description = [[
These files form the test suite for the package. The listed `.lvt` files are the individual unit tests, with matching `.tlg` (not shown, for brevity) are the stored output for ensuring changes to the package produce the same output. Not part of a CTAN release.
]],
files = {"*"..lvtext,"*"..lveext},
dir = testfiledir,
skipfiledescription = true,
},
{
subheading = "TDS manifest",
description = [[
The following groups list the files included in the TeX Directory Structure used to install
the package into a TeX distribution.
]],
},
{
name = "Source files (TDS)",
description = "All files included in the `"..module.."/source` directory.\n",
dir = tdsdir.."/source/"..moduledir,
files = {"*.*"},
exclude = {".",".."},
flag = false,
skipfiledescription = true,
},
{
name = "TeX files (TDS)",
description = "All files included in the `"..module.."/tex` directory.\n",
dir = tdsdir.."/tex/"..moduledir,
files = {"*.*"},
exclude = {".",".."},
flag = false,
skipfiledescription = true,
},
{
name = "Doc files (TDS)",
description = "All files included in the `"..module.."/doc` directory.\n",
dir = tdsdir.."/doc/"..moduledir,
files = {"*.*"},
exclude = {".",".."},
flag = false,
skipfiledescription = true,
},
{
subheading = "CTAN manifest",
description = [[
The following group lists the files included in the CTAN package.
]],
},
{
name = "CTAN files",
dir = ctandir.."/"..module,
files = {"*.*"},
exclude = {".",".."},
flag = false,
skipfiledescription = true,
},
}
return groups
end
filematches = {}
filematches["CHANGES.md"] = "Chronological list of release notes"
filematches["LICENSE"] = "Copy of the LPPL"
filematches["README.md"] = "General information about the package"
-- improve sorting
dtxlisting = nil
ltxlisting = nil
do
local f = assert(io.open("unicode-math.dtx", "r"))
dtxlisting = f:read("*all")
f:close()
local f = assert(io.open("unicode-math.ltx", "r"))
ltxlisting = f:read("*all")
f:close()
end
sort_by_loc = function(str,x,y)
m = string.find(str,x,1,true)
n = string.find(str,y,1,true)
return n > m
end
manifest_sort_within_match = manifest_sort_within_match or function(files)
local f = files
local sortfn = function(x,y) return y>x end
if f[1] then
if string.match(f[1],".*%.dtx") then
sortfn = function(x,y) return sort_by_loc(dtxlisting,x,y) end
elseif string.match(f[1],".*%.tex") then
sortfn = function(x,y) return sort_by_loc(ltxlisting,x,y) end
end
end
table.sort(f,sortfn)
return f
end
-- use an enumerated list for files (mostly just for testing)
manifest_write_group_file = function(filehandle,filename,param)
filehandle:write(string.format("%2i",param.count)..". " .. filename .. " " .. (param.flag or "") .. "\n")
end
-- Extract file descriptions from the 2nd line of each file:
manifest_extract_filedesc = function(filehandle,filename)
filedesc = filematches[filename]
if not(filedesc) then
local end_read_loop = 2
local matchstr = "%%%S%s+(.*)"
local this_line = ""
for ii = 1, end_read_loop do
this_line = filehandle:read("*line")
end
filedesc = string.match(this_line,matchstr)
end
return filedesc
end