summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/latexmk/latexmk.pl
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-08-21 23:50:03 +0000
committerKarl Berry <karl@freefriends.org>2009-08-21 23:50:03 +0000
commit60961ff6e9cd5bde2a7a55e7099330f618ef0b87 (patch)
treea1354572a94e1a8811395d69f276dc14e456085f /Master/texmf-dist/scripts/latexmk/latexmk.pl
parentb9c7ed74e07a19cbedb140faefeaaad448608a41 (diff)
latexmk 4.10 (21aug09)
git-svn-id: svn://tug.org/texlive/trunk@14802 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/latexmk/latexmk.pl')
-rwxr-xr-xMaster/texmf-dist/scripts/latexmk/latexmk.pl311
1 files changed, 147 insertions, 164 deletions
diff --git a/Master/texmf-dist/scripts/latexmk/latexmk.pl b/Master/texmf-dist/scripts/latexmk/latexmk.pl
index 13cf3071512..32db4dfbc95 100755
--- a/Master/texmf-dist/scripts/latexmk/latexmk.pl
+++ b/Master/texmf-dist/scripts/latexmk/latexmk.pl
@@ -16,27 +16,6 @@ use warnings;
# See ?? <===============================
-# Results of 8 Sep 2007:
-
-# Some improvements relative to the issues below.
-
-# ????????:
-# Why is bibtex not always running right? Or running when it shouldn't
-# I've put in rdb_make_links in a few places.
-# and rdb_write
-# Problem is that aux file is always out of date, until after a
-# primary run. Ensure fdb and c. is updated enough etc.
-# I may have it correct now: fdb_write in makeB
-# See also routine rdb_update_files_for_rule, and who calls it
-# It appears to be unused. What is rationale?
-
-# Apparently excess runs of latex after change in .tex file that entails
-# change in bibliography.
-
-## ???!!!!!!!!!!!!! Should I remove bibtex rule? NO
-## ?? Need to set dependence of extra bibtex rules on .bib file
-## ?? Put $pass as variable in rule.
-
## ?? Issues with clean-up
## List of aux files deleted is those read, not those generated.
## Other files are generated by (pdf)latex; should they be deleted?
@@ -46,15 +25,8 @@ use warnings;
#=======================================
-#?? Check all code for rdb stuff.
-#?? Use of $update and $failure, etc
-# Especially in pvc. Should I restore source file set up
-# if there is a latex error??????????????????????
#?? Force mode doesn't appear to do force (if error in latex file)
#??? Get banner back in.
-#?? ==> Clean up of rdb. It accumulates files that aren't in use any more.
-# Restrict to dependents (existent or not) discovered during
-# parse of log file, and its consequences.
#?? CORRECT DIAGNOSTICS ON CHANGED FILES IF THEY DIDN'T EXIST BEFORE
#?? Further corrections to deal with disappeared source files for custom dependencies.
# Message repeatedly appears about remake when source file of cusdep doesn't exist.
@@ -62,11 +34,7 @@ use warnings;
# Reconsider
#?? Do proper run-stuff for bibtex, makeindex, cus-deps. OK I think
# Parse and correctly find bst and ist files
-#?? Remove superfluous code when it's working. Mostly done.
-#?? update_source_times in particular. I think it's done OK
-#?? Add making of other files to rdb. Unify
-#?? Ditto for printing and viewing?
-#?? Update documentation
+
# ATTEMPT TO ALLOW FILENAMES WITH SPACES:
# (as of 1 Apr 2006, and then 14 Sep. 2007)
@@ -132,7 +100,6 @@ use warnings;
# Rationalize again handling of include files.
# Now I use kpsewhich to do searches, if file not found
# (How do I avoid getting slowed down too much?)
-# Better parsing of log file for includes.
# Document the assumptions at each stage of processing algorithm.
# Option to restart previewer automatically, if it dies under -pvc
# Test for already running previewer gets wrong answer if another
@@ -140,8 +107,8 @@ use warnings;
$my_name = 'latexmk';
$My_name = 'Latexmk';
-$version_num = '4.08';
-$version_details = "$My_name, John Collins, 23 June 2009";
+$version_num = '4.10';
+$version_details = "$My_name, John Collins, 21 August 2009";
use Config;
@@ -174,7 +141,7 @@ else {
warn "Something wrong with the perl configuration: No signals?\n";
}
-## Copyright John Collins 1998-2008
+## Copyright John Collins 1998-2009
## (username collins at node phys.psu.edu)
## (and thanks to David Coppit (username david at node coppit.org)
## for suggestions)
@@ -208,107 +175,12 @@ else {
## 5. Parsing of log file instead of source file is used to
## obtain dependencies, by default.
##
-## Modification log for 24 Sep 2008 onwards in detail
+## Modification log from 21 Aug 2009 onwards in detail
##
-## 22 Jun 2009, John Collins Binmode for log file under MSWin
-## to avoid problem with ctrl/Z written
-## by Miktex 2.7 giving spurious end-of-file
-## 10 Jun 2009, John Collins V. 4.08
-## 27 May 2009, John Collins V. 4.07
-## 23 May 2009, John Collins Try to work rationally when run of
-## (pdf)latex does not produce
-## output.
-## Diagonostic when latex makes pdf or
-## pdflatex makes dvi.
-## 28 Apr 2009, John Collins Deal with case that file is written
-## during run, but is not in database
-## before run.
-## 17 Apr 2009, John Collins V. 4.06
-## 14 Apr 2009, John Collins In parse_logB, clean up a bit more
-## aggressively non-existent source files
-## 11 Apr 2009, John Collins Capture ctrl/C and ctrl/break during wait
-## loop in preview_continuous. Then
-## control stays within latexmk on break
-## from loop. It allows user to do
-## postprocessing, like
-## "latexmk -pvc file; cleanup;"
-## 10 Apr 2009, John Collins Safer use of % in placeholders in commands
-## 10 Apr 2009, John Collins V. 4.05
-## 3 Apr 2009, John Collins Change to a nicer #! line
-## 26 Mar 2009, John Collins Case independence for one item in
-## @file_not_found
-## 6 Mar 2009, John Collins Single %input_extensions variable
-## Correct bug in making cusdep for missing
-## extensionless file
-## 5 Mar 2009, John Collins Get rid of warning about variables used
-## only once.
-## 25 Feb 2009, John Collins Ensure viewed file type is made.
-## Configurable extensions for finding
-## cusdep.
-## 24 Feb 2009, John Collins V. 4.04
-## Fix problems when using both latex and pdflatex
-## 1. In fdb, keep primary rules that have been
-## run, even if they are not in use in
-## current invocation of latexmk.
-## 2. But don't write primary rules if they have
-## not been run (i.e., $run_time==0).
-## 3. If $run_time==0 for an in-use primary
-## rule, i.e., if the rule has not
-## been run, then run it
-## unconditionally.
-## 4. But don't let this apply to other
-## rules, since the time-stamp rule
-## will normally have been adequate.
-## Improved diagnostics on reason for rerun.
-## Corrected classify_rules call in pvc.
-## In rdb_set_from_logB: when setting
-## subsidiary rules after parsing log
-## file, this is now done only for the
-## currently-being-applied primary rule,
-## not for all primary rules.
-## 22 Dec 2008, John Collins V. 4.03
-## 22 Dec 2008, John Collins Fix possibility that unwrapping of lines
-## in log_file is done incorrectly
-## 5 Dec 2008, John Collins Correct treatment of -e option
-## 2 Dec 2008, John Collins For home directory (where user's .latexmkrc
-## is located, when $ENV{'HOME'} does
-## not exist, use $ENV{USERPROFILE}
-## (suitable for MS-Win).
-## Clean up code in rdb_set_rules
-## 1 Dec 2008, John Collins -c and -C now also delete fdb_latex file
-## 26 Nov 2008, John Collins Correct problem with invocation of MSWin
-## with cygwin
-## 25 Nov 2008, John Collins Correct problem with invocation of MSWin
-## start command
-## 15 Nov 2008, John Collins Make version # 4.02, for release
-## 12 Nov 2008, John Collins Deal with quoted filenames in log file
-## (as with MikTeX)
-## 10 Nov 2008, John Collins Start fixing bug about -ps -pdfps
-## running ps2pdf before dvips
-## 30 Sep 2008, John Collins V. 4.01a
-## Correct problem that aux files not of
-## same basename are not deleted on clean-up
-## Primary problem: fdb file was deleted before
-## being read
-## ?? Remaining issues on this:
-## List of aux files deleted is those read,
-## not those generated
-## Other files are generated by (pdf)latex
-## should they be deleted?
-## Solution of problem that if a source file
-## for (pdf)latex disappears, that is treated
-## as a change requiring a rerun. This gives
-## an infinite loop of unnecessary runs in
-## -pvc mode
-## Cleanup can also apply to all files
-## generated during (pdf)latex run,
-## as diagnosed by \openout lines,
-## and also to files generated from
-## these. Controlling variable
-## $cleanup_includes_generated.
-## 24 Sep 2008, John Collins Release version 4.01.
+## 21 Aug 2009, John Collins V. 4.10 for CTAN release.
##
-## 1998-2008, John Collins. Many improvements and fixes.
+## 1998-2009, John Collins. Many improvements and fixes.
+## See CHANGE-log.txt for full list, and CHANGES for summary
##
## Modified by Evan McLean (no longer available for support)
## Original script (RCS version 2.3) called "go" written by David J. Musliner
@@ -404,6 +276,7 @@ else {
#Line length in log file that indicates wrapping.
# This number EXCLUDES line-end characters, and is one-based
+# It is the parameter max_print_line in the TeX program. (tex.web)
$log_wrap = 79;
#########################################################################
@@ -423,6 +296,7 @@ $log_wrap = 79;
'.*?:\\d*: LaTeX Error: File `([^\\\']*)\\\' not found\\.',
'^LaTeX Warning: File `([^\\\']*)\\\' not found',
'^Package .* [fF]ile `([^\\\']*)\\\' not found',
+ 'Error: pdflatex \(file ([^\)]*)\): cannot find image file',
);
## Hash mapping file extension (w/o period, e.g., 'eps') to a single regexp,
@@ -1146,7 +1020,7 @@ if (!$TEXINPUTS) { $TEXINPUTS = '.'; }
# last_result, last_message
# ]
# where
- # cmd_type is 'primary', 'external' or 'cusdep',
+ # cmd_type is 'primary', 'external', or 'cusdep'
# ext_cmd is string for associated external command
# with substitutions (%D for destination, %S
# for source, %B for base of current rule,
@@ -1688,6 +1562,9 @@ foreach $filename ( @file_list )
local %idx_files = (); # Maps idx_file to (ind_file, base)
local %generated_log = (); # Lists generated files
local $primary_out = ''; # Actual output file (dvi or pdf)
+ local %conversions = (); # (pdf)latex-performed conversions.
+ # Maps output file created and read by (pdf)latex
+ # to source file of conversion.
print "$My_name: Examining log file for generated files...\n";
&parse_logB;
@@ -2420,7 +2297,9 @@ CHANGE:
"------------\n";
}
}
- local $retcode = rdb_makeB ( 'view' );
+ local $retcode = 0;
+ rdb_one_rule( 'view', sub { $retcode = &rdb_run1;} );
+# PREVIOUS local $retcode = rdb_makeB ( 'view' );
if ( $retcode != 0 ) {
if ($force_mode) {
warn "$My_name: I could not run previewer\n";
@@ -2824,10 +2703,14 @@ sub parse_logB {
# Should be LaTeX file that exists.
# If it doesn't exist, we have probably a mis-parsed line.
# There's no need to do a search.
-# 4 = definitive, which in this subroutine is only
-# done for default dependents
+# 4 = definitive, which in this subroutine is only done:
+# for default dependents,
+# and for files that exist and are source of conversion
+# reported by epstopdf et al.
# 5 = Had a missing file line. Now the file exists.
# 6 = File was written during run. (Overrides 5)
+# 7 = File was created during run to be read in. (Overrides 5 and 6)
+# (e.g., by epstopdf)
# Treat the following specially, since they have special rules
# @bbl_files to list of .bbl files.
# %idx_files to map from .idx files to .ind files.
@@ -2854,6 +2737,7 @@ sub parse_logB {
@bbl_files = ();
%idx_files = (); # Maps idx_file to (ind_file, base)
%generated_log = ();
+ %conversions = ();
# $primary_out is actual output file (dvi or pdf)
# It is initialized before the call to this routine, to ensure
# a sensible default in case of misparsing
@@ -2876,11 +2760,39 @@ sub parse_logB {
# used by perl. (Notably a problem with MSWin latex and
# cygwin perl!)
s/[\n\r]*$//;
+ # Handle wrapped lines:
+ # They are lines brutally broken at exactly $log_wrap chars
+ # excluding line-end. The TeX program adds an EXTRA
+ # end-of-line character whenever a line gets to $log_wrap
+ # characters. So we recover the unwrapped line(s) simply
+ # by deleting the end-of-line following a line of exactly
+ # $log_wrap characters.
+ my $len = length($_);
+ while ( ($len == $log_wrap) && !eof($log_file) ) {
+ my $extra = <$log_file>;
+ $extra =~ s/[\n\r]*$//;
+ $len = length($extra);
+ $_ .= $extra;
+ }
push @lines, $_;
}
close $log_file;
+
+ push @lines, ""; # Blank line to terminate. So multiline blocks
+ # are always terminated by non-block line, rather than eof.
my $line = 0;
+ # For parsing multiple line blocks of info
+ my $current_pkg = ""; # non-empty string for package name, if in
+ # middle of parsing multi-line block of form:
+ # Package name ....
+ # (name) ...
+ # ...
+ my $block_type = ""; # Specify information in such a block
+ my $delegated_source = ""; # If it is a file conversion, specify source
+ my $delegated_output = ""; # and output file. (Don't put in
+ # data structure until block is ended.)
+ my @converted_pairs = ();
LINE:
while( $line <= $#lines ) {
$_ = $lines[$line];
@@ -2897,22 +2809,26 @@ LINE:
return 0;
}
}
- # Handle wrapped lines:
- # They are lines brutally broken at exactly $log_wrap chars
- # excluding line-end.
- # But a line can be of the length where the wrapping occurs, but
- # there can be no wrapping. So for a long line, try parsing it
- # as if it is wrapped, but leave the index variable $line as is,
- # so that on the next loop over LINE, we also try parsing the
- # succeeding line as if there was no wrapping:
- my $len = length($_);
- my $next = $line;
- while ( ($len == $log_wrap) && ($next <= $#lines) ) {
- my $extra = $lines[$next];
- $next++;
- $len = length($extra);
- $_ .= $extra;
- }
+ if ( $block_type ) {
+ # In middle of parsing block
+ if ( /^\($current_pkg\)/ ) {
+ # Block continues
+ if ( ($block_type eq 'conversion')
+ && /^\($current_pkg\)\s+Output file: <([^>]+)>/ )
+ {
+ $delegated_output = $1;
+ }
+ next LINE;
+ }
+ # Block has ended.
+ if ($block_type eq 'conversion') {
+ push @converted_pairs,
+ [ $delegated_source, $delegated_output ];
+ }
+ $current_pkg = $block_type
+ = $delegated_source = $delegated_output = "";
+ # Then process current line
+ }
# Check for changed references, bad references and bad citations:
if (/Rerun to get/) {
warn "$My_name: References changed.\n";
@@ -2957,6 +2873,15 @@ LINE:
$generated_log{$1} = 1;
next LINE;
}
+ # Test for conversion produced by package:
+ if ( /^Package (\S+) Info: Source file: <([^>]+)>/ ) {
+ # Info. produced by epstopdf (and possibly others)
+ # about file conversion
+ $current_pkg = $1;
+ $delegated_source = $2;
+ $block_type = 'conversion';
+ next LINE;
+ }
# Test for writing of index file. The precise format of the message
# depends on which package (makeidx.sty , multind.sty or index.sty) and
# which version writes the message.
@@ -3227,12 +3152,46 @@ CANDIDATE:
my ($base, $path, $ext) = fileparseA($candidate);
$ext =~ s/^\.//;
if ( ($ext eq '') && (-e "$path$base.tex") ) {
- $dependents{"$path$base.tex"} = 4;
- delete $dependents{$candidate};
+ # I don't think the old version was correct.
+ # If the missing-file report was of a bare
+ # extensionless file, and a corresponding .tex file
+ # exists, then the missing file does not correspond
+ # to the missing file, unless the .tex file was
+ # created during the run.
+ # OLD $dependents{"$path$base.tex"} = 4;
+ # OLD delete $dependents{$candidate};
+ # NEW:
+ $dependents{"$path$base.tex"} = 4;
}
push @missing, $candidate;
}
}
+CANDIDATE_PAIR:
+ foreach $_ (@converted_pairs) {
+ my ($delegated_source, $delegated_output) = @$_;
+ my $rule = "Delegated $delegated_source, $delegated_output";
+ # N.B. $delegated_source eq '' means the output file
+ # was created without a named input file.
+ if ( ( (-e $delegated_source) || ($delegated_source eq '') )
+ && (-e $delegated_output) )
+ {
+ $conversions{$delegated_output} = $delegated_source;
+ $dependents{$delegated_output} = 7;
+ if ($delegated_source) {
+ $dependents{$delegated_source} = 4;
+ }
+ }
+ else {
+ print "Logfile claimed conversion from '$delegated_source' ",
+ "to '$delegated_output'. But:\n";
+ if (! -e $delegated_output) {
+ print " Output file does not exist\n";
+ }
+ if ( ($delegated_source ne '') && (! -e $delegated_output) ) {
+ print " Input file does not exist\n";
+ }
+ }
+ }
if ( $diagnostics ) {
@@ -3256,6 +3215,8 @@ CANDIDATE:
print " '$_' ";
if ( $dependents{$_} == 6 ) { print " written by (pdf)latex";}
print "\n";
+ if ( $dependents{$_} == 7 ) { print " converted by (pdf)latex";}
+ print "\n";
}
if ($not_found > 0) {
print "Not found:\n";
@@ -3747,7 +3708,9 @@ sub rdb_set_from_logB {
local %idx_files = (); # Maps idx_file to (ind_file, base)
local %generated_log = (); # Lists generated files found in log file
local $primary_out = $$Pdest; # output file (dvi or pdf)
-
+ local %conversions = (); # (pdf)latex-performed conversions.
+ # Maps output file created and read by (pdf)latex
+ # to source file of conversion.
# The following are also returned, but are global, to be used by caller
# $reference_changed, $bad_reference $bad_citation
@@ -3826,7 +3789,7 @@ sub rdb_set_from_logB {
}
NEW_SOURCE:
- foreach my $new_source (keys %dependents) {
+ foreach my $new_source (keys %dependents, keys %conversions) {
print " ===Source file for rule '$rule': '$new_source'\n"
if ($diagnostics);
if ( ($dependents{$new_source} == 5)
@@ -3843,9 +3806,23 @@ NEW_SOURCE:
# treated as non-existent, to ensure another run is forced.
rdb_ensure_file( $rule, $new_source, undef, 1 );
}
+ elsif ( $dependents{$new_source} == 7 ) {
+ # File was result of conversion by (pdf)latex.
+ my $cnv_source = $conversions{$new_source};
+ rdb_ensure_file( $rule, $new_source );
+ if ($cnv_source) {
+ # Conversion from $cnv_source to $new_source
+ # implies that effectively $cnv_source is a source
+ # of the (pdf)latex run.
+ rdb_ensure_file( $rule, $cnv_source );
+ }
+ # Flag that changes of the generated file during a run
+ # do not require a rerun:
+ rdb_one_file( $new_source, sub{ $$Pcorrect_after_primary = 1; } );
+ }
else {
- # But we don't need this precaution for ordinary user files (or
- # for files that are generated outside of latex/pdflatex).
+ # But we don't need special precautions for ordinary user files
+ # (or for files that are generated outside of latex/pdflatex).
rdb_ensure_file( $rule, $new_source );
}
}
@@ -4036,7 +4013,10 @@ sub rdb_set_dependentsA {
# Returns array (sorted), of new source files.
local @new_sources = ();
local @deletions = ();
- rdb_recurseA( [@_], 0, \&rdb_one_depA );
+
+# Shouldn't recurse. The definite rules to be examined are given.
+ rdb_for_some( [@_], 0, \&rdb_one_depA );
+# OLD rdb_recurseA( [@_], 0, \&rdb_one_depA );
foreach (@deletions) {
my ($rule, $file) = @$_;
rdb_remove_files( $rule, $file );
@@ -4520,6 +4500,9 @@ sub rdb_makeB1 {
if ( ( $$Pcmd_type eq 'cusdep') && $$Psource && (! -e $$Psource) ) {
# No action
}
+ elsif ( $$Pcmd_type eq 'delegated' ) {
+ # Delegate to destination rule
+ }
elsif ( $pass{$rule}==0) {
push @no_dest, $$Pdest;
$$Pout_of_date = 1;
@@ -4891,7 +4874,7 @@ sub rdb_primary_run {
# For each file of the kind made by epstopdf.sty during a run,
# if the file has changed during a run, then the new version of
# the file will have been read during the run. Unlike the usual
- # case, we will need to redo the primary run because of the
+ # case, we will NOT need to redo the primary run because of the
# change of this file during the run. Therefore set the file as
# up-to-date:
rdb_do_files( sub { if ($$Pcorrect_after_primary) {&rdb_update1;} } );