-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.lua
119 lines (96 loc) · 3.22 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
--[[
lua-widow-control
https://github.com/gucci-on-fleek/lua-widow-control
SPDX-License-Identifier: MPL-2.0+
SPDX-FileCopyrightText: 2022 Max Chernoff
]]
-- Initialization
module = "lua-widow-control"
local orig_targets = target_list
target_list = {}
-- Tagging
target_list.tag = orig_targets.tag
tagfiles = { "source/*.*", "docs/**/*.*", "README.md" }
function update_tag(name, content, version, date)
if not version then
print("No version provided. Exiting")
os.exit(1)
end
if name:match("%.pdf$") then
return content
end
content = content:gsub(
"(%d%.%d%.%d)([^\n]*)%%%%version",
version .. "%2%%%%version"
):gsub(
"(%d%d%d%d%-%d%d%-%d%d)([^\n]*)%%%%dashdate",
date .. "%2%%%%dashdate"
):gsub(
"(%d%d%d%d/%d%d/%d%d)([^\n]*)%%%%slashdate",
date:gsub("-", "/") .. "%2%%%%slashdate"
)
return content
end
-- Bundle
target_list.bundle = {}
target_list.bundle.desc = "Creates the package zipfiles"
function target_list.bundle.func()
local newzip = require "l3build-zip"
local tdszipname = module .. ".tds.zip"
local tdszip = newzip("./" .. tdszipname)
local ctanzip = newzip("./" .. module .. ".ctan.zip")
for _, path in ipairs(tree("texmf", "**/*.*")) do
tdszip:add(
path.cwd, -- outer
path.src:sub(3), -- inner
path.src:match("pdf") -- binary
)
ctanzip:add(
path.cwd, -- outer
module .. "/" .. basename(path.src), -- inner
path.src:match("pdf") -- binary
)
end
tdszip:close()
ctanzip:add("./" .. tdszipname, tdszipname, true)
ctanzip:close()
return 0
end
-- Documentation
target_list.doc = {}
target_list.doc.desc = "Builds the documentation"
local l3_run = run
local function run(cwd, cmd)
local error = l3_run(cwd, cmd)
if error ~= 0 then
print(("\n"):rep(5))
print("Error code " .. error .. " for command " .. cmd .. ".")
print("\n")
os.exit(error)
end
end
function target_list.doc.func()
mkdir("./docs/manual/tmp")
run("./docs/manual", "context lwc-manual")
run("./docs/articles", "context tb133chernoff-widows-figure.ctx")
run("./docs/articles", "lualatex tb133chernoff-widows.ltx")
run("./docs/articles", "bibtex tb133chernoff-widows")
run("./docs/articles", "lualatex tb133chernoff-widows.ltx")
run("./docs/articles", "lualatex tb133chernoff-widows.ltx")
run("./docs/articles", "lualatex tb135chernoff-lwc.ltx")
run("./docs/articles", "pdfunite tb133chernoff-widows.pdf tb135chernoff-lwc.pdf /dev/stdout | sponge tb133chernoff-widows.pdf")
run("./docs/articles", "context lwc-zpravodaj-figure.ctx")
run("./docs/articles", "lualatex lwc-zpravodaj.ltx")
run("./docs/articles", "biber lwc-zpravodaj")
run("./docs/articles", "lualatex lwc-zpravodaj.ltx")
run("./docs/articles", "lualatex lwc-zpravodaj.ltx")
return 0
end
-- Tests
target_list.check = orig_targets.check
target_list.save = orig_targets.save
os.setenv("diffexe", "git diff --no-index -w --word-diff --text")
checkconfigs = {}
for _, path in ipairs(tree(".", "./tests/*/build.lua")) do
checkconfigs[#checkconfigs+1] = path.src
end