lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r465363 - in /lucene/lucy/trunk/perl: Build.PL MANIFEST MANIFEST.SKIP META.yml Makefile.PL buildlib/ buildlib/Lucy/ buildlib/Lucy/Build.pm
Date Wed, 18 Oct 2006 20:33:34 GMT
Author: marvin
Date: Wed Oct 18 13:33:33 2006
New Revision: 465363

URL: http://svn.apache.org/viewvc?view=rev&rev=465363
Log:
Adapt Build.PL to new directory layout.  Add perl/buildlib/Lucy/Build.pm, and
take the subclassing code which was previously hard-coded as a string within
Build.PL and put it into a proper module. Add files that are expected to be
present in a CPAN distribution -- META.yml, MANIFEST, etc.

Added:
    lucene/lucy/trunk/perl/MANIFEST
    lucene/lucy/trunk/perl/MANIFEST.SKIP
    lucene/lucy/trunk/perl/META.yml
    lucene/lucy/trunk/perl/Makefile.PL
    lucene/lucy/trunk/perl/buildlib/
    lucene/lucy/trunk/perl/buildlib/Lucy/
    lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm
Modified:
    lucene/lucy/trunk/perl/Build.PL

Modified: lucene/lucy/trunk/perl/Build.PL
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/Build.PL?view=diff&rev=465363&r1=465362&r2=465363
==============================================================================
--- lucene/lucy/trunk/perl/Build.PL (original)
+++ lucene/lucy/trunk/perl/Build.PL Wed Oct 18 13:33:33 2006
@@ -2,191 +2,30 @@
 use strict;
 use warnings;
 
-use Module::Build;
+use lib 'buildlib';
+use Lucy::Build;
+use File::Spec::Functions qw( catdir updir );
 
-my $subclass_code = <<'END_BUILD_CLASS';
 
