Index: t/basic.t
===================================================================
--- t/basic.t (revision 12873)
+++ t/basic.t (working copy)
@@ -2,7 +2,7 @@
use strict;
use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
-use MBTest tests => 52;
+use MBTest tests => 60;
use_ok 'Module::Build';
ensure_blib('Module::Build');
@@ -203,6 +203,38 @@
is_deeply $mb->extra_linker_flags, ['-L/foo', '-L/bar'], "Should split shell string into list";
}
+# Test include_dirs.
+{
+ ok my $mb = Module::Build->new(
+ module_name => $dist->name,
+ include_dirs => [qw(/foo /bar)],
+ );
+ is_deeply $mb->include_dirs, ['/foo', '/bar'], 'Should have include dirs';
+ # Try a string.
+ ok $mb = Module::Build->new(
+ module_name => $dist->name,
+ include_dirs => '/foo',
+ );
+ is_deeply $mb->include_dirs, ['/foo'], 'Should have string include dir';
+
+ # Try again with command-line args
+ eval { Module::Build->run_perl_script(
+ 'Build.PL', [],
+ ['--include_dirs', '/foo', '--include_dirs', '/bar' ],
+ ) };
+
+ ok $mb = Module::Build->resume;
+ is_deeply $mb->include_dirs, ['/foo', '/bar'], 'Should have include dirs';
+
+ eval { Module::Build->run_perl_script(
+ 'Build.PL', [],
+ ['--include_dirs', '/foo' ],
+ ) };
+
+ ok $mb = Module::Build->resume;
+ is_deeply $mb->include_dirs, ['/foo'], 'Should have single include dir';
+}
+
# cleanup
$dist->remove;
Index: lib/Module/Build/Base.pm
===================================================================
--- lib/Module/Build/Base.pm (revision 12873)
+++ lib/Module/Build/Base.pm (working copy)
@@ -165,11 +165,16 @@
$p->{requires} = delete $p->{prereq} if defined $p->{prereq};
$p->{script_files} = delete $p->{scripts} if defined $p->{scripts};
- # Convert to arrays
+ # Convert to from shell strings to arrays
for ('extra_compiler_flags', 'extra_linker_flags') {
$p->{$_} = [ $self->split_like_shell($p->{$_}) ] if exists $p->{$_};
}
+ # Convert to arrays
+ for ('include_dirs') {
+ $p->{$_} = [ $p->{$_} ] if exists $p->{$_} && !ref $p->{$_}
+ }
+
$self->add_to_cleanup( @{delete $p->{add_to_cleanup}} )
if $p->{add_to_cleanup};
@@ -1760,6 +1765,11 @@
$args{$_} = [ $self->split_like_shell($args{$_}) ] if exists $args{$_};
}
+ # Convert to arrays
+ for ('include_dirs') {
+ $args{$_} = [ $args{$_} ] if exists $args{$_} && !ref $args{$_}
+ }
+
# Hashify these parameters
for ($self->hash_properties, 'config') {
next unless exists $args{$_};