forked from latex3/latex3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-config.lua
137 lines (124 loc) · 4.28 KB
/
build-config.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
-- Common settings for LaTeX3 development repo, used by l3build script
checkdeps = checkdeps or {maindir .. "/l3backend", maindir .. "/l3kernel"}
typesetdeps = typesetdeps or {maindir .. "/l3backend", maindir .. "/l3kernel"}
unpackdeps = unpackdeps or {maindir .. "/l3kernel"}
checkengines = checkengines
or {"pdftex", "xetex", "luatex", "ptex", "uptex"}
checksuppfiles = checksuppfiles or
{
"regression-test.cfg",
"regression-test.tex"
}
tagfiles = tagfiles or {"*.dtx", "README.md", "CHANGELOG.md", "*.ins"}
unpacksuppfiles = unpacksuppfiles or
{
"*.ini",
"docstrip.tex",
"hyphen.cfg",
"lualatexquotejobname.lua",
"luatexconfig.tex",
"pdftexconfig.tex",
"texsys.cfg",
"UShyphen.tex"
}
packtdszip = true
typesetcmds = typesetcmds or "\\AtBeginDocument{\\csname DisableImplementation\\endcsname}"
typesetexe = "pdftex"
typesetopts = "--fmt=pdflatex -interaction=nonstopmode"
if checksearch == nil then
checksearch = false
end
if unpacksearch == nil then
unpacksearch = false
end
-- Detail how to set the version automatically
function update_tag(file,content,tagname,tagdate)
local iso = "%d%d%d%d%-%d%d%-%d%d"
local url = "https://github.com/latex3/latex3/compare/"
if string.match(content,"%(C%)%s*[%d%-,]+ The LaTeX3 Project") then
local year = os.date("%Y")
content = string.gsub(content,
"%(C%)%s*([%d%-,]+) The LaTeX3 Project",
"(C) %1," .. year .. " The LaTeX3 Project")
content = string.gsub(content,year .. "," .. year,year)
content = string.gsub(content,
"%-" .. math.tointeger(year - 1) .. "," .. year,
"-" .. year)
content = string.gsub(content,
math.tointeger(year - 2) .. "," .. math.tointeger(year - 1) .. "," .. year,
math.tointeger(year - 2) .. "-" .. year)
end
if string.match(file,"%.dtx$") then
content = string.gsub(content,
"\n\\ProvidesExpl" .. "(%w+ *{[^}]+} *){" .. iso .. "}",
"\n\\ProvidesExpl%1{" .. tagname .. "}")
return string.gsub(content,
"\n%% \\date{Released " .. iso .. "}\n",
"\n%% \\date{Released " .. tagname .. "}\n")
elseif string.match(file, "%.md$") then
if string.match(file,"CHANGELOG.md") then
local previous = string.match(content,"compare/(" .. iso .. ")%.%.%.HEAD")
if tagname == previous then return content end
content = string.gsub(content,
"## %[Unreleased%]",
"## [Unreleased]\n\n## [" .. tagname .."]")
return string.gsub(content,
iso .. "%.%.%.HEAD",
tagname .. "...HEAD\n[" .. tagname .. "]: " .. url .. previous
.. "..." .. tagname)
end
return string.gsub(content,
"\nRelease " .. iso .. "\n",
"\nRelease " .. tagname .. "\n")
end
return content
end
-- Need to build format files
local function fmt(engines,dest)
local function mkfmt(engine)
-- Standard (u)pTeX engines don't have e-TeX
local cmd = engine
if string.match(engine,"uptex") then
cmd = "euptex"
elseif string.match(engine,"ptex") then
cmd = "eptex"
elseif string.match(engine,"luatex") then
cmd = "luahbtex"
end
-- Use .ini files if available
local src = "latex.ltx"
local ini = string.gsub(engine,"tex","") .. "latex.ini"
if fileexists(supportdir .. "/" .. ini) then
src = ini
end
print("Building format for " .. engine)
local errorlevel = os.execute(
os_setenv .. " TEXINPUTS=" .. unpackdir .. os_pathsep .. localdir
.. os_pathsep .. texmfdir .. "//"
.. os_concat ..
os_setenv .. " LUAINPUTS=" .. unpackdir .. os_pathsep .. localdir
.. os_pathsep .. texmfdir .. "//"
.. os_concat .. cmd .. " -etex -ini -output-directory=" .. unpackdir
.. " " .. src .. " > " .. os_null)
if errorlevel ~= 0 then return errorlevel end
local engname = string.match(src,"^[^.]*") .. ".fmt"
local fmtname = string.gsub(engine,"tex$","") .. "latex.fmt"
if engname ~= fmtname then
ren(unpackdir,engname,fmtname)
end
cp(fmtname,unpackdir,dest)
return 0
end
local errorlevel
for _,engine in pairs(engines) do
errorlevel = mkfmt(engine)
if errorlevel ~= 0 then return errorlevel end
end
return 0
end
function checkinit_hook()
return fmt(options["engine"] or checkengines,testdir)
end
function docinit_hook()
return fmt({typesetexe},typesetdir)
end