Commits

Rob Managan committed 4103e51

Add support for the biblatex package; search for new keywards to get side effects and dependencies right

  • Participants
  • Parent commits 1c28012

Comments (0)

Files changed (4)

File src/CHANGES.txt

 
   From Rob Managan:
     - Updated the TeX builder to support LaTeX's multibib package.
+    - Updated the TeX build to support LeTeX's biblatex package.
 
   From Arve Knudsen:
     - Test for FORTRANPPFILESUFFIXES (#2129).

File src/engine/SCons/Scanner/LaTeX.py

                      'includegraphics': 'TEXINPUTS',
                      'bibliography': 'BIBINPUTS',
                      'bibliographystyle': 'BSTINPUTS',
+                     'addbibresource': 'BIBINPUTS',
+                     'addglobalbib': 'BIBINPUTS',
+                     'addsectionbib': 'BIBINPUTS',
                      'makeindex': 'INDEXSTYLE',
                      'usepackage': 'TEXINPUTS',
                      'lstinputlisting': 'TEXINPUTS'}
         # line followed by one or more newline characters (i.e. blank
         # lines), interfering with a match on the next line.
         # add option for whitespace before the '[options]' or the '{filename}'
-        regex = r'^[^%\n]*\\(include|includegraphics(?:\s*\[[^\]]+\])?|lstinputlisting(?:\[[^\]]+\])?|input|bibliography|usepackage)\s*{([^}]*)}'
+        regex = r'^[^%\n]*\\(include|includegraphics(?:\s*\[[^\]]+\])?|lstinputlisting(?:\[[^\]]+\])?|input|bibliography|addbibresource|addglobalbib|addsectionbib|usepackage)\s*{([^}]*)}'
         self.cre = re.compile(regex, re.M)
         self.comment_re = re.compile(r'^((?:(?:\\%)|[^%\n])*)(.*)$', re.M)
 

File src/engine/SCons/Tool/tex.py

 # or outputs that require rerunning latex
 #
 # search for all .aux files opened by latex (recorded in the .fls file)
-openout_aux_re = re.compile(r"INPUT *(.*\.aux)")
+openout_aux_re = re.compile(r"OUTPUT *(.*\.aux)")
 
 #printindex_re = re.compile(r"^[^%]*\\printindex", re.MULTILINE)
 #printnomenclature_re = re.compile(r"^[^%]*\\printnomenclature", re.MULTILINE)
 bibliography_re = re.compile(r"^[^%\n]*\\bibliography", re.MULTILINE)
 bibunit_re = re.compile(r"^[^%\n]*\\begin\{bibunit\}", re.MULTILINE)
 multibib_re = re.compile(r"^[^%\n]*\\newcites\{([^\}]*)\}", re.MULTILINE)
+addbibresource_re = re.compile(r"^[^%\n]*\\(addbibresource|addglobalbib|addsectionbib)", re.MULTILINE)
 listoffigures_re = re.compile(r"^[^%\n]*\\listoffigures", re.MULTILINE)
 listoftables_re = re.compile(r"^[^%\n]*\\listoftables", re.MULTILINE)
 hyperref_re = re.compile(r"^[^%\n]*\\usepackage.*\{hyperref\}", re.MULTILINE)
                         result = BibTeXAction(bibfile, bibfile, env)
                         if result != 0:
                             check_file_error_message(env['BIBTEX'], 'blg')
-                        #must_rerun_latex = must_rerun_latex or check_MD5(suffix_nodes['.bbl'],'.bbl')
                         must_rerun_latex = True
+
         # Now decide if latex will need to be run again due to index.
         if check_MD5(suffix_nodes['.idx'],'.idx') or (count == 1 and run_makeindex):
             # We must run makeindex
                          bibliography_re,
                          bibunit_re,
                          multibib_re,
+                         addbibresource_re,
                          tableofcontents_re,
                          listoffigures_re,
                          listoftables_re,
                   ['.bbl', '.blg','bibliography'],
                   ['.bbl', '.blg','bibunit'],
                   ['.bbl', '.blg','multibib'],
