Subject: | C file is generated in root directory |
Revisiting my previous attempts at getting an XS distribution to build
with both ExtUtils::MakeMaker and Module::Build, I've come across a bug.
Generate a sample Foo module using:
h2xs -n Foo --skip-autoloader
and then drop the attached Build.PL file into place.
Run:
perl Build.PL
perl Build
and you'll find that Foo.c (and Foo.obj) has been created in the root of
the current drive, rather than in the current directory. So in the line:
xs_files => { 'Foo.xs' => 'Foo.xs' },
"Foo.xs" has evidently been interpreted in two different ways: firstly
as ".\Foo.xs" for key and then as "\Foo.xs" for the value!
Somehow, the build actually manages to work, but this is clearly not good.
I'm running bleadperl on Windows XP with VC++ 6.
Subject: | Build.PL |
use Module::Build;
my $build = Module::Build->new(
module_name => 'Foo',
xs_files => { 'Foo.xs' => 'Foo.xs' },
include_dirs => [ '.' ],
add_to_cleanup => ['const-c.inc', 'const-xs.inc'],
);
$build->create_build_script();
if (eval {require ExtUtils::Constant; 1}) {
my @names = (qw());
ExtUtils::Constant::WriteConstants(
NAME => 'Foo',
NAMES => \@names,
DEFAULT_TYPE => 'IV',
C_FILE => 'const-c.inc',
XS_FILE => 'const-xs.inc'
);
}
else {
use File::Copy;
use File::Spec;
foreach my $file ('const-c.inc', 'const-xs.inc') {
my $fallback = File::Spec->catfile('fallback', $file);
copy ($fallback, $file) or die "Can't copy $fallback to $file: $!";
}
}