On Sat Nov 11 12:04:20 2006, particle wrote:
> we need ... some config hackery to do it during
> configure-time.
> 
> this would replace the MANIFEST.generated file which is created ex
> post facto with a file that is created at build-time.
> 

Herewith some configure-time hackery.  This patch provides a new
compilation utility subroutine,
Parrot::Configure::Utils::append_configure_log(), which appends the name
of a file about to be created to a file called MANIFEST.configure.generated.

Where files (other than test.c files within auto::* config step classes)
are created by Parrot::Configure::Compiler::cc_gen(),
append_configure_log() is called internally.  This is the case for 59 of
the 97 files currently created during compilation.  The new function is
called explicitly in the remaining cases.

This cannot yet replace MANIFEST.generated because we still need that
build-time hackery.  But it should do no harm, and it gets us part way
there.  Please review.  I'll apply next week if there are no objections.

Thank you very much.
kid51


Index: lib/Parrot/Configure/Compiler.pm
===================================================================
--- lib/Parrot/Configure/Compiler.pm    (revision 26514)
+++ lib/Parrot/Configure/Compiler.pm    (working copy)
@@ -32,6 +32,7 @@
     capture_output check_progs _slurp
     _run_command _build_compile_command
     move_if_diff
+    append_configure_log
 );
 
 =item C<cc_gen()>
@@ -258,6 +259,11 @@
     my $conf = shift;
     my ( $source, $target, %options ) = @_;
 
+    my @caller_values = caller(1);
+    if ( $caller_values[3] !~ /cc_gen$/ ) {
+        append_configure_log($target);
+    }
+
     open my $in,  '<', $source       or die "Can't open $source: $!";
     open my $out, '>', "$target.tmp" or die "Can't open $target.tmp: $!";
 
@@ -303,7 +309,9 @@
 
             # OUT was/is used at the output filehandle in eval'ed scripts
             # e.g. feature.pl or feature_h.in
+            no warnings 'once';
             local *OUT = $out;
+            use warnings;
             my $text = do { local $/; <$in> };
 
             # interpolate @foo@ values
Index: lib/Parrot/Configure/Utils.pm
===================================================================
--- lib/Parrot/Configure/Utils.pm       (revision 26514)
+++ lib/Parrot/Configure/Utils.pm       (working copy)
@@ -38,13 +38,14 @@
     prompt copy_if_diff move_if_diff integrate
     capture_output check_progs _slurp
     _run_command _build_compile_command
+    append_configure_log
 );
 our %EXPORT_TAGS = (
     inter => [qw(prompt integrate)],
     auto  => [
         qw(capture_output check_progs)
     ],
-    gen => [qw(copy_if_diff move_if_diff)]
+    gen => [qw(copy_if_diff move_if_diff append_configure_log)]
 );
 
 =item C<_run_command($command, $out, $err)>
@@ -311,6 +312,17 @@
 
 =back
 
+=cut
+
+sub append_configure_log {
+    my $target = shift;
+    my $generated_log = q{MANIFEST.configure.generated};
+    open my $GEN, '>>', $generated_log
+        or die "Can't open $generated_log for appending: $!";
+    print $GEN qq{$target\n};
+    close $GEN or die "Can't close $generated_log after appending: $!";
+}
+
 =head1 SEE ALSO
 
 =over 4
Index: config/init/manifest.pm
===================================================================
--- config/init/manifest.pm     (revision 26514)
+++ config/init/manifest.pm     (working copy)
@@ -19,6 +19,7 @@
 use base qw(Parrot::Configure::Step);
 
 use Parrot::Configure::Step;
+use Parrot::Configure::Utils ':gen';
 use ExtUtils::Manifest qw(manicheck);
 
 
