Skip to content

Commit

Permalink
Add a documented call() functions (fixes #16)
Browse files Browse the repository at this point in the history
By generalising allmodules() to take a list of places to run,
we avoid needing to repeat this code multiple times (and should
not need to remember to add new options in several places!).
  • Loading branch information
josephwright committed Jun 30, 2017
1 parent 09ab41d commit 5d3f863
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
11 changes: 11 additions & 0 deletions l3build.dtx
Expand Up @@ -1317,6 +1317,17 @@
% used inside |os.execute| (it does not terminate).
% \end{variable}
%
% \subsection{Components of \texttt{l3build}}
%
% \begin{function}{call()}
% \begin{syntax}
% |call(|\meta{dirs}, \meta{target}|)|
% \end{syntax}
% Runs the \texttt{l3build} \meta{target} (a string) for each directory in the
% \meta{dirs} (a table). This will pass command line options for the parent
% script to the child processes.
% \end{function}
%
% \end{documentation}
%
% \begin{implementation}
Expand Down
22 changes: 11 additions & 11 deletions l3build.lua
Expand Up @@ -680,7 +680,7 @@ end
--
-- Do some subtarget for all modules in a bundle
local function allmodules(target)
function call(dirs, target)
local date = ""
if optdate then
date = " --date=" .. optdate[1]
Expand All @@ -693,7 +693,7 @@ local function allmodules(target)
if optrelease then
release = " --release=" .. optrelease[1]
end
for _,i in ipairs(modules) do
for _,i in ipairs(dirs) do
print(
"Running script " .. scriptname .. " with target \"" .. target
.. "\" for module "
Expand Down Expand Up @@ -1749,7 +1749,7 @@ function clean()
end
function bundleclean()
local errorlevel = allmodules("clean")
local errorlevel = call(modules, "clean")
for _,i in ipairs(cleanfiles) do
errorlevel = rm(".", i) + errorlevel
end
Expand Down Expand Up @@ -1833,7 +1833,7 @@ function ctan(standalone)
errorlevel = check()
bundle = module
else
errorlevel = allmodules("bundlecheck")
errorlevel = call(modules, "bundlecheck")
end
if errorlevel == 0 then
rmdir(ctandir)
Expand All @@ -1843,7 +1843,7 @@ function ctan(standalone)
if standalone then
errorlevel = bundlectan()
else
errorlevel = allmodules("bundlectan")
errorlevel = call(modules, "bundlectan")
end
else
print("\n====================")
Expand Down Expand Up @@ -2237,28 +2237,28 @@ function stdmain(target, files)
-- Detect all of the modules
modules = modules or listmodules()
if target == "doc" then
errorlevel = allmodules("doc")
errorlevel = call(modules, "doc")
elseif target == "check" then
errorlevel = allmodules("bundlecheck")
errorlevel = call(modules, "bundlecheck")
if errorlevel ~=0 then
print("There were errors: checks halted!\n")
end
elseif target == "clean" then
errorlevel = bundleclean()
elseif target == "cmdcheck" and next(cmdchkfiles) ~= nil then
errorlevel = allmodules("cmdcheck")
errorlevel = call(modules, "cmdcheck")
elseif target == "ctan" then
errorlevel = ctan()
elseif target == "install" then
errorlevel = allmodules("install")
errorlevel = call(modules, "install")
elseif target == "setversion" then
errorlevel = allmodules("setversion")
errorlevel = call(modules, "setversion")
-- Deal with any files in the bundle dir itself
if errorlevel == 0 then
errorlevel = setversion()
end
elseif target == "unpack" then
errorlevel = allmodules("bundleunpack")
errorlevel = call(modules, "bundleunpack")
elseif target == "version" then
version()
else
Expand Down

0 comments on commit 5d3f863

Please sign in to comment.