summaryrefslogtreecommitdiff
path: root/tex/context/base/grph-fil.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2010-07-04 15:32:09 +0300
committerMarius <mariausol@gmail.com>2010-07-04 15:32:09 +0300
commit85b7bc695629926641c7cb752fd478adfdf374f3 (patch)
tree80293f5aaa7b95a500a78392c39688d8ee7a32fc /tex/context/base/grph-fil.lua
downloadcontext-85b7bc695629926641c7cb752fd478adfdf374f3.tar.gz
stable 2010-05-24 13:10
Diffstat (limited to 'tex/context/base/grph-fil.lua')
-rw-r--r--tex/context/base/grph-fil.lua42
1 files changed, 42 insertions, 0 deletions
diff --git a/tex/context/base/grph-fil.lua b/tex/context/base/grph-fil.lua
new file mode 100644
index 000000000..2e32c7a60
--- /dev/null
+++ b/tex/context/base/grph-fil.lua
@@ -0,0 +1,42 @@
+if not modules then modules = { } end modules ['grph-fil'] = {
+ version = 1.001,
+ comment = "companion to grph-fig.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local format, concat = string.format, table.concat
+
+local trace_run = false trackers.register("files.run",function(v) trace_run = v end)
+
+local command = "context %s"
+
+jobfiles = jobfiles or { }
+jobfiles.collected = jobfiles.collected or { }
+jobfiles.tobesaved = jobfiles.tobesaved or { }
+
+local tobesaved, collected = jobfiles.tobesaved, jobfiles.collected
+
+local function initializer()
+ tobesaved, collected = jobfiles.tobesaved, jobfiles.collected
+end
+
+job.register('jobfiles.collected', jobfiles.tobesaved, initializer)
+
+jobfiles.forcerun = false
+
+function jobfiles.run(name,...)
+ 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)
+ end
+ os.execute(format(command,concat({ name, ... }," ")))
+ elseif trace_run then
+ commands.writestatus("buffers","no changes in '%s', not processed",name)
+ end
+ tobesaved[name] = newchecksum
+ return file.replacesuffix(name,"pdf")
+end