@@ -33,6 +34,7 @@
 sub runstep {
     my ( $self, $conf ) = @_;
 
+    append_configure_log('MANIFEST.configure.generated');
     if ( $conf->options->get('nomanicheck') ) {
         $self->set_result('skipped');
         return 1;
Index: config/gen/platform.pm
===================================================================
--- config/gen/platform.pm      (revision 26514)
+++ config/gen/platform.pm      (working copy)
@@ -19,7 +19,7 @@
 
 use base qw(Parrot::Configure::Step);
 
-use Parrot::Configure::Utils qw(copy_if_diff);
+use Parrot::Configure::Utils ':gen';
 
 sub _init {
     my $self = shift;
@@ -74,8 +74,10 @@
         string.h
         /;
 
-    open my $PLATFORM_H, ">", "include/parrot/platform.h"
-        or die "Can't open include/parrot/platform.h: $!";
+    my $plat_h = q{include/parrot/platform.h};
+    append_configure_log($plat_h);
+    open my $PLATFORM_H, ">", $plat_h
+        or die "Can't open $plat_h: $!";
 
     print {$PLATFORM_H} <<"END_HERE";
 /* ex: set ro:
@@ -176,8 +178,10 @@
         misc.c
         /;
 
-    open my $PLATFORM_C, ">", "src/platform.c"
-        or die "Can't open src/platform.c: $!";
+    my $plat_c = q{src/platform.c};
+    append_configure_log($plat_c);
+    open my $PLATFORM_C, ">", $plat_c
+        or die "Can't open $plat_c: $!";
 
     print {$PLATFORM_C} <<"END_HERE";
 /*
Index: config/gen/makefiles/root.in
===================================================================
--- config/gen/makefiles/root.in        (revision 26514)
+++ config/gen/makefiles/root.in        (working copy)
@@ -225,7 +225,8 @@
     $(GEN_MAKEFILES) \
     ext/Parrot-Embed/Makefile.PL \
     myconfig  \
-    $(GEN_PASM_INCLUDES)
+    $(GEN_PASM_INCLUDES) \
+    MANIFEST.configure.generated
 
 
 ###############################################################################
Index: config/gen/core_pmcs.pm
===================================================================
--- config/gen/core_pmcs.pm     (revision 26514)
+++ config/gen/core_pmcs.pm     (working copy)
@@ -43,6 +43,7 @@
     my ( $self, $conf ) = @_;
 
     my $file = "include/parrot/core_pmcs.h";
+    append_configure_log($file);
     open( my $OUT, ">", "$file.tmp" );
 
     print {$OUT} <<"END_H";
@@ -95,6 +96,7 @@
     my $file = "src/core_pmcs.c";
     my @pmcs = split( / /, $conf->data->get('pmc_names') );
 
+    append_configure_log($file);
     open( my $OUT, ">", "$file.tmp" );
 
     print {$OUT} <<"END_C";
@@ -180,6 +182,7 @@
     my $file = "lib/Parrot/PMC.pm";
     my @pmcs = split( / /, $conf->data->get('pmc_names') );
 
+    append_configure_log($file);
     open( my $OUT, ">", "$file.tmp" );
 
     print $OUT <<'END_PM';
Index: config/gen/parrot_include.pm
===================================================================
--- config/gen/parrot_include.pm        (revision 26514)
+++ config/gen/parrot_include.pm        (working copy)
@@ -158,6 +158,7 @@
                 $conf->options->get('verbose') and print "$target ";
                 my $gen = join "\n",
                     ( $target =~ /\.pl$/ ? \&const_to_perl : \&const_to_parrot 
)->(@defs);
+                append_configure_log($target);
                 my $target_tmp = "$target.tmp";
                 open my $out, '>', $target_tmp or die "Can't open $target_tmp: 
$!\n";
 
Index: config/gen/config_h.pm
===================================================================
--- config/gen/config_h.pm      (revision 26514)
+++ config/gen/config_h.pm      (working copy)
@@ -48,6 +48,7 @@
     );
 
     my $hh = "include/parrot/has_header.h";
+    append_configure_log($hh);
     open( my $HH, ">", "$hh.tmp" )
         or die "Can't open has_header.h: $!";
 
Index: config/gen/makefiles.pm
===================================================================
--- config/gen/makefiles.pm     (revision 26514)
+++ config/gen/makefiles.pm     (working copy)
@@ -76,6 +76,8 @@
     my ( $self, $conf ) = @_;
 
     $self->makefiles($conf);
+    append_configure_log('docs/Makefile');
+    append_configure_log('CFLAGS');
     $self->cflags($conf);
 
     return 1;
Index: config/gen/config_pm.pm
===================================================================
--- config/gen/config_pm.pm     (revision 26514)
+++ config/gen/config_pm.pm     (working copy)
@@ -19,6 +19,7 @@
 use warnings;
 
 use base qw(Parrot::Configure::Step);
+use Parrot::Configure::Utils ':gen';
 
 use Cwd qw(cwd);
 use File::Spec::Functions qw(catdir);
@@ -46,8 +47,10 @@
         mkdir $configdir
             or die "Can't create dir $configdir: $!";
     }
-    open( my $OUT, ">", "lib/Parrot/Config/Generated.pm" )
-        or die "Can't open lib/Parrot/Config/Generated.pm: $!";
+    my $gen_pm = q{lib/Parrot/Config/Generated.pm};
+    append_configure_log($gen_pm);
+    open( my $OUT, ">", $gen_pm )
+        or die "Can't open $gen_pm: $!";
 
     print {$OUT} "# Generated by config/gen/config_pm.pm\n";
 
@@ -62,7 +65,9 @@
 
     my $template = "config/gen/config_pm/config_lib.in";
     open( $IN,  "<", $template )         or die "Can't open '$template': $!";
-    open( $OUT, ">", "config_lib.pasm" ) or die "Can't open config_lib.pasm: 
$!";
+    my $c_l_pasm = q{config_lib.pasm};
+    append_configure_log($c_l_pasm);
+    open( $OUT, ">", $c_l_pasm ) or die "Can't open $c_l_pasm: $!";
 
     print {$OUT} <<"END";
 # Generated by config/gen/config_pm.pm from the template
@@ -95,7 +100,7 @@
     }
 
     close $IN  or die "Can't close config_lib.in: $!";
-    close $OUT or die "Can't close config_lib.pasm: $!";
+    close $OUT or die "Can't close $c_l_pasm: $!";
 
     return 1;
 }

Reply via email to