forked from latex3/fontspec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.lua
executable file
·162 lines (128 loc) · 4.35 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
#!/usr/bin/env texlua
module = "fontspec"
--[================[
PARAMETERS
--]================]
sourcefiles = {"*.ins","*.dtx","*.ltx","*.cfg","*.tex","fontspec-doc-style.sty"}
installfiles = {"fontspec.sty","fontspec-xetex.sty","fontspec-luatex.sty","fontspec.lua","fontspec.cfg"}
demofiles = {"fontspec-example.tex"}
textfiles = {"README.md","doc/CHANGES.md","LICENSE"}
tagfiles = {"fontspec.dtx","doc/CHANGES.md"}
typesetfiles = {"fontspec.ltx","fontspec-code.ltx"}
typesetexe = "xelatex"
typesetopts = " -shell-escape -interaction=errorstopmode "
unpackopts = " -interaction=batchmode "
checkengines = {"xetex","luatex"}
recordstatus = true
packtdszip = true
checksuppfiles = {"texmf.cnf"}
--[===[
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 os.getenv'TEST_DEV_FORMATS' 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("doc/CHANGES.md", "r"))
changeslisting = f:read("*all")
f:close()
end
pkgversion = string.match(changeslisting,"## v(%S+) %(.-%)")
gittag = 'v'..pkgversion
print('Current version (from first entry in CHANGES.md): '..pkgversion)
--[============[
TAGGING
--]============]
function update_tag(file, content, tagname, tagdate)
check_status()
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
content = content:gsub("version = \"[^\"]+\",", "version = \""..pkgversion.."\",")
content = content:gsub("date = \"[^\"]+\",", "date = \""..date.."\",")
if string.match(content, "## (%S+) %([^)]+%)") then
print("Found changes line in file: "..file)
content = content:gsub("## (%S+) %([^)]+%)","## %1 ("..date..")",1)
end
return content
end
status_bool = false
function check_status()
if status_bool then
return true
end
local handle = io.popen('git status --porcelain --untracked-files=no')
local gitstatus = string.gsub(handle:read("*a"),'%s*$','')
handle:close()
if gitstatus=="" then
print("Checking git status: clean")
status_bool = true
return status_bool
else
print("ABORTING, git status is not clean:")
print(gitstatus)
status_bool = false
return status_bool
end
end
--[=================[
Fetching / updating test font repository
--]=================]
local function ensure_test_fonts()
local repo_mode = lfs.attributes('fontspec-test-fonts', 'mode')
if repo_mode == nil then
assert(os.execute'git clone --depth 1 https://github.com/wspr/fontspec-test-fonts fontspec-test-fonts')
elseif repo_mode == 'directory' then
assert(os.execute'git -C fontspec-test-fonts pull --ff-only')
else
error'Unexpected mode of fontspec-test-fonts'
end
end
ensure_test_fonts()
--[=================[
CTAN UPLOAD
--]=================]
uploadconfig = {
version = pkgversion,
author = "Will Robertson",
license = "lppl1.3c",
summary = "Advanced font selection in XeLaTeX and LuaLaTeX",
ctanPath = "/macros/unicodetex/latex/fontspec",
repository = "https://github.com/latex3/fontspec/",
bugtracker = "https://github.com/latex3/fontspec/issues",
}
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")