Skip Menu |
 

This queue is for tickets about the Module-Build CPAN distribution.

Report information
The Basics
Id: 20532
Status: rejected
Priority: 0/
Queue: Module-Build

People
Owner: Nobody in particular
Requestors: shay [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.2804
Fixed in: (no value)



Subject: C file is generated in root directory
Download (untitled) / with headers
text/plain 745b
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
Download Build.PL
text/x-perl 780b
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: $!"; } }
RT-Send-CC: module-build [...] perl.org
Download (untitled) / with headers
text/plain 157b
On Tue Jul 18 10:22:07 2006, SHAY wrote: Show quoted text
> xs_files => { 'Foo.xs' => 'Foo.xs' },
should be: xs_files => {'Foo.xs' => 'lib/Foo.xs'}, --Eric
Subject: xs_files confusion?
Download (untitled) / with headers
text/plain 673b
On Sun Jul 15 03:33:56 2007, EWILHELM wrote: Show quoted text
> On Tue Jul 18 10:22:07 2006, SHAY wrote:
> > xs_files => { 'Foo.xs' => 'Foo.xs' },
> > should be: > xs_files => {'Foo.xs' => 'lib/Foo.xs'},
also_see: http://rt.cpan.org/Ticket/Display.html?id=20533 Note that it is really much simpler to just make a tree in lib/ rather than using the pm_files or xs_files parameters. If you do use these parameters, the values need to start with "lib/". The values should never point to the same file as the key. I would make this a wishlist item to add some better documentation, but I'm not sure what else should be said about it, so closing as "notabug". --Eric
Download (untitled) / with headers
text/plain 1.1k
On Sun Sep 30 22:36:36 2007, EWILHELM wrote: Show quoted text
> On Sun Jul 15 03:33:56 2007, EWILHELM wrote:
> > On Tue Jul 18 10:22:07 2006, SHAY wrote:
> > > xs_files => { 'Foo.xs' => 'Foo.xs' },
> > > > should be: > > xs_files => {'Foo.xs' => 'lib/Foo.xs'},
I tried that, but then I get a build error relating to the fact that Foo.xs is now in lib/ but the files that it includes (const-c.inc and const-xs.inc) are still in the top-level directory: C:\Temp\Foo>perl Build Copying Foo.xs -> lib\Foo.xs lib\Foo.xs -> lib\Foo.c Cannot open 'const-xs.inc': No such file or directory in Foo.xs, line 11 Show quoted text
> > Note that it is really much simpler to just make a tree in lib/ rather > than using the pm_files or xs_files parameters.
Do you mean put the Foo.xs together with the const-*.inc files in lib/ in the first place? The problem with that is that it doesn't work with ExtUtils-MakeMaker. What I was really trying to achieve with this (and 20533) was a setup in which an XS module could be built using either Module-Build or ExtUtils-MakeMaker. I was, and still am, unable to build a traditional ExtUtils-MakeMaker layout (as produced by h2xs) using Module-Build.
Subject: Re: [rt.cpan.org #20532] C file is generated in root directory
Date: Tue, 9 Oct 2007 12:27:12 -0700
To: bug-Module-Build [...] rt.cpan.org
From: Eric Wilhelm <scratchcomputing [...] gmail.com>
Download (untitled) / with headers
text/plain 1.9k
# from via RT # on Tuesday 09 October 2007 06:27: Show quoted text
> > xs_files => {'Foo.xs' => 'lib/Foo.xs'},
Show quoted text
>I tried that, but then I get a build error relating to the fact that >Foo.xs is now in lib/ but the files that it includes (const-c.inc and >const-xs.inc) are still in the top-level directory:
... Show quoted text
>Do you mean put the Foo.xs together with the const-*.inc files in lib/ >in the first place? The problem with that is that it doesn't work with >ExtUtils-MakeMaker.
I see. The trouble is that ExtUtils::ParseXS (and historically, xsubpp) chdir into the dirname($xsfile) directory and work from there. Possibly there's a way to get EU::MM to play nicely in 'lib/', but otherwise the way to get your compatibility is like so: xs_files => { './Foo.xs' => './Foo.xs' }, Note the ./ on both. (Yes, this is confusing and "something ought to be done about it".) Aside: you're creating the .inc files in Build.PL, which means a `./Build` will fail after `./Build clean` clean because they're in the cleanup. The attached subclass puts their creation into the build process at process_xs_files() time (though an up_to_date() check of some sort is probably warranted.) rm Foo -rf h2xs -n Foo --skip-autoloader mkdir Foo/inc cp MyXSConstants.pm Foo/inc cp Build.PL Foo/ cd Foo; perl Build.PL && \ ./Build --verbose && \ ./Build test && cd .. (This probably needs to be a cookbook entry.) As for the actual bug: either we disallow bare paths as values in foo_files parameters (and fix the 'eq' check which causes add_to_cleanup (bug #20533)) or we deal with all of the places where File::Spec causes the bare paths to turn into '/foo'. The culprits are: _infer_xs_spec() my( $v, $d, $f ) = File::Spec->splitpath( $file ); ... $spec{c_file} = File::Spec->catfile( $spec{src_dir}, "${file_base}.c" ); process_xs_files() unless ($from eq $to) { $self->add_to_cleanup($to); ... --Eric
Download Build.PL
text/x-perl 254b

Message body is not shown because sender requested not to inline it.

Download MyXSConstants.pm
text/x-perl 651b

Message body is not shown because sender requested not to inline it.

Download (untitled) / with headers
text/plain 128b
Perhaps the docs are unclear, but the behavior is as-specified. Closing this and opening #31567 to address that. Thanks, Eric


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.