diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/grph-fil.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/grph-fil.lua | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/Master/texmf-dist/tex/context/base/grph-fil.lua b/Master/texmf-dist/tex/context/base/grph-fil.lua index 2e32c7a6066..0856f5b0854 100644 --- a/Master/texmf-dist/tex/context/base/grph-fil.lua +++ b/Master/texmf-dist/tex/context/base/grph-fil.lua @@ -8,35 +8,58 @@ if not modules then modules = { } end modules ['grph-fil'] = { local format, concat = string.format, table.concat -local trace_run = false trackers.register("files.run",function(v) trace_run = v end) +local trace_run = false trackers.register("graphic.runfile",function(v) trace_run = v end) -local command = "context %s" +local report_run = logs.reporter("graphics","run") -jobfiles = jobfiles or { } -jobfiles.collected = jobfiles.collected or { } -jobfiles.tobesaved = jobfiles.tobesaved or { } +local allocate = utilities.storage.allocate -local tobesaved, collected = jobfiles.tobesaved, jobfiles.collected +local collected = allocate() +local tobesaved = allocate() + +local jobfiles = { + collected = collected, + tobesaved = tobesaved, +} + +job.files = jobfiles local function initializer() - tobesaved, collected = jobfiles.tobesaved, jobfiles.collected + tobesaved = jobfiles.tobesaved + collected = jobfiles.collected end -job.register('jobfiles.collected', jobfiles.tobesaved, initializer) +job.register('job.files.collected', tobesaved, initializer) jobfiles.forcerun = false -function jobfiles.run(name,...) +function jobfiles.run(name,command) local oldchecksum = collected[name] local newchecksum = file.checksum(name) if jobfiles.forcerun or not oldchecksum or oldchecksum ~= newchecksum then if trace_run then - commands.writestatus("buffers","changes in '%s', processing forced",name) + report_run("processing file, changes in '%s', processing forced",name) + end + if command and command ~= "" then + os.execute(command) + else + report_run("processing file, no command given for processing '%s'",name) end - os.execute(format(command,concat({ name, ... }," "))) elseif trace_run then - commands.writestatus("buffers","no changes in '%s', not processed",name) + report_run("processing file, no changes in '%s', not processed",name) end tobesaved[name] = newchecksum - return file.replacesuffix(name,"pdf") +end + +function jobfiles.context(name,options) + if type(name) == "table" then + local result = { } + for i=1,#name do + result[#result+1] = jobfiles.context(name[i],options) + end + return result + else + jobfiles.run(name,"context ".. (options or "") .. " " .. name) + return file.replacesuffix(name,"pdf") + end end |