+                  ['.bbl', '.blg','addbibresource'],
                   ['.toc','contents'],
                   ['.lof','figures'],
                   ['.lot','tables'],
                 file_list = glob.glob(file_basename)
                 # remove the suffix '.aux'
                 for i in range(len(file_list)):
-                    file_list[i] = SCons.Util.splitext(file_list[i])[0]
+                    file_list.append(SCons.Util.splitext(file_list[i])[0])
             # for multibib we need a list of files
             if suffix_list[-1] == 'multibib':
-                file_list = []
                 for multibibmatch in multibib_re.finditer(content):
                     if Verbose:
                         print "multibib match ",multibibmatch.group(1)
                 for suffix in suffix_list[:-1]:
                     env.SideEffect(file_name + suffix,target[0])
                     if Verbose:
-                        print "side effect :",file_name + suffix
+                        print "side effect tst :",file_name + suffix, " target is ",str(target[0])
                     env.Clean(target[0],file_name + suffix)
 
     for aFile in aux_files:
         aFile_base = SCons.Util.splitext(aFile)[0]
         env.SideEffect(aFile_base + '.aux',target[0])
         if Verbose:
-            print "side effect :",aFile_base + '.aux'
+            print "side effect aux :",aFile_base + '.aux'
         env.Clean(target[0],aFile_base + '.aux')
     # read fls file to get all other files that latex creates and will read on the next pass
     # remove files from list that we explicitly dealt with above
                 out_files.remove(filename)
         env.SideEffect(out_files,target[0])
         if Verbose:
-            print "side effect :",out_files
+            print "side effect fls :",out_files
         env.Clean(target[0],out_files)
 
     return (target, source)

File test/TEX/biblatex.py

+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test creation of a Tex document that uses the multibib oackage
+
+Test courtesy Rob Managan.
+"""
+
+import TestSCons
+import os
+
+test = TestSCons.TestSCons()
+
+latex = test.where_is('pdflatex')
+if not latex:
+    test.skip_test("Could not find 'pdflatex'; skipping test.\n")
+
+gloss = os.system('kpsewhich biblatex.sty')
+if not gloss==0:
+    test.skip_test("biblatex.sty not installed; skipping test(s).\n")
+
+
+test.write(['SConstruct'], """\
+#!/usr/bin/env python
+
+import os
+env = Environment(ENV=os.environ)
+main_output = env.PDF(target='biblatextest.pdf', source='biblatextest.tex')
+""")
+
+
+sources_bib_content = r"""
+@book{mybook,
+  title={Title},
+  author={Author, A},
+  year={%s},
+  publisher={Publisher},
+}
+"""
+test.write(['ref.bib'],sources_bib_content % '2013' )
+
+test.write(['biblatextest.tex'],r"""
+\documentclass{article}
+
+\usepackage{biblatex}
+\addbibresource{ref.bib}
+
+\begin{document}
+
+Hello. This is boring.
+\cite{mybook}
+And even more boring.
+
+\printbibliography
+\end{document}
+""")
+
+
+test.run()
+
+
+# All (?) the files we expect will get created in the docs directory
+files = [
+    'biblatextest.aux',
+    'biblatextest.bbl',
+    'biblatextest.blg',
+    'biblatextest-blx.bib',
+    'biblatextest.fls',
+    'biblatextest.log',
+    'biblatextest.pdf',
+    'biblatextest.run.xml',
+]
+
+for f in files:
+    test.must_exist([ f])
+
+pdf_output_1 = test.read('biblatextest.pdf')
+
+
+
+test.write(['ref.bib'],sources_bib_content % '1982')
+
+test.run()
+
+pdf_output_2 = test.read('biblatextest.pdf')
+
+pdf_output_1 = test.normalize_pdf(pdf_output_1)
+pdf_output_2 = test.normalize_pdf(pdf_output_2)
+
+# If the PDF file is the same as it was previously, then it didn't
+# pick up the change from 1981 to 1982, so fail.
+test.fail_test(pdf_output_1 == pdf_output_2)
+
+test.pass_test()