diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/context/luatex/luatex-basics-gen.lua')
-rw-r--r-- | Master/texmf-dist/tex/generic/context/luatex/luatex-basics-gen.lua | 86 |
1 files changed, 58 insertions, 28 deletions
diff --git a/Master/texmf-dist/tex/generic/context/luatex/luatex-basics-gen.lua b/Master/texmf-dist/tex/generic/context/luatex/luatex-basics-gen.lua index 288cfa2e15d..4a46fbb0782 100644 --- a/Master/texmf-dist/tex/generic/context/luatex/luatex-basics-gen.lua +++ b/Master/texmf-dist/tex/generic/context/luatex/luatex-basics-gen.lua @@ -11,9 +11,14 @@ if context then os.exit() end -local dummyfunction = function() end ------ dummyreporter = function(c) return function(...) texio.write_nl(c .. " : " .. string.format(...)) end end -local dummyreporter = function(c) return function(...) texio.write_nl(c .. " : " .. string.formatters(...)) end end +local dummyfunction = function() +end + +local dummyreporter = function(c) + return function(...) + (texio.reporter or texio.write_nl)(c .. " : " .. string.formatters(...)) + end +end statistics = { register = dummyfunction, @@ -130,7 +135,9 @@ end caches = { } -local writable, readables = nil, { } +local writable = nil +local readables = { } +local usingjit = jit if not caches.namespace or caches.namespace == "" or caches.namespace == "context" then caches.namespace = 'generic' @@ -138,16 +145,24 @@ end do - local cachepaths = kpse.expand_path('$TEXMFCACHE') or "" + -- standard context tree setup + + local cachepaths = kpse.expand_var('$TEXMFCACHE') or "" + + -- quite like tex live or so if cachepaths == "" then - cachepaths = kpse.expand_path('$TEXMFVAR') + cachepaths = kpse.expand_var('$TEXMFVAR') or "" end + -- this also happened to be used + if cachepaths == "" then - cachepaths = kpse.expand_path('$VARTEXMF') + cachepaths = kpse.expand_var('$VARTEXMF') or "" end + -- and this is a last resort + if cachepaths == "" then cachepaths = "." end @@ -155,8 +170,15 @@ do cachepaths = string.split(cachepaths,os.type == "windows" and ";" or ":") for i=1,#cachepaths do - if file.is_writable(cachepaths[i]) then - writable = file.join(cachepaths[i],"luatex-cache") + local cachepath = cachepaths[i] + if not lfs.isdir(cachepath) then + lfs.mkdirs(cachepath) -- needed for texlive and latex + if lfs.isdir(cachepath) then + texio.write(string.format("(created cache path: %s)",cachepath)) + end + end + if file.is_writable(cachepath) then + writable = file.join(cachepath,"luatex-cache") lfs.mkdir(writable) writable = file.join(writable,caches.namespace) lfs.mkdir(writable) @@ -203,8 +225,7 @@ end local function makefullname(path,name) if path and path ~= "" then - name = "temp-" .. name -- clash prevention - return file.addsuffix(file.join(path,name),"lua"), file.addsuffix(file.join(path,name),"luc") + return file.addsuffix(file.join(path,name),"lua"), file.addsuffix(file.join(path,name),usingjit and "lub" or "luc") end end @@ -265,27 +286,36 @@ end -- this) in which case one should limit the method to luac and enable support -- for execution. -caches.compilemethod = "both" +-- function caches.compile(data,luaname,lucname) +-- local d = io.loaddata(luaname) +-- if not d or d == "" then +-- d = table.serialize(data,true) -- slow +-- end +-- if d and d ~= "" then +-- local f = io.open(lucname,'w') +-- if f then +-- local s = loadstring(d) +-- if s then +-- f:write(string.dump(s,true)) +-- end +-- f:close() +-- end +-- end +-- end function caches.compile(data,luaname,lucname) - local done = false - if caches.compilemethod == "luac" or caches.compilemethod == "both" then - done = os.spawn("texluac -o " .. string.quoted(lucname) .. " -s " .. string.quoted(luaname)) == 0 + local d = io.loaddata(luaname) + if not d or d == "" then + d = table.serialize(data,true) -- slow end - if not done and (caches.compilemethod == "dump" or caches.compilemethod == "both") then - local d = io.loaddata(luaname) - if not d or d == "" then - d = table.serialize(data,true) -- slow - end - if d and d ~= "" then - local f = io.open(lucname,'w') - if f then - local s = loadstring(d) - if s then - f:write(string.dump(s,true)) - end - f:close() + if d and d ~= "" then + local f = io.open(lucname,'wb') + if f then + local s = loadstring(d) + if s then + f:write(string.dump(s,true)) end + f:close() end end end |