-
-
Notifications
You must be signed in to change notification settings - Fork 248
/
build.lua
243 lines (227 loc) · 5.8 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
#!/usr/bin/env texlua
-- Build script for LaTeX2e "base" files
-- Identify the bundle and module
module = "base"
bundle = ""
-- CTAN's name for this is a bit different from ours
ctanpkg = "latex-base"
-- Location of main directory: use Unix-style path separators
maindir = ".."
-- Set up the file types needed here
installfiles =
{
"*.cfg",
"*.clo",
"*.cls",
"*.def",
"*.dfu",
"*.fd",
"*.ltx",
"*.lua",
"*.sty",
"docstrip.tex",
"idx.tex",
"lablst.tex",
"lppl.tex",
"ltluatex.tex",
"ltxcheck.tex",
"nfssfont.tex",
"sample2e.tex",
"small2e.tex",
"testpage.tex",
}
sourcefiles =
{
"ltnews.cls",
"ltxguide.cls",
"minimal.cls",
"*.dtx",
"*.fdd",
"*.ins",
"idx.tex",
"lablst.tex",
"ltxcheck.tex",
"sample2e.tex",
"small2e.tex",
"testpage.tex",
"utf8andspace.tex"
}
typesetfiles =
{
"source2e.tex",
"alltt.dtx",
"classes.dtx",
"cmfonts.dtx",
"doc.dtx",
"docstrip.dtx",
"exscale.dtx",
"fix-cm.dtx",
"graphpap.dtx",
"ifthen.dtx",
"inputenc.dtx",
"ltunicode.dtx",
"lppl.tex",
"utf8ienc.dtx",
"latexrelease.dtx",
"latexsym.dtx",
"letter.dtx",
"ltluatex.dtx",
"ltxdoc.dtx",
"makeindx.dtx",
"nfssfont.dtx",
"proc.dtx",
"slides.dtx",
"slifonts.dtx",
"syntonly.dtx",
"*.fdd",
"*.err",
}
dynamicfiles = {"*.tst"}
-- A few special file for unpacking
unpackfiles = {"unpack.ins"}
unpacksuppfiles =
{
"EastAsianWidth.txt",
"hyphen.cfg",
"LineBreak.txt",
"load-unicode-data.tex",
"load-unicode-xetex-classes.tex",
"MathClass.txt",
"UnicodeData.txt",
"UShyphen.tex",
"ot1lmr.fd"
}
-- Custom settings for the check system
testsuppdir = "testfiles/helpers"
-- No dependencies at all (other than l3build of course)
checkdeps = { }
unpackdeps = { }
-- Customise typesetting
indexstyle = "source2e.ist"
-- Allow for TU test
checkconfigs = {"build","config-TU","config-legacy"}
function format ()
local errorlevel = unpack ()
if errorlevel ~=0 then
return errorlevel
end
local function format (engine,fmtname)
-- the relationships are all correct
local errorlevel = os.execute (
os_setenv .. " TEXINPUTS=" .. unpackdir .. os_pathsep .. localdir
.. os_concat ..
engine .. " -etex -ini " .. " -output-directory=" .. unpackdir ..
" " .. unpackdir .. "/latex.ltx"
)
if errorlevel ~=0 then
return errorlevel
end
ren (unpackdir, "latex.fmt", fmtname)
-- As format building is added in as an 'extra', the normal
-- copy mechanism (checkfiles) will fail as things get cleaned up
-- inside bundleunpack(): get around that using a manual copy
cp (fmtname, unpackdir, localdir)
if fmtname == "elatex.fmt" then
rm(localdir, "latex.fmt")
ren(localdir, fmtname, "latex.fmt")
end
return 0
end
if not options["config"] or options["config"][1] ~= "config-TU" then
cp("fonttext.cfg",supportdir,unpackdir)
end
local checkengines = options["engine"] or checkengines
for _,i in ipairs(checkengines) do
errorlevel = format (i, string.gsub (i, "tex$", "") .. "latex.fmt")
if errorlevel ~=0 then
return errorlevel
end
end
return 0
end
-- Custom bundleunpack which does not search the localdir
-- That is needed as texsys.cfg is unpacked in an odd way and
-- without this will otherwise not be available
function bundleunpack ()
local errorlevel = mkdir(localdir)
if errorlevel ~=0 then
return errorlevel
end
errorlevel = cleandir(unpackdir)
if errorlevel ~=0 then
return errorlevel
end
for _,i in ipairs (sourcefiles) do
errorlevel = cp (i, ".", unpackdir)
if errorlevel ~=0 then
return errorlevel
end
end
for _,i in ipairs (unpacksuppfiles) do
errorlevel = cp (i, supportdir, localdir)
if errorlevel ~=0 then
return errorlevel
end
end
for _,i in ipairs (unpackfiles) do
for _,j in ipairs (filelist (unpackdir, i)) do
os.execute (os_yes .. ">>" .. localdir .. "/yes")
errorlevel = os.execute (
-- Notice that os.execute is used from 'here' as this ensures that
-- localdir points to the correct place: running 'inside'
-- unpackdir would avoid the need for setting -output-directory
-- but at the cost of needing to correct the relative position
-- of localdir w.r.t. unpackdir
os_setenv .. " TEXINPUTS=" .. unpackdir .. os_concat ..
unpackexe .. " " .. unpackopts .. " -output-directory=" .. unpackdir
.. " " .. unpackdir .. "/" .. j .. " < " .. localdir .. "/yes"
)
if errorlevel ~=0 then
return errorlevel
end
end
end
return 0
end
-- base does all of the targets itself
function main (target, file, engine)
local errorlevel
if target == "check" then
if not options["rerun"] then
format()
end
errorlevel = check (file, engine)
elseif target == "clean" then
errorlevel = clean ()
elseif target == "ctan" then
format ()
errorlevel = ctan (true)
elseif target == "doc" then
errorlevel = doc ()
elseif target == "install" then
install ()
elseif target == "save" then
if file then
errorlevel = save (file, engine)
else
help ()
end
elseif target == "unpack" then
-- A simple way to have the unpack target also build the format
errorlevel = format ()
elseif target == "uninstall" then
errorlevel = uninstall()
elseif target == "version" then
version ()
else
help ()
end
os.exit (errorlevel)
end
-- Load the common settings for the LaTeX2e repo
dofile (maindir .. "/build-config.lua")
-- Find and run the build system
kpse.set_program_name ("kpsewhich")
if not release_date then
dofile(kpse.lookup("l3build.lua"))
end