From 4d12c3875aa543d42fc585b4771c9b9ef6981424 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 16 Jan 2010 23:43:33 +0000 Subject: latexmk 4.13 git-svn-id: svn://tug.org/texlive/trunk@16749 c570f23f-e606-0410-a88d-b1316a301751 --- .../texk/texlive/linked_scripts/latexmk/latexmk.pl | 209 +++++++++++++-------- 1 file changed, 127 insertions(+), 82 deletions(-) (limited to 'Build') diff --git a/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl b/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl index 0588b2efe9c..2ea0e023e8f 100755 --- a/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl +++ b/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl @@ -95,6 +95,7 @@ use warnings; # 2. Convert errors to failure only in calling routine # 3. Save first warning/error. +# ?? Use of generated_exts arrays and hashes needs rationalization # To do: # Rationalize again handling of include files. @@ -107,8 +108,8 @@ use warnings; $my_name = 'latexmk'; $My_name = 'Latexmk'; -$version_num = '4.11'; -$version_details = "$My_name, John Collins, 27 November 2009"; +$version_num = '4.13'; +$version_details = "$My_name, John Collins, 13 January 2010"; use Config; @@ -141,7 +142,7 @@ else { warn "Something wrong with the perl configuration: No signals?\n"; } -## Copyright John Collins 1998-2009 +## Copyright John Collins 1998-2010 ## (username collins at node phys.psu.edu) ## (and thanks to David Coppit (username david at node coppit.org) ## for suggestions) @@ -175,8 +176,17 @@ else { ## 5. Parsing of log file instead of source file is used to ## obtain dependencies, by default. ## -## Modification log from 21 Aug 2009 onwards in detail +## Modification log from 25 Nov 2009 onwards in detail ## +## 13 Jan 2010, John Collins V. 4.13 +## 27 Dec 2009, John Collins Correct position of inserting bbl into list +## of generated extensions. +## Correct clean_up. It stopped deleting aux +## file. +## $bibtex_use defaults to 1. +## 15 Dec 2009, John Collins Option not to do bibtex +## (to allow for case that bbl files +## are available, but no bibtex). ## 27 Nov 2009, John Collins Solve problem that changes in \include ## files weren't reflected in changes ## in bibtex source files. @@ -205,20 +215,6 @@ else { ## that uses the file. ## Avoided excess md5 calculations at ## startup. -## 24 Nov 2009, John Collins Start 4.11 -## 22 Sep 2009, John Collins Bibtex error => message see blg file. -## 10 Sep 2009, John Collins When tmp view file is moved to view file, -## delete original file first. Avoids -## bug in kpdf -## 4 Sep 2009, John Collins A missing file message is now suppressed -## when -silent option used -## kpsewhich is used to find non-existent -## converted files (as with epstopdf) -## 1 Sep 2009, John Collins Change "last FILE" to "next FILE" -## on failure in main loop. -## I had earlier changed this from "next FILE" to -## "last FILE" (for v. 4.08), but I don't see why. -## 21 Aug 2009, John Collins V. 4.10 for CTAN release. ## ## 1998-2009, John Collins. Many improvements and fixes. ## See CHANGE-log.txt for full list, and CHANGES for summary @@ -384,6 +380,14 @@ add_input_ext( 'pdflatex', 'tex', 'jpg', 'pdf' ); $bibtex = 'bibtex %O %B'; # Switch(es) to make bibtex silent: $bibtex_silent_switch = '-terse'; +$bibtex_use = 1; # Whether to actually run bibtex to update bbl files + # 0: Never run bibtex + # 1: Run bibtex only if the bibfiles exists + # according to kpsewhich, and the bbl files + # appear to be out-of-date + # 2: Run bibtex when the bbl files are out-of-date + # In any event bibtex is only run if the log file + # indicates that the document uses bbl files. ## Command to invoke makeindex $makeindex = 'makeindex %O -o %D %S'; @@ -838,7 +842,8 @@ $landscape_mode = 0; # default to portrait mode # the run (which might correct the error) should provoke a # rerun, but a change in a generated file should not. # These arrays can be user-configured. -@generated_exts = ( 'aux', 'bbl', 'idx', 'ind', 'lof', 'lot', 'out', 'toc' ); + +@generated_exts = ( 'aux', 'idx', 'ind', 'lof', 'lot', 'out', 'toc' ); # N.B. 'out' is generated by hyperref package # Which kinds of file do I have requests to make? @@ -1189,6 +1194,10 @@ read_first_rc_file_in_list( "latexmkrc", ".latexmkrc" ); #================================================== +if ($bibtex_use > 1) { + push @generated_exts, 'bbl'; +} + #show_array ("BIBINPUTS", @BIBINPUTS); die; ## Process command line args. @@ -1202,7 +1211,11 @@ while ($_ = $ARGV[0]) # Make -- and - equivalent at beginning of option: s/^--/-/; shift; - if (/^-c$/) { $cleanup_mode = 2; $cleanup_fdb = 1; $cleanup_only = 1; } + if (/^-bibtex$/) { $bibtex_use = 2; } + elsif (/^-bibtex-$/) { $bibtex_use = 0; } + elsif (/^-nobibtex$/) { $bibtex_use = 0; } + elsif (/^-bibtex-cond$/) { $bibtex_use = 1; } + elsif (/^-c$/) { $cleanup_mode = 2; $cleanup_fdb = 1; $cleanup_only = 1; } elsif (/^-C$/ || /^-CA$/ ) { $cleanup_mode = 1; $cleanup_fdb = 1; $cleanup_only = 1; } elsif (/^-CF$/) { $cleanup_fdb = 1; } elsif (/^-cd$/) { $do_cd = 1; } @@ -1228,13 +1241,13 @@ while ($_ = $ARGV[0]) $jobname = $1; } elsif (/^-l$/) { $landscape_mode = 1; } + elsif (/^-l-$/) { $landscape_mode = 0; } elsif (/^-new-viewer$/) { $new_viewer_always = 1; } elsif (/^-new-viewer-$/) { $new_viewer_always = 0; } - elsif (/^-l-$/) { $landscape_mode = 0; } elsif (/^-p$/) { $printout_mode = 1; $preview_continuous_mode = 0; # to avoid conflicts $preview_mode = 0; @@ -1635,26 +1648,38 @@ foreach $filename ( @file_list ) if ( ($go_mode == 2) && !$silent ) { warn "$My_name: Removing all generated files\n" unless $silent; } - foreach (@index_bibtex_generated, @aux_files) { + if ($bibtex_use < 2) { + delete $generated_exts_all{'bbl'}; + } + my %index_bibtex_generated = (); + my %aux_files = (); + foreach (@index_bibtex_generated) { + $index_bibtex_generated{$_} = 1 + unless ( /\.bbl$/ && ($bibtex_use < 2) ); + delete( $other_generated{$_} ); + } + foreach (@aux_files) { + $aux_files{$_} = 1; delete( $other_generated{$_} ); } if ($diagnostics) { show_array( "For deletion:\n" ." Generated (from makeindex and bibtex):", - @index_bibtex_generated ); - show_array( " Aux files:", @aux_files ); + keys %index_bibtex_generated ); + show_array( " Aux files:", keys %aux_files ); show_array( "Other generated files:\n" ." (only deleted if \$cleanup_includes_generated is set): ", keys %other_generated ); } - # Add to the generated files, some log file and some backup # files used in previous versions of latexmk &cleanup1( $fdb_ext, 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak', split(' ',$clean_ext), - @generated_exts + keys %generated_exts_all ); - unlink( 'texput.log', @index_bibtex_generated, "texput.aux", @aux_files ); + unlink( 'texput.log', "texput.aux", + keys %index_bibtex_generated, + keys %aux_files ); if ($cleanup_includes_generated) { unlink( keys %other_generated ); } @@ -2587,6 +2612,9 @@ sub print_help "$My_name $version_num: Automatic LaTeX document generation routine\n\n", "Usage: $my_name [latexmk_options] [filename ...]\n\n", " Latexmk_options:\n", + " -bibtex - use bibtex when needed (default)\n", + " -bibtex- - never use bibtex\n", + " -bibtex-cond - use bibtex when needed, but only if the bib files exist\n", " -bm - Print message across the page when converting to postscript\n", " -bi - Set contrast or intensity of banner\n", " -bs - Set scale for banner\n", @@ -2624,8 +2652,9 @@ sub print_help " implementations of latex/pdflatex.)\n", " -l - force landscape mode\n", " -l- - turn off -l\n", - " -new-viewer - in -pvc mode, always start a new viewer\n", - " -new-viewer- - in -pvc mode, start a new viewer only if needed\n", + " -new-viewer - in -pvc mode, always start a new viewer\n", + " -new-viewer- - in -pvc mode, start a new viewer only if needed\n", + " -nobibtex - never use bibtex\n", " -nodependents - Do not show list of dependent files after processing\n", " -pdf - generate pdf by pdflatex\n", " -pdfdvi - generate pdf by dvipdf\n", @@ -4097,8 +4126,6 @@ MISSING_FILE: } } -## ?? Is this correct? I used to use @includes -# rdb_update_files_for_rule( keys %PHsources ); if ( $diagnostics && ( $found > 0 ) ) { warn "$My_name: Detected previously missing files:\n"; foreach ( sort keys %new_includes ) { @@ -4110,53 +4137,6 @@ MISSING_FILE: #************************************************************ -sub rdb_update_files_for_rule { -#=========== APPEARS NOT TO BE USED! ========================= -# Usage: rdb_update_files_for_rule( source_files ...) -# Assume rule context. -# Update list of source files for current rule, treating properly cases -# where file didn't exist before run, etc - foreach my $file ( @_ ) { - if ( ! rdb_file_exists( $rule, $file ) ) { - # File that didn't appear in the source files for the run - # before. Two cases: (a) it was created during the run; - # (b) it existed before the run. - # If case (a), then the file was non-existent before the - # run, so we must now label it as non-existent, and - # we trigger a new run -#?? print "?? Adding '$file' to '$rule'\n"; - rdb_ensure_file( $rule, $file ); - my $file_time = get_mtime0( $file ); - if ( ($$Ptest_kind == 2) || ($$Ptest_kind == 3) ) { - # Test wrt destination time, but exclude files - # which appear to be generated (according to extension) - # Assume generated files up-to-date after last run. - # I.e., last run was valid. - my $ext = ext( $file ); - - if ( (! exists $generated_exts_all{$ext} ) - && ($file_time >= $dest_mtime) - ) { - # Only changes since the mtime of the destination matter, - # and only non-generated files count. - # Non-existent destination etc gives $dest_mtime=0 - # so this will automatically give out-of-date condition - # Flag out-of-date for a file by treating it as non-existent - rdb_set_file1( $rule, $file, 0, -1, 0); - } - } - elsif ($file_time >= $$Prun_time ) { - # File generated during run. So treat as non-existent at beginning - rdb_set_file1( $rule, $file, 0, -1, 0); - $$Pout_of_date = 1; - } - # Else default of current state of file is correct. - } # END not previously existent file - } # END file -} # END rdb_update_files_for_rule - -#************************************************************ - sub rdb_set_dependentsA { # Call rdb_set_dependentsA( rules ...) # Returns array (sorted), of new source files. @@ -4622,6 +4602,32 @@ sub rdb_makeB1 { if ($failure & ! $force_mode) {return;} if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; } &rdb_clear_change_record; + + # Special fix up for bibtex: + my $bibtex_not_run = -1; # Flags status as to whether this is a + # bibtex rule and if it is, whether out-of-date condition is to + # be ignored. + # -1 => not a bibtex rule + # 0 => no special treatment + # 1 => don't run bibtex because of non-existent bibfiles + # (and setting to do this test) + # 2 => don't run bibtex because of setting + my @missing_bib_files = (); + if ( $rule =~ /^bibtex/ ) { + $bibtex_not_run = 0; + if ($bibtex_use == 0) { + $bibtex_not_run = 2; + } + elsif ($bibtex_use == 1) { + foreach ( keys %$PHsource ) { + if ( ( /\.bib$/ ) && (! -e $_) ) { + push @missing_bib_files, $_; + $bibtex_not_run = 1; + } + } + } + } + if ( ($$Prun_time == 0) && exists($possible_primaries{$rule}) ) { push @rules_never_run, $rule; $$Pout_of_date = 1; @@ -4675,6 +4681,7 @@ sub rdb_makeB1 { print "$My_name: applying rule '$rule'...\n"; &rdb_diagnose_changes( "Rule '$rule': " ); } + $rules_applied{$rule} = 1; $runs++; @@ -4697,11 +4704,23 @@ sub rdb_makeB1 { return; } $pass{$rule}++; - warn_running( "Run number $pass{$rule} of rule '$rule'" ); - if ($$Pcmd_type eq 'primary' ) { - $return = &rdb_primary_run; + if ($bibtex_not_run > 0) { + if ($bibtex_not_run == 1 ) { + show_array ("$My_name: I WON'T RUN '$rule' because I don't find the following files:", + @missing_bib_files); + } + elsif ($bibtex_not_run == 2 ) { + warn "$My_name: I AM CONFIGURED/INVOKED NOT TO RUN '$rule'\n"; + } + $return = &rdb_dummy_run1; + } + else { + warn_running( "Run number $pass{$rule} of rule '$rule'" ); + if ($$Pcmd_type eq 'primary' ) { + $return = &rdb_primary_run; + } + else { $return = &rdb_run1; } } - else { $return = &rdb_run1; } if ($$Pchanged) { $newrule_nofile = 1; $return = 0; @@ -4950,6 +4969,32 @@ sub rdb_run1 { #----------------- +sub rdb_dummy_run1 { + # Assumes contexts for: rule. + # Update rule state as if the rule ran successfully, + # but don't run the rule. + # Returns 0 (success code) + + # Source file data, by definition, correspond to the file state just before + # the latest run, and the run_time to the time just before the run: + &rdb_update_filesA; + $$Prun_time = time; + $$Pchanged = 0; # No special changes in files + $$Plast_result = 0; + $$Plast_message = ''; + + if ($$Ptest_kind == 3) { + # We are time-criterion first time only. Now switch to + # file-change criterion + $$Ptest_kind = 1; + } + $$Pout_of_date = $$Pout_of_date_user = 0; + + return 0; +} # END rdb_dummy_run1 + +#----------------- + sub rdb_ext_cmd { # Call: rdb_ext_cmd # Assumes rule context. Runs external command with substitutions. -- cgit v1.2.3