summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/luat-fmt.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/luat-fmt.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/luat-fmt.lua65
1 files changed, 33 insertions, 32 deletions
diff --git a/Master/texmf-dist/tex/context/base/luat-fmt.lua b/Master/texmf-dist/tex/context/base/luat-fmt.lua
index cfb9a0bb776..20a4a8fcdf7 100644
--- a/Master/texmf-dist/tex/context/base/luat-fmt.lua
+++ b/Master/texmf-dist/tex/context/base/luat-fmt.lua
@@ -6,36 +6,38 @@ if not modules then modules = { } end modules ['luat-fmt'] = {
license = "see context related readme files"
}
-
local format = string.format
+local concat = table.concat
+local quoted = string.quoted
+local luasuffixes = utilities.lua.suffixes
local report_format = logs.reporter("resolvers","formats")
--- helper for mtxrun
-
-local quoted = string.quoted
-
local function primaryflags() -- not yet ok
local trackers = environment.argument("trackers")
local directives = environment.argument("directives")
- local flags = ""
+ local flags = { }
if trackers and trackers ~= "" then
- flags = flags .. "--trackers=" .. quoted(trackers)
+ flags = { "--trackers=" .. quoted(trackers) }
end
if directives and directives ~= "" then
- flags = flags .. "--directives=" .. quoted(directives)
+ flags = { "--directives=" .. quoted(directives) }
+ end
+ if environment.argument("jit") then
+ flags = { "--jiton" }
end
- return flags
+ return concat(flags," ")
end
function environment.make_format(name)
+ local engine = environment.ownmain or "luatex"
-- change to format path (early as we need expanded paths)
- local olddir = lfs.currentdir()
- local path = caches.getwritablepath("formats") or "" -- maybe platform
+ local olddir = dir.current()
+ local path = caches.getwritablepath("formats",engine) or "" -- maybe platform
if path ~= "" then
lfs.chdir(path)
end
- report_format("format path: %s",lfs.currentdir())
+ report_format("using format path %a",dir.current())
-- check source file
local texsourcename = file.addsuffix(name,"mkiv")
local fulltexsourcename = resolvers.findfile(texsourcename,"tex") or ""
@@ -44,11 +46,11 @@ function environment.make_format(name)
fulltexsourcename = resolvers.findfile(texsourcename,"tex") or ""
end
if fulltexsourcename == "" then
- report_format("no tex source file with name: %s (mkiv or tex)",name)
+ report_format("no tex source file with name %a (mkiv or tex)",name)
lfs.chdir(olddir)
return
else
- report_format("using tex source file: %s",fulltexsourcename)
+ report_format("using tex source file %a",fulltexsourcename)
end
local texsourcepath = dir.expandname(file.dirname(fulltexsourcename)) -- really needed
-- check specification
@@ -59,7 +61,7 @@ function environment.make_format(name)
fullspecificationname = resolvers.findfile(specificationname,"tex") or ""
end
if fullspecificationname == "" then
- report_format("unknown stub specification: %s",specificationname)
+ report_format("unknown stub specification %a",specificationname)
lfs.chdir(olddir)
return
end
@@ -70,39 +72,38 @@ function environment.make_format(name)
if type(usedlualibs) == "string" then
usedluastub = file.join(file.dirname(fullspecificationname),usedlualibs)
elseif type(usedlualibs) == "table" then
- report_format("using stub specification: %s",fullspecificationname)
+ report_format("using stub specification %a",fullspecificationname)
local texbasename = file.basename(name)
- local luastubname = file.addsuffix(texbasename,"lua")
- local lucstubname = file.addsuffix(texbasename,"luc")
+ local luastubname = file.addsuffix(texbasename,luasuffixes.lua)
+ local lucstubname = file.addsuffix(texbasename,luasuffixes.luc)
-- pack libraries in stub
- report_format("creating initialization file: %s",luastubname)
+ report_format("creating initialization file %a",luastubname)
utilities.merger.selfcreate(usedlualibs,specificationpath,luastubname)
-- compile stub file (does not save that much as we don't use this stub at startup any more)
- local strip = resolvers.booleanvariable("LUACSTRIP", true)
if utilities.lua.compile(luastubname,lucstubname) and lfs.isfile(lucstubname) then
- report_format("using compiled initialization file: %s",lucstubname)
+ report_format("using compiled initialization file %a",lucstubname)
usedluastub = lucstubname
else
- report_format("using uncompiled initialization file: %s",luastubname)
+ report_format("using uncompiled initialization file %a",luastubname)
usedluastub = luastubname
end
else
- report_format("invalid stub specification: %s",fullspecificationname)
+ report_format("invalid stub specification %a",fullspecificationname)
lfs.chdir(olddir)
return
end
-- generate format
- local command = format("luatex --ini %s --lua=%s %s %sdump",primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),os.platform == "unix" and "\\\\" or "\\")
+ local command = format("%s --ini %s --lua=%s %s %sdump",engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),os.platform == "unix" and "\\\\" or "\\")
report_format("running command: %s\n",command)
os.spawn(command)
-- remove related mem files
local pattern = file.removesuffix(file.basename(usedluastub)).."-*.mem"
- -- report_format("removing related mplib format with pattern '%s'", pattern)
+ -- report_format("removing related mplib format with pattern %a", pattern)
local mp = dir.glob(pattern)
if mp then
for i=1,#mp do
local name = mp[i]
- report_format("removing related mplib format %s", file.basename(name))
+ report_format("removing related mplib format %a", file.basename(name))
os.remove(name)
end
end
@@ -110,16 +111,16 @@ function environment.make_format(name)
end
function environment.run_format(name,data,more)
- -- hm, rather old code here; we can now use the file.whatever functions
if name and name ~= "" then
+ local engine = environment.ownmain or "luatex"
local barename = file.removesuffix(name)
- local fmtname = caches.getfirstreadablefile(file.addsuffix(barename,"fmt"),"formats")
+ local fmtname = caches.getfirstreadablefile(file.addsuffix(barename,"fmt"),"formats",engine)
if fmtname == "" then
fmtname = resolvers.findfile(file.addsuffix(barename,"fmt")) or ""
end
fmtname = resolvers.cleanpath(fmtname)
if fmtname == "" then
- report_format("no format with name: %s",name)
+ report_format("no format with name %a",name)
else
local barename = file.removesuffix(name) -- expanded name
local luaname = file.addsuffix(barename,"luc")
@@ -127,10 +128,10 @@ function environment.run_format(name,data,more)
luaname = file.addsuffix(barename,"lua")
end
if not lfs.isfile(luaname) then
- report_format("using format name: %s",fmtname)
- report_format("no luc/lua with name: %s",barename)
+ report_format("using format name %a",fmtname)
+ report_format("no luc/lua file with name %a",barename)
else
- local command = format("luatex %s --fmt=%s --lua=%s %s %s",primaryflags(),quoted(barename),quoted(luaname),quoted(data),more ~= "" and quoted(more) or "")
+ local command = format("%s %s --fmt=%s --lua=%s %s %s",engine,primaryflags(),quoted(barename),quoted(luaname),quoted(data),more ~= "" and quoted(more) or "")
report_format("running command: %s",command)
os.spawn(command)
end