Author: kwilliams
Date: Sun Feb 17 12:00:41 2008
New Revision: 10768

Modified:
   Module-Build/trunk/Changes
   Module-Build/trunk/lib/Module/Build/Compat.pm
   Module-Build/trunk/t/compat.t

Log:
Fix some Makefile-to-build argument translation by taking the '--' out of the 
translation hash and dealing with it separately

Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes  (original)
+++ Module-Build/trunk/Changes  Sun Feb 17 12:00:41 2008
@@ -1,5 +1,8 @@
 Revision history for Perl extension Module::Build.
 
+ - Fixed processing of INC=, POLLUTE=, INSTALLDIRS=, and LIB= for
+   passthrough/small Makefile.PLs.
+
  - perl Build.PL --sign=1 now signs. [Michael G Schwern]
 
  - Fixed processing of INSTALLDIRS=whatever for compatibility

Modified: Module-Build/trunk/lib/Module/Build/Compat.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Compat.pm       (original)
+++ Module-Build/trunk/lib/Module/Build/Compat.pm       Sun Feb 17 12:00:41 2008
@@ -15,10 +15,10 @@
   (
    TEST_VERBOSE => 'verbose',
    VERBINST     => 'verbose',
-   INC     => sub { map {('--extra_compiler_flags', $_)} 
Module::Build->split_like_shell(shift) },
-   POLLUTE => sub { ('--extra_compiler_flags', '-DPERL_POLLUTE') },
-   INSTALLDIRS => sub {local $_ = shift; ('--installdirs', (/^perl$/ ? 'core' 
: $_)) },
-   LIB => sub { ('--install_path', 'lib='.shift()) },
+   INC          => sub { map {(extra_compiler_flags => $_)} 
Module::Build->split_like_shell(shift) },
+   POLLUTE      => sub { (extra_compiler_flags => '-DPERL_POLLUTE') },
+   INSTALLDIRS  => sub { local $_ = shift; (installdirs => (/^perl$/ ? 'core' 
: $_)) },
+   LIB          => sub { (install_path => ('lib='.shift())) },
 
    # Some names they have in common
    map {$_, lc($_)} qw(DESTDIR PREFIX INSTALL_BASE UNINST),
@@ -170,7 +170,7 @@
 }
 
 sub makefile_to_build_args {
-  shift;
+  my $class = shift;
   my @out;
   foreach my $arg (@_) {
     next if $arg eq '';
@@ -194,17 +194,27 @@
 
     if (exists $makefile_to_build{$key}) {
       my $trans = $makefile_to_build{$key};
-      push @out, ref($trans) ? $trans->($val) : ("--$trans", $val);
+      push @out, $class->_argvify( ref($trans) ? $trans->($val) : ($trans => 
$val) );
     } elsif (exists $Config{lc($key)}) {
-      push @out, '--config', lc($key) . "=$val";
+      push @out, $class->_argvify( config => lc($key) . "=$val" );
     } else {
       # Assume M::B can handle it in lowercase form
-      push @out, "--\L$key", $val;
+      push @out, $class->_argvify("\L$key" => $val);
     }
   }
   return @out;
 }
 
+sub _argvify {
+  my ($self, @pairs) = @_;
+  my @out;
+  while (@pairs) {
+    my ($k, $v) = splice @pairs, 0, 2;
+    push @out, ("--$k", $v);
+  }
+  return @out;
+}
+
 sub makefile_to_build_macros {
   my @out;
   while (my ($macro, $trans) = each %makefile_to_build) {

Modified: Module-Build/trunk/t/compat.t
==============================================================================
--- Module-Build/trunk/t/compat.t       (original)
+++ Module-Build/trunk/t/compat.t       Sun Feb 17 12:00:41 2008
@@ -18,7 +18,7 @@
 #find_in_path does not understand VMS.
 
 if ( $Config{make} && $^O ne 'VMS' ? find_in_path($Config{make}) : 1 ) {
-    plan tests => 32 + @makefile_types*$tests_per_type*2;
+    plan tests => 34 + @makefile_types*$tests_per_type*2;
 } else {
     plan skip_all => "Don't know how to invoke 'make'";
 }
@@ -214,11 +214,28 @@
        qr/# .+basic[.\s#]+ok[.\s#]+All tests successful/,
        'Should be non-verbose';
 
+  (my $libdir2 = $libdir) =~ s/libdir/lbiidr/;
+  ($output) = stdout_stderr_of(
+    sub {
+      $ran_ok = $mb->do_system(@make, 'fakeinstall',
+                              'INSTALLDIRS=vendor',
+                              "INSTALLVENDORLIB=$libdir2");
+    }
+  );
+
+  ok $ran_ok, "make fakeinstall with INSTALLDIRS=vendor ran ok";
+  $output =~ s/^/# /gm;  # Don't confuse our own test output
+  like $output,
+       qr/\Q$libdir2/,
+       'Should have installdirs=vendor';
+
   stdout_of( sub { $mb->do_system(@make, 'realclean'); } );
   ok ! -e $makefile, "$makefile shouldn't exist";
 
   1 while unlink 'Makefile.PL';
   ok ! -e 'Makefile.PL', "Makefile.PL cleaned up";
+
+  1 while unlink $libdir, $libdir2;
 }
 
 { # Make sure tilde-expansion works

Reply via email to