waf

FORK: waf with some random patches
git clone https://git.neptards.moe/neptards/waf.git
Log | Files | Refs | README

biber.py (1629B)


      1 #!/usr/bin/env python
      2 # encoding: utf-8
      3 # Thomas Nagy, 2011 (ita)
      4 
      5 """
      6 Latex processing using "biber"
      7 """
      8 
      9 import os
     10 from waflib import Task, Logs
     11 
     12 from waflib.Tools import tex as texmodule
     13 
     14 class tex(texmodule.tex):
     15 	biber_fun, _ = Task.compile_fun('${BIBER} ${BIBERFLAGS} ${SRCFILE}',shell=False)
     16 	biber_fun.__doc__ = """
     17 	Execute the program **biber**
     18 	"""
     19 
     20 	def bibfile(self):
     21 		return None
     22 
     23 	def bibunits(self):
     24 		self.env.env = {}
     25 		self.env.env.update(os.environ)
     26 		self.env.env.update({'BIBINPUTS': self.texinputs(), 'BSTINPUTS': self.texinputs()})
     27 		self.env.SRCFILE = self.aux_nodes[0].name[:-4]
     28 
     29 		if not self.env['PROMPT_LATEX']:
     30 			self.env.append_unique('BIBERFLAGS', '--quiet')
     31 
     32 		path = self.aux_nodes[0].abspath()[:-4] + '.bcf'
     33 		if os.path.isfile(path):
     34 			Logs.warn('calling biber')
     35 			self.check_status('error when calling biber, check %s.blg for errors' % (self.env.SRCFILE), self.biber_fun())
     36 		else:
     37 			super(tex, self).bibfile()
     38 			super(tex, self).bibunits()
     39 
     40 class latex(tex):
     41 	texfun, vars = Task.compile_fun('${LATEX} ${LATEXFLAGS} ${SRCFILE}', shell=False)
     42 class pdflatex(tex):
     43 	texfun, vars =  Task.compile_fun('${PDFLATEX} ${PDFLATEXFLAGS} ${SRCFILE}', shell=False)
     44 class xelatex(tex):
     45 	texfun, vars = Task.compile_fun('${XELATEX} ${XELATEXFLAGS} ${SRCFILE}', shell=False)
     46 
     47 def configure(self):
     48 	"""
     49 	Almost the same as in tex.py, but try to detect 'biber'
     50 	"""
     51 	v = self.env
     52 	for p in ' biber tex latex pdflatex xelatex bibtex dvips dvipdf ps2pdf makeindex pdf2ps'.split():
     53 		try:
     54 			self.find_program(p, var=p.upper())
     55 		except self.errors.ConfigurationError:
     56 			pass
     57 	v['DVIPSFLAGS'] = '-Ppdf'
     58