-package Lucy::Build;
-use strict;
-use warnings;
-use base qw( Module::Build );
-
-use File::Spec::Functions qw( catdir catfile splitpath );
-use File::Path qw( mkpath );
-use File::Find qw( find );
-use ExtUtils::CBuilder;
-use Config;
-
-my $METAQUOTE_EXE_PATH     = 'metaquote';
-my $CHARMONIZE_EXE_PATH    = 'charmonize';
-my $CHARMONIZER_SOURCE_DIR = catdir(qw( charmonizer src ));
-
-my $EXTRA_CCFLAGS
-    = $ENV{DEBUG_CHARM} ? " -ansi -pedantic -Wall -Wextra -std=c89 " : "";
-my $VALGRIND = $ENV{CHARM_VALGRIND} ? "valgrind " : "";
-
-# Compile the metaquote source filter utility.
-sub ACTION_metaquote {
-    my $self        = shift;
-    my $source_path = catfile(qw( charmonizer metaquote metaquote.c ));
-
-    # don't compile if we're up to date
-    return if $self->up_to_date( [$source_path], $METAQUOTE_EXE_PATH );
-
-    # compile
-    print "\nBuilding $METAQUOTE_EXE_PATH...\n\n";
-    my $cbuilder = ExtUtils::CBuilder->new;
-    my $o_file   = $cbuilder->compile(
-        source               => $source_path,
-        extra_compiler_flags => $EXTRA_CCFLAGS,
-    );
-    $cbuilder->link_executable(
-        objects  => [$o_file],
-        exe_file => $METAQUOTE_EXE_PATH,
-    );
-
-    # clean both the object file and the executable
-    $self->add_to_cleanup( $o_file, $METAQUOTE_EXE_PATH );
-}
-
-# Build the charmonize executable.
-sub ACTION_charmonizer {
-    my $self         = shift;
-    my $filtered_dir = catdir(qw( charmonizer filtered_src ));
-    if ( !-d $filtered_dir ) {
-        mkpath($filtered_dir) or die "can't mkpath '$filtered_dir': $!";
-    }
-
-    $self->dispatch('metaquote');
-
-    my $charm_source_files
-        = $self->_find_charm_source_files($CHARMONIZER_SOURCE_DIR);
-    my $filtered_files = $self->_metaquote_charm_files($charm_source_files);
-    my $charmonize_c   = catfile(qw( charmonizer charmonize.c ));
-    my @all_source     = ( $charmonize_c, @$filtered_files );
-
-    # don't compile if we're up to date
-    return if $self->up_to_date( \@all_source, $CHARMONIZE_EXE_PATH );
-
-    print "Building $CHARMONIZE_EXE_PATH...\n\n";
-
-    my $cbuilder = ExtUtils::CBuilder->new;
-
-    my @o_files;
-    for (@all_source) {
-        next unless /\.c$/;
-        my $o_file = $cbuilder->object_file($_);
-        push @o_files, $o_file;
-
-        next if $self->up_to_date( $_, $o_file );
-
-        $cbuilder->compile(
-            source               => $_,
-            include_dirs         => [$filtered_dir],
-            extra_compiler_flags => $EXTRA_CCFLAGS,
-        );
-    }
-
-    my $exe_path = $cbuilder->link_executable(
-        objects  => \@o_files,
-        exe_file => $CHARMONIZE_EXE_PATH,
-    );
-
-    $self->add_to_cleanup( $filtered_dir, @$filtered_files, @o_files,
-        $CHARMONIZE_EXE_PATH, );
-}
-
-sub _find_charm_source_files {
-    my ( $self, $dir ) = @_;
-    my @files;
-    find(
-        {   wanted => sub {
-                if ( $File::Find::name =~ /\.c?harm$/ ) {
-                    push @files, $File::Find::name;
-                }
-            },
-            no_chdir => 1,
-        },
-        $dir,
-    );
-    return \@files;
-}
-
-sub _metaquote_charm_files {
-    my ( $self, $charm_files ) = @_;
-    my @filtered_files;
-
-    for my $source_path (@$charm_files) {
-        my $dest_path = $source_path;
-        $dest_path =~ s#(.*)src#$1filtered_src#;
-        $dest_path =~ s#\.charm#.c#;
-        $dest_path =~ s#\.harm#.h#;
-
-        push @filtered_files, $dest_path;
-
-        next if ( $self->up_to_date( $source_path, $dest_path ) );
-
-        # create directories if need be
-        my ( undef, $dir, undef ) = splitpath($dest_path);
-        if ( !-d $dir ) {
-            $self->add_to_cleanup($dir);
-            mkpath $dir or die "Couldn't mkpath $dir";
-        }
-
-        # run the metaquote filter
-        system("./$METAQUOTE_EXE_PATH $source_path $dest_path");
-    }
-
-    return \@filtered_files;
-}
-
-# Run the charmonizer executable, creating the lucyconf.h file.
-sub ACTION_lucyconf {
-    my $self          = shift;
-    my $lucyconf_in   = 'lucyconf_in';
-    my $lucyconf_path = "lucyconf.h";
-
-    $self->dispatch('charmonizer');
-
-    return if $self->up_to_date( $CHARMONIZE_EXE_PATH, $lucyconf_path );
-    print "\nWriting $lucyconf_path...\n\n";
-
-    # write the infile with which to communicate args to charmonize
-    open( my $infile_fh, '>', $lucyconf_in )
-        or die "Can't open '$lucyconf_in': $!";
-    print $infile_fh qq|
-        <charm_outpath>$lucyconf_path</charm_outpath>
-        <charm_compiler>$Config{cc}</charm_compiler>
-        <charm_ccflags>$Config{ccflags}</charm_ccflags>
-    |;
-    close $infile_fh or die "Can't close '$lucyconf_in': $!";
-
-    system("$VALGRIND ./$CHARMONIZE_EXE_PATH $lucyconf_in");
-
-    unlink($lucyconf_in) or die "Can't unlink '$lucyconf_in': $!";
-
-    $self->add_to_cleanup($lucyconf_path);
-}
-
-sub ACTION_code {
-    my $self = shift;
-    $self->dispatch('lucyconf');
-    $self->SUPER::ACTION_code(@_);
-}
-
-END_BUILD_CLASS
-
-my $class = Module::Build->subclass(
-    class => 'Lucy::Build',
-    code  => $subclass_code,
-);
+=for Rationale
 
