From 021501855e5e14602a36bc34498435dbcea267df Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 11 Jan 2011 23:19:49 +0000 Subject: latexmk 4.22b (11jan11) git-svn-id: svn://tug.org/texlive/trunk@21032 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/latexmk/latexmk.pl | 173 ++++++++++++++++++++++----- 1 file changed, 145 insertions(+), 28 deletions(-) (limited to 'Master/texmf-dist/scripts/latexmk') diff --git a/Master/texmf-dist/scripts/latexmk/latexmk.pl b/Master/texmf-dist/scripts/latexmk/latexmk.pl index b03c9a58da6..4353be4b11c 100755 --- a/Master/texmf-dist/scripts/latexmk/latexmk.pl +++ b/Master/texmf-dist/scripts/latexmk/latexmk.pl @@ -107,8 +107,8 @@ use warnings; $my_name = 'latexmk'; $My_name = 'Latexmk'; -$version_num = '4.21'; -$version_details = "$My_name, John Collins, 28 December 2010"; +$version_num = '4.22b'; +$version_details = "$My_name, John Collins, 9 January 2011"; use Config; @@ -177,6 +177,11 @@ else { ## ## Modification log from 23 Jun 2010 onwards in detail ## +## 9 Jan 2011, John Collins Correct parsing of blg file for biber 0.7.2 +## 3 Jan 2011, John Collins Small correction on reading .fdb_file +## 1 Jan 2011, John Collins Biber implementation +## 30 Dec 2010, John Collins Version number to 4.22 +## Start for biber ## 28 Dec 2010, John Collins Version number to 4.21 ## 1. Improved handling of quotes in filenames in log file: ## a. Clean double quotes in names from messages about files. @@ -386,9 +391,11 @@ add_input_ext( 'latex', 'tex', 'eps' ); add_input_ext( 'pdflatex', 'tex', 'jpg', 'pdf' ); #show_input_ext( 'latex' ); show_input_ext( 'pdflatex' ); -## Command to invoke bibtex +## Command to invoke biber & bibtex +$biber = 'biber %O %B'; $bibtex = 'bibtex %O %B'; -# Switch(es) to make bibtex silent: +# Switch(es) to make biber & bibtex silent: +$biber_silent_switch = '--onlylog'; $bibtex_silent_switch = '-terse'; $bibtex_use = 1; # Whether to actually run bibtex to update bbl files # 0: Never run bibtex @@ -1527,6 +1534,7 @@ if ( $landscape_mode ) if ( $silent ) { add_option( \$latex, " $latex_silent_switch" ); add_option( \$pdflatex, " $pdflatex_silent_switch" ); + add_option( \$biber, " $biber_silent_switch" ); add_option( \$bibtex, " $bibtex_silent_switch" ); add_option( \$makeindex, " $makeindex_silent_switch" ); add_option( \$dvips, " $dvips_silent_switch" ); @@ -1620,11 +1628,6 @@ $quell_uptodate_msgs = $silent; # Whether to quell informational messages when files are uptodate # Will turn off in -pvc mode -# Process for each file. -# The value of $bibtex_mode set in an initialization file may get -# overridden, during file processing, so save it: -#?? Unneeded now: $save_bibtex_mode = $bibtex_mode; - $failure_count = 0; @failed_primaries = (); @@ -1917,7 +1920,7 @@ sub fix_cmds { # Source only if ( $_ && ! /%/ ) { $_ .= " %O %S"; } } - foreach ($bibtex) { + foreach ($biber, $bibtex) { # Base only if ( $_ && ! /%/ ) { $_ .= " %O %B"; } } @@ -2075,9 +2078,14 @@ sub rdb_make_links { #?? foreach (sort keys %from_rules) {print "D='$_' F='$from_rules{$_}\n";} rdb_for_all( 0, - sub{ - if ( exists $from_rules{$file} ) { $$Pfrom_rule = $from_rules{$file}; } -#?? print "$rule: $file, $$Pfrom_rule\n"; + sub{ + # Set from_rule, but only if it isn't set or is invalid. + # Don't forget the biber v. bibtex issue + if ( exists $from_rules{$file} + && ( (!$$Pfrom_rule) || (! exists $rule_db{$$Pfrom_rule} ) ) + ) + { $$Pfrom_rule = $from_rules{$file}; + } } ); rdb_for_all( @@ -2818,6 +2826,7 @@ sub print_commands warn "Commands used by $my_name:\n", " To run latex, I use \"$latex\"\n", " To run pdflatex, I use \"$pdflatex\"\n", + " To run biber, I use \"$biber\"\n", " To run bibtex, I use \"$bibtex\"\n", " To run makeindex, I use \"$makeindex\"\n", " To make a ps file from a dvi file, I use \"$dvips\"\n", @@ -2857,6 +2866,63 @@ sub view_file_via_temporary { #************************************************** +sub check_biber_log { + # Check for biber warnings: + # Usage: check_biber_log( base_of_biber_run[, \@biber_source ) + # return 0: OK, 1: biber warnings, 2: biber errors, + # 3: could not open .blg file. + # 10: only error is missing \citation commands. + # Side effect: add source files @biber_source + my $base = $_[0]; + my $Pbiber_source = $_[1]; + my $log_name = "$base.blg"; + my $log_file = new FileHandle; + open( $log_file, "<$log_name" ) + or return 3; + my $have_warning = 0; + my $have_error = 0; + my $missing_citations = 0; + my $no_citations = 0; + my $error_count = 0; + my $warning_count = 0; + while (<$log_file>) { + if (/> WARN /) { + print "Biber warning: $_"; + $have_warning = 1; + $warning_count ++; + } + elsif (/> FATAL /) { + print "Biber error: $_"; + $have_error = 1; + $error_count ++; + if ( /> FATAL - The file '[^']+' does not contain any citations!/ ) { + $no_citations++; + } + } + elsif ( /> INFO - Found .* '([^']+)'\s*$/ + || /> INFO - Found '([^']+)'\s*$/ + ) { + if ( defined $Pbiber_source ) { + push @$Pbiber_source, $1; + } + } + } + close $log_file; +# print "$My_name: #Biber errors = $error_count, warning messages = $warning_count,\n ", +# "missing citation messages = $missing_citations, no_citations = $no_citations\n"; + if ( ! $have_error && $no_citations ) { + # If the only errors are missing citations, or lack of citations, that should + # count as a warning. + # HOWEVER: biber doesn't generate a new bbl. So it is an error condition. + return 10; + } + if ($have_error) {return 2;} + if ($have_warning) {return 1;} + return 0; +} #END check_biber_log + +#************************************************** + sub check_bibtex_log { # Check for bibtex warnings: # Usage: check_bibtex_log( base_of_bibtex_run ) @@ -3811,7 +3877,7 @@ LINE: rdb_create_rule( $rule, 'cusdep', '', $PAnew_cmd, 1, $source, $dest, $base, 0, $run_time, 1 ); } - elsif ( $rule =~ /^(makeindex|bibtex)\s*(.*)$/ ) { + elsif ( $rule =~ /^(makeindex|bibtex|biber)\s*(.*)$/ ) { my $rule_generic = $1; if ( ! $source ) { # If fdb_file was old-style (v. 1) @@ -3827,6 +3893,10 @@ LINE: $dest = "$base.bbl"; $source = "$base.aux"; } + elsif ($rule_generic eq 'biber') { + $dest = "$base.bbl"; + $source = "$base.bcf"; + } } warn "$My_name: File-database '$in_name': setting rule '$rule'\n" if $diagnostics; @@ -4078,6 +4148,7 @@ sub rdb_set_from_logB { # $reference_changed, $bad_reference $bad_citation &parse_logB; +# ?? !! Should also deal with .run.xml file # Handle result on output file: # 1. Non-existent output file, which is because of no content. @@ -4129,19 +4200,37 @@ sub rdb_set_from_logB { my @new_bib_files = (); my @new_aux_files = (); my @new_bst_files = (); - &parse_aux( "$bbl_base.aux", \@new_bib_files, \@new_aux_files, \@new_bst_files ); - my $from_rule = "bibtex $bbl_base"; - print "!!!===Dealing with rule '$from_rule'\n" - if ($diagnostics); + my @biber_source = ( "$bbl_base.bcf" ); + my $bib_program = 'bibtex'; + if ( exists $generated_log{"$bbl_base.bcf"} ) { + $bib_program = 'biber'; + } + my $from_rule = "$bib_program $bbl_base"; + print "======= Dealing with '$from_rule'\n" if ($diagnostics); + if ($bib_program eq 'biber') { + check_biber_log( $bbl_base, \@biber_source ); + # Remove OPPOSITE kind of bbl generation: + rdb_remove_rule( "bibtex $bbl_base" ); + } + else { + parse_aux( "$bbl_base.aux", \@new_bib_files, \@new_aux_files, \@new_bst_files ); + # Remove OPPOSITE kind of bbl generation: + rdb_remove_rule( "biber $bbl_base" ); + } if ( ! rdb_rule_exists( $from_rule ) ){ - print " ===Creating rule '$from_rule'\n" - if ($diagnostics); - rdb_create_rule( $from_rule, 'external', $bibtex, '', 1, - "$bbl_base.aux", $bbl_file, $bbl_base, 1, 0); + print " ===Creating rule '$from_rule'\n" if ($diagnostics); + if ( $bib_program eq 'biber' ) { + rdb_create_rule( $from_rule, 'external', $biber, '', 1, + "$bbl_base.bcf", $bbl_file, $bbl_base, 1, 0); + } + else { + rdb_create_rule( $from_rule, 'external', $bibtex, '', 1, + "$bbl_base.aux", $bbl_file, $bbl_base, 1, 0); + } } local %old_sources = (); rdb_one_rule( $from_rule, sub { %old_sources = %$PHsource; } ); - foreach my $source ( @new_bib_files, @new_aux_files, @new_bst_files ) { + foreach my $source ( @new_bib_files, @new_aux_files, @new_bst_files, @biber_source ) { print " === Source file '$source' for '$from_rule'\n" if ($diagnostics); rdb_ensure_file( $from_rule, $source ); @@ -4151,7 +4240,7 @@ sub rdb_set_from_logB { foreach ( keys %old_sources ) { print "Removing no-longer-needed dependent '$_' from rule '$from_rule'\n"; } - } + } rdb_remove_files( $from_rule, keys %old_sources ); print " ===Source file '$bbl_file' for '$rule'\n" if ($diagnostics); @@ -4222,7 +4311,6 @@ NEW_SOURCE: print "No new source files for rule '$rule':\n"; } } - my @files_not_needed = (); foreach (keys %$PHsource) { if ( ! exists $dependents{$_} ) { @@ -4794,7 +4882,7 @@ sub rdb_makeB1 { # Carries out make at level of given rule (all data available). # Assumes contexts for recursion, make, and rule, and # assumes that source files for the rule are to be considered - # up-to-date. + # up-to-date. if ($diagnostics) { print " MakeB1 $rule\n"; } if ($failure & ! $force_mode) {return;} if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; } @@ -4810,7 +4898,7 @@ sub rdb_makeB1 { # (and setting to do this test) # 2 => don't run bibtex because of setting my @missing_bib_files = (); - if ( $rule =~ /^bibtex/ ) { + if ( $rule =~ /^(bibtex|biber)/ ) { $bibtex_not_run = 0; if ($bibtex_use == 0) { $bibtex_not_run = 2; @@ -5050,7 +5138,6 @@ sub rdb_classify1 { # Helper routine for rdb_classify_rules # Applied as rule_act1 in recursion over rules # Assumes rule context, and local variables from rdb_classify_rules - #print "??======= '$rule' $depth $state ========== \n"; push @classify_stack, [$state]; if ( exists $possible_one_time{$rule} ) { # Normally, we will have already extracted the one_time rules, @@ -5127,6 +5214,27 @@ sub rdb_run1 { $$Plast_result = 2; $$Plast_message = "Bug or configuration error; incorrect command type"; } + if ( $rule =~ /^biber/ ) { + my $retcode = check_biber_log($$Pbase); + if ($retcode == 3) { + $$Plast_result = 2; + $$Plast_message = "Could not open biber log file for '$$Pbase'"; + push @warnings, $$Plast_message; + } + elsif ($retcode == 2) { + $$Plast_message = "Biber errors: See file '$$Pbase.blg'"; + push @warnings, $$Plast_message; + } + elsif ($retcode == 1) { + push @warnings, "Biber warnings for '$$Pbase'"; + } + elsif ($retcode == 10) { + push @warnings, "Biber found no citations for '$$Pbase'"; + # Biber doesn't generate a bbl file in this situation. So I cannot + # ignore the error the way I do with bibtex. + #$return = 0; + } + } if ( $rule =~ /^bibtex/ ) { my $retcode = check_bibtex_log($$Pbase); if ($retcode == 3) { @@ -5742,6 +5850,15 @@ sub rdb_one_file { #************************************************************ +sub rdb_remove_rule { + # rdb_remove_rule( rule, ... ) + foreach my $key (@_) { + delete $rule_db{$key}; + } +} + +#************************************************************ + sub rdb_create_rule { # rdb_create_rule( rule, command_type, ext_cmd, int_cmd, test_kind, # source, dest, base, -- cgit v1.2.3