tl2017 luatex discretionaries
[latex2e.git] / latex2e-20150101 / base / build.lua
blob377ff02f3de0b6b66382baeb004d047236033dbe
1 #!/usr/bin/env texlua
3 -- Build script for LaTeX2e "base" files
5 -- Identify the bundle and module
6 module = "base"
7 bundle = ""
9 -- CTAN's name for this is a bit different from ours
10 ctanpkg = "latex-base"
12 -- Location of main directory: use Unix-style path separators
13 maindir = ".."
15 -- Set up the file types needed here
16 installfiles =
17 {"*.cfg", "*.clo", "*.cls", "*.def", "*.dfu", "*.fd", "*.ltx", "*.sty", "*.tex"}
18 sourcefiles = {"*.cls", "unicode-letters.def", "*.dtx", "*.fdd", "ltpatch.ltx", "*.ins", "*.tex"}
19 typesetfiles =
21 "source2e.tex",
22 "alltt.dtx",
23 "classes.dtx",
24 "cmfonts.dtx",
25 "doc.dtx",
26 "docstrip.dtx",
27 "exscale.dtx",
28 "fix-cm.dtx",
29 "graphpap.dtx",
30 "ifthen.dtx",
31 "inputenc.dtx",
32 "ltunicode.dtx",
33 "lppl.tex",
34 "utf8ienc.dtx",
35 "latexrelease.dtx",
36 "latexsym.dtx",
37 "letter.dtx",
38 "ltxdoc.dtx",
39 "makeindx.dtx",
40 "nfssfont.dtx",
41 "proc.dtx",
42 "slides.dtx",
43 "slifonts.dtx",
44 "syntonly.dtx",
45 "*.fdd",
46 "*.err",
49 -- A few special file for unpacking
50 unpackfiles = {"unpack.ins"}
51 unpacksuppfiles = {"hyphen.cfg", "UShyphen.tex"}
53 -- Custom settings for the check system
54 testsuppdir = "testfiles/helpers"
56 -- No dependencies at all (other than l3build of course)
57 checkdeps = { }
58 unpackdeps = { }
60 -- Customise typesetting
61 indexstyle = "source2e.ist"
63 function format ()
64 unpack ()
65 local function format (engine,fmtname)
66 -- the relationships are all correct
67 os.execute (
68 os_setenv .. " TEXINPUTS=" .. unpackdir .. os_pathsep .. localdir
69 .. os_concat ..
70 engine .. " -etex -ini " .. " -output-directory=" .. unpackdir ..
71 " " .. unpackdir .. "/latex.ltx"
73 ren (unpackdir, "latex.fmt", fmtname)
74 -- As format building is added in as an 'extra', the normal
75 -- copy mechanism (checkfiles) will fail as things get cleaned up
76 -- inside bundleunpack(): get around that using a manual copy
77 cp (fmtname, unpackdir, localdir)
78 end
79 for _,i in ipairs (checkengines) do
80 format (i, string.gsub (i, "tex$", "") .. "latex.fmt")
81 end
82 end
84 -- Custom bundleunpack which does not search the localdir
85 -- That is needed as texsys.cfg is unpacked in an odd way and
86 -- without this will otherwise not be available
87 function bundleunpack ()
88 mkdir (localdir)
89 cleandir (unpackdir)
90 for _,i in ipairs (sourcefiles) do
91 cp (i, ".", unpackdir)
92 end
93 for _,i in ipairs (unpacksuppfiles) do
94 cp (i, supportdir, localdir)
95 end
96 for _,i in ipairs (unpackfiles) do
97 for _,j in ipairs (filelist (unpackdir, i)) do
98 os.execute (os_yes .. ">>" .. localdir .. "/yes")
99 os.execute (
100 -- Notice that os.execute is used from 'here' as this ensures that
101 -- localdir points to the correct place: running 'inside'
102 -- unpackdir would avoid the need for setting -output-directory
103 -- but at the cost of needing to correct the relative position
104 -- of localdir w.r.t. unpackdir
105 os_setenv .. " TEXINPUTS=" .. unpackdir .. os_concat ..
106 unpackexe .. " " .. unpackopts .. " -output-directory=" .. unpackdir
107 .. " " .. unpackdir .. "/" .. j .. " < " .. localdir .. "/yes"
113 -- base does all of the targets itself
114 function main (target, file, engine)
115 local errorlevel
116 if target == "check" then
117 format ()
118 errorlevel = check (file, engine)
119 elseif target == "clean" then
120 errorlevel = clean ()
121 elseif target == "ctan" then
122 format ()
123 errorlevel = ctan (true)
124 elseif target == "doc" then
125 errorlevel = doc ()
126 elseif target == "install" then
127 install ()
128 elseif target == "save" then
129 if file then
130 errorlevel = save (file, engine)
131 else
132 help ()
134 elseif target == "unpack" then
135 -- A simple way to have the unpack target also build the format
136 errorlevel = format ()
137 elseif target == "version" then
138 version ()
139 else
140 help ()
142 os.exit (errorlevel)
145 -- Load the common settings for the LaTeX2e repo
146 dofile (maindir .. "/build-config.lua")
148 -- Find and run the build system
149 kpse.set_program_name ("kpsewhich")
150 dofile (kpse.lookup ("l3build.lua"))