[latex3-commits] [git/LaTeX3-latex3-l3build] standalone: Load build.lua 'late' if called directly (see #50) (54500b3)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Mar 6 10:21:45 CET 2018


Repository : https://github.com/latex3/l3build
On branch  : standalone
Link       : https://github.com/latex3/l3build/commit/54500b3baf5cfcd842e6f1a0809a89c318669ec1

>---------------------------------------------------------------

commit 54500b3baf5cfcd842e6f1a0809a89c318669ec1
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon Mar 5 22:58:12 2018 +0000

    Load build.lua 'late' if called directly (see #50)
    
    This is the first key step to making a stand-alone script.
    
    Note that one now needs to do "texlua l3build" or similar.
    
    Various bits and pieces outstanding!


>---------------------------------------------------------------

54500b3baf5cfcd842e6f1a0809a89c318669ec1
 build.lua   |    3 ---
 l3build.lua |   20 ++++++++++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/build.lua b/build.lua
index 40c56cc..520d301 100644
--- a/build.lua
+++ b/build.lua
@@ -38,6 +38,3 @@ function setversion_update_line(line, date, version)
   end
   return line
 end
-
--- Load l3build itself: truly self-contained so no kpsewhich() here
-dofile("./l3build.lua")
diff --git a/l3build.lua b/l3build.lua
index b81d405..e1294f4 100644
--- a/l3build.lua
+++ b/l3build.lua
@@ -33,6 +33,7 @@ local lfs = require("lfs")
 local assert           = assert
 local ipairs           = ipairs
 local lookup           = kpse.lookup
+local match            = string.match
 local next             = next
 local print            = print
 local select           = select
@@ -66,6 +67,25 @@ build_require("stdmain")
 -- Allow main function to be disabled 'higher up'
 main = main or stdmain
 
+-- Load configuration file if running as a script
+if match(arg[0], "l3build(%.lua)$") then
+  -- Options which do not need any configuration
+  if options["help"] then
+    help()
+    exit(0)
+  -- Look for some configuration details
+  elseif fileexists("build.lua") then
+    -- Force these to be undefined: needed for the reloading step
+    dofile("build.lua")
+    -- Reload the variables to set things up correctly
+    -- Has to be dofile() as require() doesn't reload
+    dofile(lookup("l3build-variables.lua", { path = build_kpse_path } ))
+  else
+    print("Error: Cannot find configuration build.lua")
+    exit(1)
+  end
+end
+
 --
 -- Deal with multiple configs for tests
 --





More information about the latex3-commits mailing list