From c96a660e4d38ec2d3c5fd25fa74a04bc47c62845 Mon Sep 17 00:00:00 2001 From: Lukas Schrangl Date: Sun, 4 Aug 2019 12:11:33 +0200 Subject: Run latex after bibtex/biber only when necessary Although comments in src/engine/SCons/Tool/tex.py indicated that latex should only be run after biber/bibtex if the .bbl file had changed, it was always run. --- CHANGES.txt | 3 +++ SCons/Tool/tex.py | 4 ++-- test/TEX/biber_biblatex2.py | 17 ++++++++++++++--- test/TEX/bibtex-latex-rerun.py | 16 +++++++++++++--- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index cae5783..2308a2f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1066,6 +1066,9 @@ RELEASE 3.1.1 - Mon, 07 Aug 2019 20:09:12 -0500 - JSON encoding errors for CacheDir config - JSON decoding errors for CacheDir config + From Lukas Schrangl: + - Run LaTeX after biber/bibtex only if necessary + RELEASE 3.1.0 - Mon, 20 Jul 2019 16:59:23 -0700 diff --git a/SCons/Tool/tex.py b/SCons/Tool/tex.py index 6d0a5fb..b9dd29e 100644 --- a/SCons/Tool/tex.py +++ b/SCons/Tool/tex.py @@ -345,7 +345,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None result = BibTeXAction(bibfile, bibfile, env) if result != 0: check_file_error_message(env['BIBTEX'], 'blg') - must_rerun_latex = True + check_MD5(suffix_nodes[".bbl"], ".bbl") # Now decide if biber will need to be run. # When the backend for biblatex is biber (by choice or default) the @@ -369,7 +369,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None result = BiberAction(bibfile, bibfile, env) if result != 0: check_file_error_message(env['BIBER'], 'blg') - must_rerun_latex = True + check_MD5(suffix_nodes[".bbl"], ".bbl") # 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): diff --git a/test/TEX/biber_biblatex2.py b/test/TEX/biber_biblatex2.py index 92c7ea9..049f06e 100644 --- a/test/TEX/biber_biblatex2.py +++ b/test/TEX/biber_biblatex2.py @@ -72,7 +72,7 @@ sources_bib_content = r""" """ test.write(['ref.bib'],sources_bib_content % '2013' ) -test.write(['bibertest.tex'],r""" +sources_tex_content = r""" \documentclass{article} \usepackage{biblatex} @@ -80,13 +80,14 @@ test.write(['bibertest.tex'],r""" \begin{document} -Hello. This is boring. +Hello. This is %s boring. \cite{mybook} And even more boring. \printbibliography \end{document} -""") +""" +test.write(['bibertest.tex'], sources_tex_content % "") test.run() @@ -110,7 +111,17 @@ for f in files: pdf_output_1 = test.read('bibertest.pdf') +# Change tex, but don't change bib. In this case, pdf should still be rebuilt. +test.write(['bibertest.tex'], sources_tex_content % "very") +test.run() +pdf_output_1a = test.read('bibertest.pdf') +# If the PDF file is the same as it was previously, then it didn't +# pick up the change in the tex file, so fail. +test.fail_test(pdf_output_1 == pdf_output_1a) + +# Change bib. +test.write(['bibertest.tex'], sources_tex_content % "") test.write(['ref.bib'],sources_bib_content % '1982') test.run() diff --git a/test/TEX/bibtex-latex-rerun.py b/test/TEX/bibtex-latex-rerun.py index f0f8c34..7334f1e 100644 --- a/test/TEX/bibtex-latex-rerun.py +++ b/test/TEX/bibtex-latex-rerun.py @@ -47,14 +47,14 @@ env = Environment(tools=['pdftex', 'tex']) env.PDF( 'bibtest.tex' ) """) -test.write(['bibtest.tex'], r""" +sources_tex_content = r""" \documentclass{article} \begin{document} -Learn about cool math in \cite{koblitz:elliptic_curves}. +Learn about %s cool math in \cite{koblitz:elliptic_curves}. \bibliographystyle{alpha} \bibliography{sources} \end{document} -""") +""" sources_bib_content = r""" @book{koblitz:elliptic_curves, @@ -67,14 +67,24 @@ sources_bib_content = r""" +test.write(['bibtest.tex'], sources_tex_content % "") test.write('sources.bib', sources_bib_content % '1981') test.run() pdf_output_1 = test.read('bibtest.pdf') +# Change tex, but don't change bib. In this case, pdf should still be rebuilt. +test.write(['bibtest.tex'], sources_tex_content % "really") +test.run() +pdf_output_1a = test.read('bibtest.pdf') +# If the PDF file is the same as it was previously, then it didn't +# pick up the change in the tex file, so fail. +test.fail_test(pdf_output_1 == pdf_output_1a) +# Change bib. +test.write(['bibtest.tex'], sources_tex_content % "") test.write('sources.bib', sources_bib_content % '1982') test.run() -- cgit v0.12