This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
mktables: Regenerate if called with different cmd line args
authorKarl Williamson <public@khwilliamson.com>
Sun, 20 Oct 2013 16:20:13 +0000 (10:20 -0600)
committerKarl Williamson <public@khwilliamson.com>
Tue, 31 Dec 2013 15:27:15 +0000 (08:27 -0700)
mktables acts pretty much like its own Makefile.  This is because the
rules for regenerating are complicated and too hard to keep in sync in a
Makefile with new versions of Unicode.  mktables itself already has
enough intelligence to automatically update the rules when it gets
modified to account for new files from Unicode.

However, prior to this commit, it didn't keep track of the options it
was called with, thus it wouldn't necessarily run when those options
changed to affect the desired outputs.

lib/unicore/mktables

index 959bfa6..0781267 100644 (file)
@@ -679,6 +679,11 @@ my $VERBOSE = 3;
 
 my $verbosity = $NORMAL_VERBOSITY;
 
+# Stored in mktables.lst so that if this program is called with different
+# options, will regenerate even if the files otherwise look like they're
+# up-to-date.
+my $command_line_arguments = join " ", @ARGV;
+
 # Process arguments
 while (@ARGV) {
     my $arg = shift @ARGV;
@@ -17810,6 +17815,7 @@ File::Find::find({
 
 my @mktables_list_output_files;
 my $old_start_time = 0;
+my $old_options = "";
 
 if (! -e $file_list) {
     print "'$file_list' doesn't exist, so forcing rebuild.\n" if $verbosity >= $VERBOSE;
@@ -17836,6 +17842,10 @@ else {
                     $old_start_time = $1;
                     next;
                 }
+                if (/^ \s* \# \s* From\ options\ (.+) /x) {
+                    $old_options = $1;
+                    next;
+                }
                 next if /^ \s* (?: \# .* )? $/x;
                 last if /^ =+ $/x;
                 my ( $file ) = split /\t/;
@@ -17967,7 +17977,9 @@ foreach my $in (@input_files) {
 
 my $rebuild = $write_unchanged_files    # Rebuild: if unconditional rebuild
               || ! scalar @mktables_list_output_files  # or if no outputs known
-              || $old_start_time < $most_recent;       # or out-of-date
+              || $old_start_time < $most_recent        # or out-of-date
+              || $old_options ne $command_line_arguments; # or with different
+                                                          # options
 
 # Now we check to see if any output files are older than youngest, if
 # they are, we need to continue on, otherwise we can presumably bail.
@@ -18038,6 +18050,7 @@ if ( $file_list and $make_list ) {
 # $file_list -- File list for $0.
 #
 #   Autogenerated starting on $start_time ($localtime)
+#   From options $command_line_arguments
 #
 # - First section is input files
 #   ($0 itself is not listed but is automatically considered an input)