[latex3-commits] [git/LaTeX3-latex3-l3build] master: Load build.lua 'late' if called directly (see #50) (494b046)
Joseph Wright
joseph.wright at morningstar2.co.uk
Tue Mar 6 19:38:53 CET 2018
Repository : https://github.com/latex3/l3build
On branch : master
Link : https://github.com/latex3/l3build/commit/494b046b0300b5063f1be9c9c5440079cf456e79
>---------------------------------------------------------------
commit 494b046b0300b5063f1be9c9c5440079cf456e79
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!
>---------------------------------------------------------------
494b046b0300b5063f1be9c9c5440079cf456e79
build.lua | 3 ---
l3build.lua | 20 ++++++++++++++++++++
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/build.lua b/build.lua
index 254f76c..e4669ff 100644
--- a/build.lua
+++ b/build.lua
@@ -55,6 +55,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 0acb767..32306a6 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