Skip to content

Commit

Permalink
New sourcefiledir variable
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwright committed Dec 11, 2017
1 parent 3290ab9 commit afea07b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 25 deletions.
15 changes: 12 additions & 3 deletions l3build.dtx
Expand Up @@ -57,10 +57,11 @@
\luavarset{modules}{\{\}}{The list of all modules in a bundle (when not auto-detecting)}
\luavarset{exclmodules}{\{\}}{Directories to be excluded from automatic module detection}
\luavarseparator
\luavarset{maindir} {"."} {Top level directory for the module/bundle}
\luavarset{docfiledir} {maindir} {Directory containing documentation files}
\luavarset{maindir} {"."} {Top level directory for the module/bundle}
\luavarset{docfiledir} {"."} {Directory containing documentation files}
\luavarset{sourcfiledir}{"."} {Directory containing source files}

This comment has been minimized.

Copy link
@stone-zeng

stone-zeng Mar 29, 2018

Typo: sourcfiledir should be sourcefiledir.

\luavarset{supportdir} {maindir .. "/support"} {Directory containing general support files}
\luavarset{testfiledir}{maindir .. "/testfiles"} {Directory containing test files}
\luavarset{testfiledir}{"./testfiles"} {Directory containing test files}
\luavarset{testsuppdir}{testfiledir .. "/support"}{Directory containing test-specific support files}
\luavarseparator
\luavarset{builddir} {maindir .. "/build"} {Directory for building and testing}
Expand Down Expand Up @@ -679,6 +680,14 @@
% This ensures that the \pkg{l3kernel} code is included in all processes involved in unpacking and checking and so on.
% The name of the script file in the dependency is set with the |scriptname| variable; by default these are |"build.lua"|.
%
% \subsection{Non-standard source layouts}
%
% A variety of source layouts are supported. In general, a \enquote{flat}
% layout with all source files \enquote{here} is most convenient. However,
% \pkg{l3build} supports placement of both code and documentation source
% files in other locations using the \var{sourcefiledir} and \var{docfiledir}
% variables. For pre-built trees, the glob syntax |**/*| may be useful in these
% cases: this enables recursive searching in the appropriate tree locations.
%
% \subsection{Output normalisation}
% \label{sec:norm}
Expand Down
50 changes: 28 additions & 22 deletions l3build.lua
Expand Up @@ -66,6 +66,7 @@ maindir = maindir or currentdir
-- Substructure for file locations
docfiledir = docfiledir or currentdir
sourcefiledir = sourcefiledir or currentdir
supportdir = supportdir or maindir .. "/support"
testfiledir = testfiledir or currentdir .. "/testfiles"
testsuppdir = testsuppdir or testfiledir .. "/support"
Expand Down Expand Up @@ -839,7 +840,7 @@ function checkinit()
for _,i in ipairs(filelist(localdir)) do
cp(i, localdir, testdir)
end
bundleunpack({currentdir, testfiledir})
bundleunpack({sourcefiledir, testfiledir})
for _,i in ipairs(installfiles) do
cp(i, unpackdir, testdir)
end
Expand Down Expand Up @@ -873,10 +874,11 @@ function copyctan()
cp(file, docfiledir, ctandir .. "/" .. ctanpkg)
end
end
for _,filetype in pairs({sourcefiles, textfiles}) do
for _,file in pairs(filetype) do
cp(file, currentdir, ctandir .. "/" .. ctanpkg)
end
for _,file in pairs(sourcefiles) do
cp(file, sourcefiledir, ctandir .. "/" .. ctanpkg)
end
for _,file in pairs(textfiles) do
cp(file, currentdir, ctandir .. "/" .. ctanpkg)
end
end
Expand Down Expand Up @@ -922,7 +924,7 @@ function copytds()
)
install(unpackdir, "makeindex", {makeindexfiles}, true)
install(unpackdir, "bibtex/bst", {bstfiles}, true)
install(currentdir, "source", {sourcelist})
install(sourcefiledir, "source", {sourcelist})
install(unpackdir, "tex", {installfiles})
end
Expand Down Expand Up @@ -1925,7 +1927,9 @@ function clean()
cleandir(typesetdir) +
cleandir(unpackdir)
for _,i in ipairs(cleanfiles) do
errorlevel = rm(currentdir, i) + errorlevel
for _,dir in pairs({maindir, sourcefiledir, docfiledir}) do
errorlevel = rm(dir, i) + errorlevel
end
end
return errorlevel
end
Expand Down Expand Up @@ -1955,7 +1959,7 @@ function cmdcheck()
end
end
for _,file in pairs(sourcefiles) do
cp(file, currentdir, testdir)
cp(file, sourcefiledir, testdir)
end
for _,file in pairs(typesetsuppfiles) do
cp(file, supportdir, testdir)
Expand All @@ -1964,7 +1968,7 @@ function cmdcheck()
local localdir = abspath(localdir)
print("Checking source files")
for _,i in ipairs(cmdchkfiles) do
for _,j in ipairs(filelist(currentdir, i)) do
for _,j in ipairs(filelist(sourcefiledir, i)) do
print(" " .. jobname(j))
run(
testdir,
Expand Down Expand Up @@ -2062,20 +2066,21 @@ end
function bundlectan()
-- Generate a list of individual file names excluding those in the second
-- argument: the latter is a table
local function excludelist(include, exclude)
local function excludelist(include, exclude, dir)
local include = include or { }
local exclude = exclude or { }
local dir = dir or currendir
local includelist = { }
local excludelist = { }
for _,i in ipairs(exclude) do
for _,j in ipairs(i) do
for _,k in ipairs(filelist(currentdir, j)) do
for _,k in ipairs(filelist(dir, j)) do
excludelist[k] = true
end
end
end
for _,i in ipairs(include) do
for _,j in ipairs(filelist(currentdir, i)) do
for _,j in ipairs(filelist(dir, i)) do
if not excludelist[j] then
insert(includelist, j)
end
Expand All @@ -2097,9 +2102,9 @@ function bundlectan()
for _,v in pairs(typesetdemofiles) do
insert(typesetfiles, v)
end
typesetlist = excludelist(typesetfiles, {sourcefiles})
typesetlist = excludelist(typesetfiles, {sourcefiles}, docfiledir)
sourcelist = excludelist(
sourcefiles, {bstfiles, installfiles, makeindexfiles}
sourcefiles, {bstfiles, installfiles, makeindexfiles}, sourcefiledir
)
copyctan()
copytds()
Expand All @@ -2120,13 +2125,13 @@ function doc(files)
end
end
for _,file in pairs(sourcefiles) do
cp(file, currentdir, typesetdir)
cp(file, sourcefiledir, typesetdir)
end
for _,file in pairs(typesetsuppfiles) do
cp(file, supportdir, typesetdir)
end
depinstall(typesetdeps)
unpack({sourcefiles, typesetsourcefiles}, {currentdir, docfiledir})
unpack({sourcefiles, typesetsourcefiles}, {sourcefiledir, docfiledir})
-- Main loop for doc creation
local done = {}
for _, typesetfiles in ipairs({typesetdemofiles, typesetfiles}) do
Expand Down Expand Up @@ -2293,7 +2298,7 @@ setversion_update_line = setversion_update_line or function(line, date, version)
return line
end
function setversion(dir)
function setversion()
local function rewrite(dir, file, date, version)
local changed = false
local result = ""
Expand Down Expand Up @@ -2324,10 +2329,11 @@ function setversion(dir)
end
local date = options["date"] or os_date("%Y-%m-%d")
local version = options["version"] or -1
local dir = dir or currentdir
for _,i in pairs(versionfiles) do
for _,j in pairs(filelist(dir, i)) do
rewrite(dir, j, date, version)
for _,dir in pairs({currentdir, sourcefiledir, docfiledir}) do
for _,i in pairs(versionfiles) do
for _,j in pairs(filelist(dir, i)) do
rewrite(dir, j, date, version)
end
end
end
return 0
Expand Down Expand Up @@ -2364,7 +2370,7 @@ bundleunpack = bundleunpack or function(sourcedirs, sources)
if errorlevel ~=0 then
return errorlevel
end
for _,i in ipairs(sourcedirs or {currentdir}) do
for _,i in ipairs(sourcedirs or {sourcefiledir}) do
for _,j in ipairs(sources or {sourcefiles}) do
for _,k in ipairs(j) do
errorlevel = cp(k, i, unpackdir)
Expand Down

0 comments on commit afea07b

Please sign in to comment.