summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2007-01-12 15:56:00 +0100
committerHans Hagen <pragma@wxs.nl>2007-01-12 15:56:00 +0100
commitef711d047d8d3e8d2cfb53e4c42b170365c06b84 (patch)
tree852e27402e9cfe63c8edf45f54cc0273abf54368 /scripts
parent4b886e1937606a539d02dafab04a2f5e399d7ca3 (diff)
downloadcontext-ef711d047d8d3e8d2cfb53e4c42b170365c06b84.tar.gz
stable 2007.01.12 15:56
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/ruby/base/ctx.rb69
-rw-r--r--scripts/context/ruby/base/kpse.rb2
-rw-r--r--scripts/context/ruby/base/kpsefast.rb4
-rw-r--r--scripts/context/ruby/base/tex.rb88
-rw-r--r--scripts/context/ruby/texexec.rb3
-rw-r--r--scripts/context/ruby/texmfstart.rb8
6 files changed, 104 insertions, 70 deletions
diff --git a/scripts/context/ruby/base/ctx.rb b/scripts/context/ruby/base/ctx.rb
index 4ee2715b8..f86e92d18 100644
--- a/scripts/context/ruby/base/ctx.rb
+++ b/scripts/context/ruby/base/ctx.rb
@@ -43,6 +43,7 @@ class CtxRunner
@modules = Array.new
@filters = Array.new
@flags = Array.new
+ @local = false
end
def manipulate(ctxname=nil,defaultname=nil)
@@ -117,18 +118,18 @@ class CtxRunner
variables['job'] = @jobname
end
root = @xmldata.root
-REXML::XPath.each(root,"/ctx:job//ctx:flags/ctx:flag") do |flg|
- @flags << justtext(flg)
-end
-REXML::XPath.each(root,"/ctx:job//ctx:resources/ctx:environment") do |sty|
- @environments << justtext(sty)
-end
-REXML::XPath.each(root,"/ctx:job//ctx:resources/ctx:module") do |mod|
- @modules << justtext(mod)
-end
-REXML::XPath.each(root,"/ctx:job//ctx:resources/ctx:filter") do |fil|
- @filters << justtext(fil)
-end
+ REXML::XPath.each(root,"/ctx:job//ctx:flags/ctx:flag") do |flg|
+ @flags << justtext(flg)
+ end
+ REXML::XPath.each(root,"/ctx:job//ctx:resources/ctx:environment") do |sty|
+ @environments << justtext(sty)
+ end
+ REXML::XPath.each(root,"/ctx:job//ctx:resources/ctx:module") do |mod|
+ @modules << justtext(mod)
+ end
+ REXML::XPath.each(root,"/ctx:job//ctx:resources/ctx:filter") do |fil|
+ @filters << justtext(fil)
+ end
begin
REXML::XPath.each(root,"//ctx:block") do |blk|
if @jobname && blk.attributes['pattern'] then
@@ -154,9 +155,9 @@ end
REXML::XPath.each(root,"/ctx:job//ctx:process/ctx:resources/ctx:filter") do |fil|
@filters << justtext(fil)
end
-REXML::XPath.each(root,"/ctx:job//ctx:process/ctx:flags/ctx:flag") do |flg|
- @flags << justtext(flg)
-end
+ REXML::XPath.each(root,"/ctx:job//ctx:process/ctx:flags/ctx:flag") do |flg|
+ @flags << justtext(flg)
+ end
commands = Hash.new
REXML::XPath.each(root,"/ctx:job//ctx:preprocess/ctx:processors/ctx:processor") do |pre|
begin
@@ -172,6 +173,11 @@ end
else
if suffix && suffix.empty? then suffix = @@suffix end
end
+ if (REXML::XPath.first(root,"/ctx:job//ctx:preprocess/ctx:processors/@local").to_s =~ /(yes|true)/io rescue false) then
+ @local = true
+ else
+ @local = false
+ end
REXML::XPath.each(root,"/ctx:job//ctx:preprocess/ctx:files") do |files|
REXML::XPath.each(files,"ctx:file") do |pattern|
preprocessor = pattern.attributes['processor']
@@ -189,9 +195,14 @@ end
return
end
pattern = justtext(pattern)
- Dir.glob(pattern).each do |oldfile|
+ oldfiles = Dir.glob(pattern)
+ if oldfiles.length == 0 then
+ report("no files match #{pattern}")
+ end
+ oldfiles.each do |oldfile|
newfile = "#{oldfile}.#{suffix}"
- if File.needsupdate(oldfile,newfile) then
+ newfile = File.basename(newfile) if @local
+ if File.expand_path(oldfile) != File.expand_path(newfile) && File.needsupdate(oldfile,newfile) then
report("#{oldfile} needs preprocessing")
begin
File.delete(newfile)
@@ -205,14 +216,16 @@ end
command = REXML::Document.new(command.to_s) # don't infect original
command = command.elements["ctx:processor"]
begin
- if suf = command.attributes['suffix'] then
- newfile = "#{oldfile}.#{suf}"
- end
+ newfile = "#{oldfile}.#{suf}" if suf = command.attributes['suffix']
+ rescue
+ end
+ begin
+ newfile = File.basename(newfile) if @local
rescue
end
- report("preprocessing #{oldfile} into #{newfile} using #{pp}")
REXML::XPath.each(command,"ctx:old") do |value| replace(value,oldfile) end
REXML::XPath.each(command,"ctx:new") do |value| replace(value,newfile) end
+ report("preprocessing #{oldfile} into #{newfile} using #{pp}")
variables['old'] = oldfile
variables['new'] = newfile
REXML::XPath.each(command,"ctx:value") do |value|
@@ -225,15 +238,19 @@ end
unless ok = System.run(command) then
report("error in preprocessing file #{oldfile}")
end
+ begin
+ oldfile = File.basename(oldfile) if @local
+ rescue
+ end
end
end
if FileTest.file?(newfile) then
File.syncmtimes(oldfile,newfile)
else
- report("preprocessing #{oldfile} gave no #{newfile}")
+ report("check target location of #{newfile}")
end
else
- report("#{oldfile} needs no preprocessing")
+ report("#{oldfile} needs no preprocessing (same file)")
end
@prepfiles[oldfile] = FileTest.file?(newfile)
end
@@ -258,7 +275,11 @@ end
if @prepfiles.length > 0 then
if log = File.open(ctlname,'w') then
log << "<?xml version='1.0' standalone='yes'?>\n\n"
- log << "<ctx:preplist>\n"
+ if @local then
+ log << "<ctx:preplist local='yes'>\n"
+ else
+ log << "<ctx:preplist local='no'>\n"
+ end
@prepfiles.keys.sort.each do |prep|
# log << "\t<ctx:prepfile done='#{yes_or_no(@prepfiles[prep])}'>#{File.basename(prep)}</ctx:prepfile>\n"
log << "\t<ctx:prepfile done='#{yes_or_no(@prepfiles[prep])}'>#{prep}</ctx:prepfile>\n"
diff --git a/scripts/context/ruby/base/kpse.rb b/scripts/context/ruby/base/kpse.rb
index bff3cc1fa..a4babae55 100644
--- a/scripts/context/ruby/base/kpse.rb
+++ b/scripts/context/ruby/base/kpse.rb
@@ -197,7 +197,7 @@ module Kpse
[progname,format,filename].join('-')
end
- def Kpse.formatpath(engine='pdfetex',enginepath=true)
+ def Kpse.formatpath(engine='pdftex',enginepath=true)
# because engine support in distributions is not always
# as we expect, we need to check for it;
diff --git a/scripts/context/ruby/base/kpsefast.rb b/scripts/context/ruby/base/kpsefast.rb
index 24ff1a0fa..8a9f89593 100644
--- a/scripts/context/ruby/base/kpsefast.rb
+++ b/scripts/context/ruby/base/kpsefast.rb
@@ -260,7 +260,7 @@ class KpseFast
@rootpath = ''
@treepath = ''
@progname = 'kpsewhich'
- @engine = 'pdfetex'
+ @engine = 'pdftex'
@variables = Hash.new
@expansions = Hash.new
@files = Hash.new
@@ -910,7 +910,7 @@ end
# puts k.expansion("$TEXMF")
# puts k.expanded_path("TEXINPUTS","context")
- # k.progname, k.engine, k.format = 'context', 'pdfetex', 'tfm'
+ # k.progname, k.engine, k.format = 'context', 'pdftex', 'tfm'
# k.scandisk = false # == must_exist
# k.expand_variables
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index 5674157b5..ca73754f4 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -89,25 +89,27 @@ class TEX
@@luafiles = "luafiles.tmp"
@@luatarget = "lua/context"
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |p|
- if System.unix? then
- pp, pe = "#{p}/pdftex" , "#{p}/pdfetex"
- else
- pp, pe = "#{p}/pdftex.exe", "#{p}/pdfetex.exe"
- end
- if FileTest.file?(pe) then
- # we assume no update
- @@pdftex = 'pdfetex'
- break
- elsif FileTest.file?(pp) then
- # we assume an update
- @@pdftex = 'pdftex'
- break
- end
- end
+ # we now drop pdfetex definitely
+
+ # ENV['PATH'].split(File::PATH_SEPARATOR).each do |p|
+ # if System.unix? then
+ # pp, pe = "#{p}/pdftex" , "#{p}/pdfetex"
+ # else
+ # pp, pe = "#{p}/pdftex.exe", "#{p}/pdfetex.exe"
+ # end
+ # if FileTest.file?(pe) then # we assume no update
+ # @@pdftex = 'pdfetex'
+ # break
+ # elsif FileTest.file?(pp) then # we assume an update
+ # @@pdftex = 'pdftex'
+ # break
+ # end
+ # end
+
+ # ['etex','pdfetex','standard'] .each do |e| @@texengines[e] = @@pdftex end
+ # ['tex','pdftex'] .each do |e| @@texengines[e] = 'pdftex' end
- ['etex','pdfetex','standard'] .each do |e| @@texengines[e] = @@pdftex end
- ['tex','pdftex'] .each do |e| @@texengines[e] = 'pdftex' end
+ ['tex','etex','pdftex','pdfetex','standard'] .each do |e| @@texengines[e] = 'pdftex' end
['aleph','omega'] .each do |e| @@texengines[e] = 'aleph' end
['xetex'] .each do |e| @@texengines[e] = 'xetex' end
['luatex'] .each do |e| @@texengines[e] = 'luatex' end
@@ -166,10 +168,11 @@ class TEX
['cont-en','cont-nl','cont-de','cont-it',
'cont-fr','cont-cz','cont-ro','cont-uk'] .each do |f| @@texprocstr[f] = "\\emergencyend" end
- # @@runoptions['xetex'] = ['--output-driver \\\"-d 4 -V 5\\\"'] # we need the pos pass
- @@runoptions['xetex'] = ['--8bit,-no-pdf'] # from now on we assume (x)dvipdfmx to be used
- @@runoptions['pdfetex'] = ['--8bit']
- @@runoptions['pdftex'] = ['--8bit'] # pdftex is now pdfetex
+ # @@runoptions['xetex'] = ['--output-driver \\\"-d 4 -V 5\\\"'] # we need the pos pass
+ # @@runoptions['xetex'] = ['--8bit','-no-pdf'] # from now on we assume (x)dvipdfmx to be used
+ @@runoptions['xetex'] = ['--8bit','-output-driver=\"xdvipdfmx -q -E -d 4 -V 5\"']
+ @@runoptions['pdfetex'] = ['--8bit'] # obsolete
+ @@runoptions['pdftex'] = ['--8bit'] # pdftex is now pdfetex
@@runoptions['luatex'] = ['--file-line-error']
@@runoptions['aleph'] = ['--8bit']
@@runoptions['mpost'] = ['--8bit']
@@ -188,7 +191,8 @@ class TEX
'forcetexutil', 'texutil',
'globalfile', 'autopath',
'purge', 'purgeall', 'keep', 'autopdf', 'xpdf', 'simplerun', 'verbose',
- 'nooptionfile', 'nobackend', 'noctx', 'utfbom'
+ 'nooptionfile', 'nobackend', 'noctx', 'utfbom',
+ 'mkii',
]
@@stringvars = [
'modefile', 'result', 'suffix', 'response', 'path',
@@ -326,6 +330,7 @@ class TEX
str = '' # allocate
[name].flatten.each do |n|
if str = getvariable(n) then
+ str = str.join(" ") if str.class == Array
unless (str.class == String) && str.empty? then
report("option '#{n}' is set to '#{str}'")
end
@@ -435,10 +440,10 @@ class TEX
if str.class == String then str.split(',') else str.flatten end
end
- def validtexformat(str) validsomething(str,@@texformats,'tex') end
- def validmpsformat(str) validsomething(str,@@mpsformats,'mp' ) end
- def validtexengine(str) validsomething(str,@@texengines,'pdfetex') end
- def validmpsengine(str) validsomething(str,@@mpsengines,'mpost' ) end
+ def validtexformat(str) validsomething(str,@@texformats,'tex') end
+ def validmpsformat(str) validsomething(str,@@mpsformats,'mp' ) end
+ def validtexengine(str) validsomething(str,@@texengines,'pdftex') end
+ def validmpsengine(str) validsomething(str,@@mpsengines,'mpost' ) end
def validtexmethod(str) [validsomething(str,@@texmethods)].flatten.first end
def validmpsmethod(str) [validsomething(str,@@mpsmethods)].flatten.first end
@@ -612,10 +617,10 @@ class TEX
begin
luatools = `texmfstart luatools --format=texmfscripts luatools.lua`.chomp.strip
unless luatools.empty? then
- runcommand(["luatex","--luaonly=#{luatools}","--generate","--verbose"])
+ runcommand(["luatex","--luaonly #{luatools}","--generate","--verbose"])
end
rescue
- report("run 'luatex --luaonly=....../luatools.lua --generate' manually")
+ report("run 'luatex --luaonly pathto/luatools.lua --generate' manually")
exit
end
end
@@ -651,7 +656,10 @@ class TEX
cleanupluafiles
texformats.each do |texformat|
report("generating tex format #{texformat}")
- run_luatools("--ini --compile #{texformat}")
+ flags = ['--ini','--compile']
+ flags << '--verbose' if getvariable('verbose')
+ flags << '--mkii' if getvariable('mkii')
+ run_luatools("#{flags.join(" ")} #{texformat}")
end
compileluafiles
else
@@ -1152,7 +1160,7 @@ class TEX
if path then
script = "#{path}/../lua/luatools.lua"
if FileTest.file?(script) then
- return runcommand("lua #{script} #{args}")
+ return runcommand("luatex --luaonly #{script} #{args}")
end
end
end
@@ -1528,12 +1536,16 @@ class TEX
report("tex format: #{texformat}")
if texengine && texformat then
fixbackendvars(@@mappaths[texengine])
-if texengine == "luatex" then
- run_luatools("--fmt=#{texformat} #{filename}")
-else
- progname = validprogname([getvariable('progname'),texformat,texengine])
- runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag,runoptions(texengine),filename,texprocextras(texformat)])
-end
+ if texengine == "luatex" then
+ # currently we use luatools to start luatex but some day we should
+ # find a clever way to directly call luatex (problem is that we need
+ # to feed the explicit location of the format and lua initialization
+ # file)
+ run_luatools("--fmt=#{texformat} #{filename}")
+ else
+ progname = validprogname([getvariable('progname'),texformat,texengine])
+ runcommand([quoted(texengine),prognameflag(progname),formatflag(texengine,texformat),tcxflag,runoptions(texengine),filename,texprocextras(texformat)])
+ end
# true
else
false
@@ -1683,7 +1695,7 @@ end
xdvfile = File.suffixed(rawname,'xdv')
if FileTest.file?(xdvfile) then
fixbackendvars('dvipdfm')
- runcommand("xdvipdfmx -d 4 -V 5 #{xdvfile}")
+ runcommand("xdvipdfmx -q -d 4 -V 5 -E #{xdvfile}")
end
when 'xdv2pdf' then
xdvfile = File.suffixed(rawname,'xdv')
diff --git a/scripts/context/ruby/texexec.rb b/scripts/context/ruby/texexec.rb
index 992766c05..f37cfd8c2 100644
--- a/scripts/context/ruby/texexec.rb
+++ b/scripts/context/ruby/texexec.rb
@@ -573,7 +573,7 @@ class Commands
if (str = @commandline.option('engine')) && ! str.standard? && ! str.empty? then
job.setvariable('texengine',str)
elsif @commandline.oneof('pdfetex','pdftex','pdf') then
- job.setvariable('texengine','pdfetex')
+ job.setvariable('texengine','pdftex')
elsif @commandline.oneof('xetex','xtx') then
job.setvariable('texengine','xetex')
elsif @commandline.oneof('aleph') then
@@ -601,6 +601,7 @@ class Commands
else
case job.getvariable('texengine')
when 'pdfetex' then job.setvariable('backend','pdftex')
+ when 'pdftex' then job.setvariable('backend','pdftex')
when 'luatex' then job.setvariable('backend','pdftex')
when 'xetex' then job.setvariable('backend','xetex')
when 'aleph' then job.setvariable('backend','dvipdfmx')
diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb
index 9a19995a1..4d1e29761 100644
--- a/scripts/context/ruby/texmfstart.rb
+++ b/scripts/context/ruby/texmfstart.rb
@@ -425,7 +425,7 @@ class KpseFast
@rootpath = ''
@treepath = ''
@progname = 'kpsewhich'
- @engine = 'pdfetex'
+ @engine = 'pdftex'
@variables = Hash.new
@expansions = Hash.new
@files = Hash.new
@@ -1074,7 +1074,7 @@ end
# puts k.expansion("$TEXMF")
# puts k.expanded_path("TEXINPUTS","context")
- # k.progname, k.engine, k.format = 'context', 'pdfetex', 'tfm'
+ # k.progname, k.engine, k.format = 'context', 'pdftex', 'tfm'
# k.scandisk = false # == must_exist
# k.expand_variables
@@ -2571,10 +2571,10 @@ end
if execute(ARGV) then
report("\nexecution was successful") if $verbose
- exit(1)
+ exit(0)
else
report("\nexecution failed") if $verbose
- exit(0)
+ exit(1)
end
# exit (if ($?.to_i rescue 0) > 0 then 1 else 0 end)