summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/luat-fmt.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-02-17 10:31:56 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-02-17 10:31:56 +0100
commitb14f992ef5f4e868c9959b174278c86516d60dbc (patch)
tree28587bb46c025ea7b0d27ba93f09c93dcf53c73a /tex/context/base/mkiv/luat-fmt.lua
parent95a1799032dc61dbca4a11e495be34b4397c8fec (diff)
downloadcontext-b14f992ef5f4e868c9959b174278c86516d60dbc.tar.gz
2017-02-17 10:23:00
Diffstat (limited to 'tex/context/base/mkiv/luat-fmt.lua')
-rw-r--r--tex/context/base/mkiv/luat-fmt.lua49
1 files changed, 41 insertions, 8 deletions
diff --git a/tex/context/base/mkiv/luat-fmt.lua b/tex/context/base/mkiv/luat-fmt.lua
index b5ea5685a..fe3c1042c 100644
--- a/tex/context/base/mkiv/luat-fmt.lua
+++ b/tex/context/base/mkiv/luat-fmt.lua
@@ -51,6 +51,33 @@ end
-- The silent option is Taco. It's a bit of a hack because we cannot yet mess
-- with directives. In fact, I could probably clean up the maker a bit by now.
+local template = [[--ini %primaryflags% --lua="%luafile%" "%texfile%" %secondaryflags% %dump% %redirect%]]
+local checkers = {
+ primaryflags = "string",
+ secondaryflags = "string",
+ luafile = "readable", -- "cache"
+ texfile = "readable", -- "cache"
+ redirect = "string",
+ dump = "string",
+}
+
+local runners = {
+ luatex = sandbox.registerrunner {
+ name = "make luatex format",
+ program = "luatex",
+ template = template,
+ checkers = checkers,
+ reporter = report_format,
+ },
+ luajittex = sandbox.registerrunner {
+ name = "make luajittex format",
+ program = "luajittex",
+ template = template,
+ checkers = checkers,
+ reporter = report_format,
+ },
+}
+
function environment.make_format(name,arguments)
local engine = environment.ownmain or "luatex"
local silent = environment.arguments.silent
@@ -116,13 +143,20 @@ function environment.make_format(name,arguments)
return
end
-- generate format
- local dump = os.platform=="unix" and "\\\\dump" or "\\dump"
- local command = format("%s --ini %s --lua=%s %s %s %s",
- engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),secondaryflags(),dump)
- if silent then
+ local specification = {
+ primaryflags = primaryflags(),
+ secondaryflags = secondaryflags(),
+ luafile = usedluastub,
+ texfile = fulltexsourcename,
+ dump = os.platform == "unix" and "\\\\dump" or "\\dump",
+ }
+ local runner = runners[engine]
+ if not runner then
+ report_format("format %a cannot be generated, no runner available for engine %a",name,engine)
+ elseif silent then
statistics.starttiming()
- local command = format("%s > temp.log",command)
- local result = os.execute(command)
+ specification.redirect = "> temp.log"
+ local result = makeformat(specification)
local runtime = statistics.stoptiming()
if result ~= 0 then
print(format("%s silent make > fatal error when making format %q",engine,name)) -- we use a basic print
@@ -131,8 +165,7 @@ function environment.make_format(name,arguments)
end
os.remove("temp.log")
else
- report_format("running command: %s\n",command)
- os.execute(command)
+ makeformat(specification)
end
-- remove related mem files
local pattern = file.removesuffix(file.basename(usedluastub)).."-*.mem"