You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2010/12/03 22:12:03 UTC

[lucy-commits] svn commit: r1042004 - /incubator/lucy/trunk/perl/buildlib/Lucy/Build.pm

Author: marvin
Date: Fri Dec  3 21:12:02 2010
New Revision: 1042004

URL: http://svn.apache.org/viewvc?rev=1042004&view=rev
Log:
Increase usage of variables to hold filepath components within Build.pm.

Modified:
    incubator/lucy/trunk/perl/buildlib/Lucy/Build.pm

Modified: incubator/lucy/trunk/perl/buildlib/Lucy/Build.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/buildlib/Lucy/Build.pm?rev=1042004&r1=1042003&r2=1042004&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/buildlib/Lucy/Build.pm (original)
+++ incubator/lucy/trunk/perl/buildlib/Lucy/Build.pm Fri Dec  3 21:12:02 2010
@@ -74,9 +74,6 @@ use Carp;
 
 BEGIN { unshift @PATH, curdir() }
 
-sub xs_filepath { catfile( 'lib', "Lucy.xs" ) }
-sub autobind_pm_path { catfile( 'lib', 'Lucy', 'Autobinding.pm' ); }
-
 sub extra_ccflags {
     my $self = shift;
     my $extra_ccflags = defined $ENV{CFLAGS} ? "$ENV{CFLAGS} " : "";
@@ -146,6 +143,9 @@ my $SNOWSTOP_SRC_DIR     = catdir( $base
 my $CORE_SOURCE_DIR      = catdir( $base_dir, 'core' );
 my $AUTOGEN_DIR          = 'autogen';
 my $XS_SOURCE_DIR        = 'xs';
+my $LIB_DIR              = 'lib';
+my $XS_FILEPATH          = catfile( $LIB_DIR, "Lucy.xs" );
+my $AUTOBIND_PM_PATH     = catfile( $LIB_DIR, 'Lucy', 'Autobinding.pm' );
 
 sub new { shift->SUPER::new( recursive_test_files => 1, @_ ) }
 
@@ -238,7 +238,7 @@ sub _compile_clownfish {
     $hierarchy->build;
 
     # Process all __BINDING__ blocks.
-    my $pm_filepaths = $self->rscan_dir( 'lib', qr/\.pm$/ );
+    my $pm_filepaths = $self->rscan_dir( $LIB_DIR, qr/\.pm$/ );
     my @pm_filepaths_with_xs;
     for my $pm_filepath (@$pm_filepaths) {
         open( my $pm_fh, '<', $pm_filepath )
@@ -256,7 +256,7 @@ sub _compile_clownfish {
     my $binding = Clownfish::Binding::Perl->new(
         parcel     => 'Lucy',
         hierarchy  => $hierarchy,
-        lib_dir    => 'lib',
+        lib_dir    => $LIB_DIR,
         boot_class => 'Lucy',
         header     => $self->autogen_header,
         footer     => '',
@@ -272,7 +272,7 @@ sub _write_pod {
     if ( !$binding ) {
         ( undef, $binding ) = $self->_compile_clownfish;
     }
-    my $pod_files = $binding->prepare_pod( lib_dir => 'lib' );
+    my $pod_files = $binding->prepare_pod( lib_dir => $LIB_DIR );
     print "Writing POD...\n";
     while ( my ( $filepath, $pod ) = each %$pod_files ) {
         $self->add_to_cleanup($filepath);
@@ -284,8 +284,7 @@ sub _write_pod {
 }
 
 sub ACTION_clownfish {
-    my $self        = shift;
-    my $xs_filepath = $self->xs_filepath;
+    my $self = shift;
 
     $self->dispatch('charmony');
 
@@ -295,14 +294,14 @@ sub ACTION_clownfish {
     }
     $self->add_to_cleanup($AUTOGEN_DIR);
 
-    my $pm_filepaths  = $self->rscan_dir( 'lib',            qr/\.pm$/ );
+    my $pm_filepaths  = $self->rscan_dir( $LIB_DIR,         qr/\.pm$/ );
     my $cfh_filepaths = $self->rscan_dir( $CORE_SOURCE_DIR, qr/\.cfh$/ );
 
     # Don't bother parsing Clownfish files if everything's up to date.
     return
         if $self->up_to_date(
         [ @$cfh_filepaths, @$pm_filepaths ],
-        [ $xs_filepath,    $AUTOGEN_DIR, ]
+        [ $XS_FILEPATH,    $AUTOGEN_DIR, ]
         );
 
     # Write out all autogenerated files.
@@ -327,13 +326,13 @@ sub ACTION_clownfish {
 
     # Rewrite XS if either any .cfh files or relevant .pm files were modified.
     $modified ||=
-        $self->up_to_date( \@$pm_filepaths_with_xs, $xs_filepath )
+        $self->up_to_date( \@$pm_filepaths_with_xs, $XS_FILEPATH )
         ? 0
         : 1;
 
     if ($modified) {
-        $self->add_to_cleanup($xs_filepath);
-        $self->add_to_cleanup( $self->autobind_pm_path );
+        $self->add_to_cleanup($XS_FILEPATH);
+        $self->add_to_cleanup($AUTOBIND_PM_PATH);
         $perl_binding->write_boot;
         $perl_binding->write_bindings;
         $self->_write_pod($perl_binding);
@@ -343,11 +342,11 @@ sub ACTION_clownfish {
     # and didn't trigger a rewrite, so that we won't have to check them again
     # next pass.
     if (!$self->up_to_date(
-            [ @$cfh_filepaths, @$pm_filepaths_with_xs ], $xs_filepath
+            [ @$cfh_filepaths, @$pm_filepaths_with_xs ], $XS_FILEPATH
         )
         )
     {
-        utime( time, time, $xs_filepath );    # touch
+        utime( time, time, $XS_FILEPATH );    # touch
     }
     if (!$self->up_to_date(
             [ @$cfh_filepaths, @$pm_filepaths_with_xs ], $AUTOGEN_DIR
@@ -474,8 +473,7 @@ sub ACTION_test_valgrind {
 }
 
 sub ACTION_compile_custom_xs {
-    my $self        = shift;
-    my $xs_filepath = $self->xs_filepath;
+    my $self = shift;
 
     $self->dispatch('ppport');
 
@@ -515,11 +513,11 @@ sub ACTION_compile_custom_xs {
     }
 
     # .xs => .c
-    my $perl_binding_c_file = "lib/Lucy.c";
+    my $perl_binding_c_file = catfile( $LIB_DIR, 'Lucy.c' );
     $self->add_to_cleanup($perl_binding_c_file);
-    if ( !$self->up_to_date( $xs_filepath, $perl_binding_c_file ) ) {
+    if ( !$self->up_to_date( $XS_FILEPATH, $perl_binding_c_file ) ) {
         ExtUtils::ParseXS::process_file(
-            filename   => $xs_filepath,
+            filename   => $XS_FILEPATH,
             prototypes => 0,
             output     => $perl_binding_c_file,
         );
@@ -527,7 +525,7 @@ sub ACTION_compile_custom_xs {
 
     # .c => .o
     my $version = $self->dist_version;
-    my $perl_binding_o_file = catfile( 'lib', "Lucy$Config{_o}" );
+    my $perl_binding_o_file = catfile( $LIB_DIR, "Lucy$Config{_o}" );
     unshift @objects, $perl_binding_o_file;
     $self->add_to_cleanup($perl_binding_o_file);
     if ( !$self->up_to_date( $perl_binding_c_file, $perl_binding_o_file ) ) {
@@ -656,7 +654,7 @@ sub _gen_pause_exclusion_list {
         next if $entry =~ m#^(README|Changes)#;
 
         # Allow public modules.
-        if ( $entry =~ m#^lib.+\.(pm|pod)$# ) {
+        if ( $entry =~ m#\blib\b.+\.(pm|pod)$# ) {
             open( my $fh, '<', $entry ) or die "Can't open '$entry': $!";
             my $content = do { local $/; <$fh> };
             next if $content =~ /=head1\s*NAME/;
@@ -670,7 +668,7 @@ sub _gen_pause_exclusion_list {
     if ( eval { require "buildlib/Lucy/Redacted.pm" } ) {
         my @redacted = map {
             my @parts = split( /\W+/, $_ );
-            catfile( 'lib', @parts ) . '.pm'
+            catfile( $LIB_DIR, @parts ) . '.pm'
         } Lucy::Redacted->redacted, Lucy::Redacted->hidden;
         push @excluded_files, @redacted;
     }