Source

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

Diff from to

src/engine/SCons/Tool/tex.py

 check_suffixes = ['.toc', '.lof', '.lot', '.out', '.nav', '.snm']
 
 # these are files that require bibtex or makeindex to be run when they change
-all_suffixes = check_suffixes + ['.bbl', '.idx', '.nlo', '.glo', '.acn']
+all_suffixes = check_suffixes + ['.bbl', '.idx', '.nlo', '.glo', '.acn', '.bcf']
 
 #
 # regular expressions used to search for Latex features
 # search for all .aux files opened by latex (recorded in the .fls file)
 openout_aux_re = re.compile(r"OUTPUT *(.*\.aux)")
 
+# search for all .bcf files opened by latex (recorded in the .fls file)
+# for use by biber
+openout_bcf_re = re.compile(r"OUTPUT *(.*\.bcf)")
+
 #printindex_re = re.compile(r"^[^%]*\\printindex", re.MULTILINE)
 #printnomenclature_re = re.compile(r"^[^%]*\\printnomenclature", re.MULTILINE)
 #printglossary_re = re.compile(r"^[^%]*\\printglossary", re.MULTILINE)
                 dups[x] = 1
             auxfiles = list(dups.keys())
 
+        bcffiles = []
+        if os.path.isfile(flsfilename):
+            flsContent = open(flsfilename, "rb").read()
+            bcffiles = openout_bcf_re.findall(flsContent)
+            # remove duplicates
+            dups = {}
+            for x in bcffiles:
+                dups[x] = 1
+            bcffiles = list(dups.keys())
+
         if Verbose:
             print "auxfiles ",auxfiles
+            print "bcffiles ",bcffiles
 
         # Now decide if bibtex will need to be run.
         # The information that bibtex reads from the .aux file is
                             check_file_error_message(env['BIBTEX'], 'blg')
                         must_rerun_latex = True
 
+        # Now decide if biber will need to be run.
+        # The information that bibtex reads from the .bcf file is
+        # pass-independent. If we find (below) that the .bbl file is unchanged,
+        # then the last latex saw a correct bibliography.
+        # Therefore only do this once
+        # Go through all .bcf files and remember the files already done.
+        for bcffilename in bcffiles:
+            if bcffilename not in already_bibtexed:
+                already_bibtexed.append(bcffilename)
+                target_bcf = os.path.join(targetdir, bcffilename)
+                if os.path.isfile(target_bcf):
+                    content = open(target_bcf, "rb").read()
+                    if content.find("bibdata") != -1:
+                        if Verbose:
+                            print "Need to run bibtex on ",bcffilename
+                        bibfile = env.fs.File(SCons.Util.splitext(target_bcf)[0])
+                        result = BibTeXAction(bibfile, bibfile, env)
+                        if result != 0:
+                            check_file_error_message(env['BIBTEX'], 'blg')
+                        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
                   ['.bbl', '.blg','bibliography'],
                   ['.bbl', '.blg','bibunit'],
                   ['.bbl', '.blg','multibib'],
-                  ['.bbl', '.blg','addbibresource'],
+                  ['.bbl', '.blg','.bcf','addbibresource'],
                   ['.toc','contents'],
                   ['.lof','figures'],
                   ['.lot','tables'],
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.