lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r692617 - /lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm
Date Sat, 06 Sep 2008 06:41:27 GMT
Author: marvin
Date: Fri Sep  5 23:41:26 2008
New Revision: 692617

URL: http://svn.apache.org/viewvc?rev=692617&view=rev
Log:
Replace private method _find_files() with override of public Module::Build
method rscan_dir().

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

Modified: lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm?rev=692617&r1=692616&r2=692617&view=diff
==============================================================================
--- lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm (original)
+++ lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm Fri Sep  5 23:41:26 2008
@@ -90,7 +90,7 @@
     if ( !-d $FILTERED_DIR ) {
         mkpath($FILTERED_DIR) or die "can't mkpath '$FILTERED_DIR': $!";
     }
-    my $charm_source_files = $self->_find_files( $CHARMONIZER_SOURCE_DIR,
+    my $charm_source_files = $self->rscan_dir( $CHARMONIZER_SOURCE_DIR,
         sub { $File::Find::name =~ /\.c?harm$/ } );
     my $filtered_files = $self->_metaquote_charm_files($charm_source_files);
     my $charmonize_c   = catfile( $base_dir, qw( charmonizer charmonize.c ) );
@@ -128,22 +128,6 @@
         $CHARMONIZE_EXE_PATH, );
 }
 
-sub _find_files {
-    my ( $self, $dir, $test_sub ) = @_;
-    my @files;
-    find(
-        {   wanted => sub {
-                if ( $test_sub->() and $File::Find::name !~ /\.\.?$/ ) {
-                    push @files, $File::Find::name;
-                }
-            },
-            no_chdir => 1,
-        },
-        $dir,
-    );
-    return \@files;
-}
-
 sub _metaquote_charm_files {
     my ( $self, $charm_files ) = @_;
     my @filtered_files;
@@ -217,7 +201,7 @@
     my $source_path     = catfile( $base_dir, 'charmonizer', 'charm_test.c' );
     my $exe_path        = "charm_test$Config{_exe}";
     my $test_source_dir = catdir( $FILTERED_DIR, qw( Charmonizer Test ) );
-    my $source_files    = $self->_find_files( $FILTERED_DIR,
+    my $source_files    = $self->rscan_dir( $FILTERED_DIR,
         sub { $File::Find::name =~ m#Charmonizer/Test.*?\.c$# } );
     push @$source_files, $source_path;
 
@@ -228,7 +212,7 @@
     if ( $Config{osname} =~ /mswin/i ) {
         my $win_compat_dir = catdir( $base_dir, 'c_src', 'compat' );
         push @include_dirs, $win_compat_dir;
-        my $win_compat_files = $self->_find_files( $win_compat_dir,
+        my $win_compat_files = $self->rscan_dir( $win_compat_dir,
             sub { $File::Find::name =~ m#\.c$# } );
         push @$source_files, @$win_compat_files;
     }
@@ -261,6 +245,27 @@
     $self->SUPER::ACTION_code(@_);
 }
 
+# copied from Module::Build::Base.pm, added exclude '#' and follow symlinks
+sub rscan_dir {
+    my ( $self, $dir, $pattern ) = @_;
+    my @result;
+    local $_;    # find() can overwrite $_, so protect ourselves
+    my $subr
+        = !$pattern ? sub { push @result, $File::Find::name }
+        : !ref($pattern)
+        || ( ref $pattern eq 'Regexp' )
+        ? sub { push @result, $File::Find::name if /$pattern/ }
+        : ref($pattern) eq 'CODE'
+        ? sub { push @result, $File::Find::name if $pattern->() }
+        : die "Unknown pattern type";
+
+    File::Find::find( { wanted => $subr, no_chdir => 1, follow => 1 }, $dir );
+
+    # skip emacs lock files
+    my @filtered = grep !/#/, @result;
+    return \@filtered;
+}
+
 1;
 
 __END__



Mime
View raw message