-my $builder = $class->new(
+When the distribution tarball for the Perl binding of Lucy is built, c_src/,
+c_test/, and any other needed files/directories are copied into the perl/
+directory within the main Lucy directory.  Then the distro is built from the
+contents of the perl/ directory, leaving out all the files in ruby/, etc.
+However, during development, the files are access from their original
+locations.
+
+=cut
+
+my $c_src = -e 'c_src' ? 'c_src' : catdir( updir(), 'c_src' );
+
+my $builder = Lucy::Build->new(
     module_name        => 'Lucy',
     license            => 'apache',
     dist_author        => 'Marvin Humphrey <marvin at rectangular dot com>',
-    dist_version_from  => 'src/perl/Lucy.pm',
-    dist_abstract_from => 'src/perl/Lucy.pm',
+    dist_version_from  => 'lib/Lucy.pm',
+    dist_abstract_from => 'lib/Lucy.pm',
     create_makefile_pl => 'passthrough',
     build_requres      => {
         'ExtUtils::CBuilder' => 0.18,

Added: lucene/lucy/trunk/perl/MANIFEST
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/MANIFEST?view=auto&rev=465363
==============================================================================
--- lucene/lucy/trunk/perl/MANIFEST (added)
+++ lucene/lucy/trunk/perl/MANIFEST Wed Oct 18 13:33:33 2006
@@ -0,0 +1,6 @@
+Build.PL
+buildlib/Lucy/Build.pm
+lib/Lucy.pm
+MANIFEST			This list of files
+Makefile.PL
+META.yml

Added: lucene/lucy/trunk/perl/MANIFEST.SKIP
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/MANIFEST.SKIP?view=auto&rev=465363
==============================================================================
--- lucene/lucy/trunk/perl/MANIFEST.SKIP (added)
+++ lucene/lucy/trunk/perl/MANIFEST.SKIP Wed Oct 18 13:33:33 2006
@@ -0,0 +1,38 @@
+# cvs files and directories
+\bCVS\b
+,v$
+
+# all object files
+\.o
+
+# Module::Build generated files and dirs.
+^Build$
+^blib/
+^_build
+
+# Makemaker generated files and dirs.
+^MANIFEST\.
+^Makefile$
+^Makefile\.old$
+^MakeMaker-\d
+pm_to_blib
+
+# hidden files
+^\.
+/\.
+
+# Apple window status files
+\.DS_Store
+
+# vim swap files
+\.swp$
+
+# log files
+\.log$
+
+# various detritus
+^helper
+^_Inline
+\.gz$
+\.ERR$
+

Added: lucene/lucy/trunk/perl/META.yml
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/META.yml?view=auto&rev=465363
==============================================================================
--- lucene/lucy/trunk/perl/META.yml (added)
+++ lucene/lucy/trunk/perl/META.yml Wed Oct 18 13:33:33 2006
@@ -0,0 +1,17 @@
+---
+name: Lucy
+version: 0.0001
+author:
+  - 'Marvin Humphrey <marvin at rectangular dot com>'
+abstract: Search engine library.
+license: apache
+resources:
+  license: http://apache.org/licenses/LICENSE-2.0
+provides:
+  Lucy:
+    file: lib/Lucy.pm
+    version: 0.0001
+generated_by: Module::Build version 0.2805
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.2.html
+  version: 1.2

Added: lucene/lucy/trunk/perl/Makefile.PL
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/Makefile.PL?view=auto&rev=465363
==============================================================================
--- lucene/lucy/trunk/perl/Makefile.PL (added)
+++ lucene/lucy/trunk/perl/Makefile.PL Wed Oct 18 13:33:33 2006
@@ -0,0 +1,31 @@
+# Note: this file was auto-generated by Module::Build::Compat version 0.03
+    
+    unless (eval "use Module::Build::Compat 0.02; 1" ) {
+      print "This module requires Module::Build to install itself.\n";
+      
+      require ExtUtils::MakeMaker;
+      my $yn = ExtUtils::MakeMaker::prompt
+	('  Install Module::Build now from CPAN?', 'y');
+      
+      unless ($yn =~ /^y/i) {
+	die " *** Cannot install without Module::Build.  Exiting ...\n";
+      }
+      
+      require Cwd;
+      require File::Spec;
+      require CPAN;
+      
+      # Save this 'cause CPAN will chdir all over the place.
+      my $cwd = Cwd::cwd();
+      
+      CPAN::Shell->install('Module::Build::Compat');
+      CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate
+	or die "Couldn't install Module::Build, giving up.\n";
+      
+      chdir $cwd or die "Cannot chdir() back to $cwd: $!";
+    }
+    eval "use Module::Build::Compat 0.02; 1" or die $@;
+    use lib 'buildlib';
+    Module::Build::Compat->run_build_pl(args => \@ARGV);
+    require Lucy::Build;
+    Module::Build::Compat->write_makefile(build_class => 'Lucy::Build');

Added: lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm?view=auto&rev=465363
==============================================================================
--- lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm (added)
+++ lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm Wed Oct 18 13:33:33 2006
@@ -0,0 +1,200 @@
+package Lucy::Build;
+use strict;
+use warnings;
+use base qw( Module::Build );
+
+use File::Spec::Functions qw( catdir catfile curdir splitpath updir );
+use File::Path qw( mkpath );
+use File::Find qw( find );
+use ExtUtils::CBuilder;
+use Config;
+use Env qw( @PATH );
+
+unshift @PATH, curdir();
+
+my $base_dir = -e 'charmonizer' ? curdir() : updir();
+
+my $METAQUOTE_EXE_PATH     = 'metaquote';
+my $CHARMONIZE_EXE_PATH    = 'charmonize';
+my $CHARMONIZER_SOURCE_DIR = catdir( $base_dir, 'charmonizer', 'src' );
+
+my $EXTRA_CCFLAGS
+    = $ENV{DEBUG_CHARM} ? " -ansi -pedantic -Wall -Wextra -std=c89 " : "";
+my $VALGRIND = $ENV{CHARM_VALGRIND} ? "valgrind " : "";
+
+# Compile the metaquote source filter utility.
+sub ACTION_metaquote {
+    my $self = shift;
+    my $source_path
+        = catfile( $base_dir, qw( charmonizer metaquote metaquote.c ) );
+
+    # don't compile if we're up to date
+    return if $self->up_to_date( [$source_path], $METAQUOTE_EXE_PATH );
+
+    # compile
+    print "\nBuilding $METAQUOTE_EXE_PATH...\n\n";
+    my $cbuilder = ExtUtils::CBuilder->new;
+    my $o_file   = $cbuilder->compile(
+        source               => $source_path,
+        extra_compiler_flags => $EXTRA_CCFLAGS,
+    );
+    $cbuilder->link_executable(
+        objects  => [$o_file],
+        exe_file => $METAQUOTE_EXE_PATH,
+    );
+
+    # clean both the object file and the executable
+    $self->add_to_cleanup( $o_file, $METAQUOTE_EXE_PATH );
+}
+
+# Build the charmonize executable.
+sub ACTION_charmonizer {
+    my $self         = shift;
+    my $filtered_dir = catdir( $base_dir, qw( charmonizer filtered_src ) );
+    if ( !-d $filtered_dir ) {
+        mkpath($filtered_dir) or die "can't mkpath '$filtered_dir': $!";
+    }
+
+    $self->dispatch('metaquote');
+
+    my $charm_source_files
+        = $self->_find_charm_source_files($CHARMONIZER_SOURCE_DIR);
+    my $filtered_files = $self->_metaquote_charm_files($charm_source_files);
+    my $charmonize_c   = catfile($base_dir, qw( charmonizer charmonize.c ) );
+    my @all_source     = ( $charmonize_c, @$filtered_files );
+
+    # don't compile if we're up to date
+    return if $self->up_to_date( \@all_source, $CHARMONIZE_EXE_PATH );
+
+    print "Building $CHARMONIZE_EXE_PATH...\n\n";
+
+    my $cbuilder = ExtUtils::CBuilder->new;
+
+    my @o_files;
+    for (@all_source) {
+        next unless /\.c$/;
+        my $o_file = $cbuilder->object_file($_);
+        push @o_files, $o_file;
+
+        next if $self->up_to_date( $_, $o_file );
+
+        $cbuilder->compile(
+            source               => $_,
+            include_dirs         => [$filtered_dir],
+            extra_compiler_flags => $EXTRA_CCFLAGS,
+        );
+    }
+
+    my $exe_path = $cbuilder->link_executable(
+        objects  => \@o_files,
+        exe_file => $CHARMONIZE_EXE_PATH,
+    );
+
+    $self->add_to_cleanup( $filtered_dir, @$filtered_files, @o_files,
+        $CHARMONIZE_EXE_PATH, );
+}
+
+sub _find_charm_source_files {
+    my ( $self, $dir ) = @_;
+    my @files;
+    find(
+        {   wanted => sub {
+                if ( $File::Find::name =~ /\.c?harm$/ ) {
+                    push @files, $File::Find::name;
+                }
+            },
+            no_chdir => 1,
+        },
+        $dir,
+    );
+    return \@files;
+}
+
+sub _metaquote_charm_files {
+    my ( $self, $charm_files ) = @_;
+    my @filtered_files;
+
+    for my $source_path (@$charm_files) {
+        my $dest_path = $source_path;
+        $dest_path =~ s#(.*)src#$1filtered_src#;
+        $dest_path =~ s#\.charm#.c#;
+        $dest_path =~ s#\.harm#.h#;
+
+        push @filtered_files, $dest_path;
+
+        next if ( $self->up_to_date( $source_path, $dest_path ) );
+
+        # create directories if need be
+        my ( undef, $dir, undef ) = splitpath($dest_path);
+        if ( !-d $dir ) {
+            $self->add_to_cleanup($dir);
+            mkpath $dir or die "Couldn't mkpath $dir";
+        }
+
+        # run the metaquote filter
+        system( $METAQUOTE_EXE_PATH, $source_path, $dest_path );
+    }
+
+    return \@filtered_files;
+}
+
+# Run the charmonizer executable, creating the lucyconf.h file.
+sub ACTION_lucyconf {
+    my $self          = shift;
+    my $lucyconf_in   = 'lucyconf_in';
+    my $lucyconf_path = "lucyconf.h";
+
+    $self->dispatch('charmonizer');
+
+    return if $self->up_to_date( $CHARMONIZE_EXE_PATH, $lucyconf_path );
+    print "\nWriting $lucyconf_path...\n\n";
+
+    # write the infile with which to communicate args to charmonize
+    open( my $infile_fh, '>', $lucyconf_in )
+        or die "Can't open '$lucyconf_in': $!";
+    print $infile_fh qq|
+        <charm_outpath>$lucyconf_path</charm_outpath>
+        <charm_compiler>$Config{cc}</charm_compiler>
+        <charm_ccflags>$Config{ccflags}</charm_ccflags>
+    |;
+    close $infile_fh or die "Can't close '$lucyconf_in': $!";
+
+    if ($VALGRIND) {
+        system("$VALGRIND ./$CHARMONIZE_EXE_PATH $lucyconf_in");
+    }
+    else {
+        system( $CHARMONIZE_EXE_PATH, $lucyconf_in );
+    }
+
+    unlink($lucyconf_in) or die "Can't unlink '$lucyconf_in': $!";
+
+    $self->add_to_cleanup($lucyconf_path);
+}
+
+sub ACTION_code {
+    my $self = shift;
+    $self->dispatch('lucyconf');
+    $self->SUPER::ACTION_code(@_);
+}
+
+1;
+
+__END__
+
+
+    /**
+     * Copyright 2006 The Apache Software Foundation
+     *
+     * Licensed under the Apache License, Version 2.0 (the "License");
+     * you may not use this file except in compliance with the License.
+     * You may obtain a copy of the License at
+     *
+     *     http://www.apache.org/licenses/LICENSE-2.0
+     *
+     * Unless required by applicable law or agreed to in writing, software
+     * distributed under the License is distributed on an "AS IS" BASIS,
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+     * implied.  See the License for the specific language governing
+     * permissions and limitations under the License.
+     */
+



Mime
View raw message