lucy-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=692616&view=rev
Log:
Subclass ExtUtils::CBuilder to accomodate Windows linking and lazy loading.

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=692616&r1=692615&r2=692616&view=diff
==============================================================================
--- lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm (original)
+++ lucene/lucy/trunk/perl/buildlib/Lucy/Build.pm Fri Sep  5 23:38:17 2008
@@ -1,12 +1,33 @@
 use strict;
 use warnings;
 
+package Lucy::Build::CBuilder;
+BEGIN { our @ISA = "ExtUtils::CBuilder"; }
+use Config;
+
+sub new {
+    my $class = shift;
+    require ExtUtils::CBuilder;
+    return $class->SUPER::new(@_);
+}
+
+# This method isn't implemented by CBuilder for Windows, so we issue a basic
+# link command that works on at least one system and hope for the best.
+sub link_executable {
+    my ( $self, %args ) = @_;
+    if ( $Config{cc} eq 'cl' ) {
+        my ( $objects, $exe_file ) = @args{qw( objects exe_file )};
+        $self->do_system("link /out:$exe_file @$objects");
+        return $exe_file;
+    }
+    else {
+        return $self->SUPER::link_executable(%args);
+    }
+}
+
 package Lucy::Build;
 use base qw( Module::Build );
 
-# Don't crash Build.PL if CBuilder isn't installed yet
-BEGIN { eval "use ExtUtils::CBuilder;"; }
-
 use File::Spec::Functions
     qw( catdir catfile curdir splitpath updir no_upwards );
 use File::Path qw( mkpath rmtree );
@@ -45,7 +66,7 @@
 
     # compile
     print "\nBuilding $METAQUOTE_EXE_PATH...\n\n";
-    my $cbuilder = ExtUtils::CBuilder->new;
+    my $cbuilder = Lucy::Build::CBuilder->new;
     my $o_file   = $cbuilder->compile(
         source               => $source_path,
         extra_compiler_flags => $EXTRA_CCFLAGS,
@@ -80,7 +101,7 @@
 
     print "Building $CHARMONIZE_EXE_PATH...\n\n";
 
-    my $cbuilder = ExtUtils::CBuilder->new;
+    my $cbuilder = Lucy::Build::CBuilder->new;
 
     my @o_files;
     for (@all_source) {
@@ -214,7 +235,7 @@
 
     return if $self->up_to_date( $source_files, $exe_path );
 
-    my $cbuilder = ExtUtils::CBuilder->new;
+    my $cbuilder = Lucy::Build::CBuilder->new;
 
     # compile and link "charm_test"
     my @o_files;



Mime
View raw message