[latex3-commits] [l3svn] 04/09: typeset in subdirectories

noreply at latex-project.org noreply at latex-project.org
Sun Jun 25 09:30:24 CEST 2017


This is an automated email from the git hooks/post-receive script.

joseph pushed a commit to branch master
in repository l3svn.

commit f3eb85500f9c131ef998fd5eda38a17fdbf05e6b
Author: XZS <d.f.fischer at web.de>
Date:   Fri Apr 14 17:38:37 2017 +0200

    typeset in subdirectories
    
    As already cared for with unpacking, typeset files should also appear
    besides they were created from. This is more complicated here, as the
    source files originate from multiple directories. Because of that, these
    directories have to be passed down through to the runtool function,
    which executes all the external programs for document compilation and
    sets up the paths.
---
 l3build/l3build.lua |   60 ++++++++++++++++++++++++++++++---------------------
 1 file changed, 35 insertions(+), 25 deletions(-)

diff --git a/l3build/l3build.lua b/l3build/l3build.lua
index 281e64f..14ba64e 100644
--- a/l3build/l3build.lua
+++ b/l3build/l3build.lua
@@ -1443,12 +1443,14 @@ end
 --
 
 -- An auxiliary used to set up the environmental variables
-function runtool(envvar, command)
+function runtool(subdir, dir, envvar, command)
+  dir = dir or "."
   return(
     run(
-      typesetdir,
+      typesetdir .. "/" .. subdir,
       os_setenv .. " " .. envvar .. "=." .. os_pathsep
-        .. abspath(localdir)
+        .. abspath(localdir) .. os_pathsep
+        .. abspath(dir .. "/" .. subdir)
         .. (typesetsearch and os_pathsep or "") ..
       os_concat ..
       command
@@ -1456,16 +1458,17 @@ function runtool(envvar, command)
   )
 end
 
-function biber(name)
+function biber(name, dir)
   if fileexists(typesetdir .. "/" .. name .. ".bcf") then
+    local path, name = splitpath(name)
     return(
-      runtool("BIBINPUTS",  biberexe .. " " .. biberopts .. " " .. name)
+      runtool(path, dir, "BIBINPUTS",  biberexe .. " " .. biberopts .. " " .. name)
     )
   end
   return 0
 end
 
-function bibtex(name)
+function bibtex(name, dir)
   if fileexists(typesetdir .. "/" .. name .. ".aux") then
     -- LaTeX always generates an .aux file, so there is a need to
     -- look inside it for a \citation line
@@ -1475,6 +1478,7 @@ function bibtex(name)
     else
      grep = "\\\\\\\\"
     end
+    local path, name = splitpath(name)
     if run(
         typesetdir,
         os_grepexe .. " \"^" .. grep .. "citation{\" " .. name .. ".aux > "
@@ -1487,6 +1491,7 @@ function bibtex(name)
       return(
         -- Cheat slightly as we need to set two variables
         runtool(
+          path, dir,
           "BIBINPUTS",
           os_setenv .. " BSTINPUTS=." .. os_pathsep
             .. abspath(localdir)
@@ -1500,34 +1505,38 @@ function bibtex(name)
   return 0
 end
 
-function makeindex(name, inext, outext, logext, style)
+function makeindex(name, dir, inext, outext, logext, style)
   if fileexists(typesetdir .. "/" .. name .. inext) then
+    local path, name = splitpath(name)
     return(
       runtool(
+        path, dir,
         "INDEXSTYLE",
         makeindexexe .. " " .. makeindexopts .. " "
           .. " -s " .. style .. " -o " .. name .. outext
-          .. " -t " .. name .. logext .. " "  .. name .. inext
+          .. " -t " .. name .. " "  .. name .. inext
       )
     )
   end
   return 0
 end
 
-function tex(file)
+function tex(file, dir)
+  local path, name = splitpath(file)
   return(
     runtool(
+      path, dir,
       "TEXINPUTS",
       typesetexe .. " " .. typesetopts .. " \"" .. typesetcmds
-        .. "\\input " .. file .. "\""
+        .. "\\input " .. name .. "\""
     )
   )
 end
 
-function typesetpdf(file)
-  local name = jobname(select(2, splitpath(file))
+function typesetpdf(file, dir)
+  local name = jobname(file)
   print("Typesetting " .. name)
-  local errorlevel = typeset(file)
+  local errorlevel = typeset(file, dir)
   if errorlevel == 0 then
     os_remove(name .. ".pdf")
     cp(name .. ".pdf", typesetdir, ".")
@@ -1537,24 +1546,25 @@ function typesetpdf(file)
   return errorlevel
 end
 
-typeset = typeset or function(file)
-  local errorlevel = tex(file)
+typeset = typeset or function(file, dir)
+  dir = dir or "."
+  local errorlevel = tex(file, dir)
   if errorlevel ~= 0 then
     return errorlevel
   else
-    local name = jobname(select(2, splitpath(file)))
-    errorlevel = biber(name) + bibtex(name)
+    local name = jobname(file)
+    errorlevel = biber(name, dir) + bibtex(name, dir)
     if errorlevel == 0 then
-      local function cycle(name)
+      local function cycle(name, dir)
         return(
-          makeindex(name, ".glo", ".gls", ".glg", glossarystyle) +
-          makeindex(name, ".idx", ".ind", ".ilg", indexstyle)    +
-          tex(file)
+          makeindex(name, dir, ".glo", ".gls", ".glg", glossarystyle) +
+          makeindex(name, dir, ".idx", ".ind", ".ilg", indexstyle)    +
+          tex(file, dir)
         )
       end
-      errorlevel = cycle(name)
+      errorlevel = cycle(name, dir)
       if errorlevel == 0 then
-        errorlevel = cycle(name)
+        errorlevel = cycle(name, dir)
       end
     end
     return errorlevel
@@ -1883,7 +1893,7 @@ function doc(files)
   for _, typesetfiles in ipairs({typesetdemofiles, typesetfiles}) do
     for _,i in ipairs(typesetfiles) do
       for _, dir in ipairs({unpackdir, typesetdir}) do
-        for _,j in ipairs(filelist(dir, i)) do
+        for j,_ in pairs(tree(dir, i)) do
           -- Allow for command line selection of files
           local typeset = true
           if files and next(files) then
@@ -1896,7 +1906,7 @@ function doc(files)
             end
           end
           if typeset then
-            local errorlevel = typesetpdf(abspath(dir) .. "/" .. j)
+            local errorlevel = typesetpdf(j, dir)
             if errorlevel ~= 0 then
               return errorlevel
             end

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the latex3-commits mailing list