develooper Front page | perl.perl5.porters | Postings from February 2009

Re: distclean and ext (was Re: restructuring ext (Re: merging make_ext and make_ext_cross))

Thread Previous | Thread Next
From:
demerphq
Date:
February 15, 2009 02:29
Subject:
Re: distclean and ext (was Re: restructuring ext (Re: merging make_ext and make_ext_cross))
Message ID:
9b18b3110902150229p3776d9c4yb0bf9da2959d7d30@mail.gmail.com
2009/2/12 Nicholas Clark <nick@ccl4.org>:
> On Thu, Feb 12, 2009 at 01:33:33PM -0600, Craig A. Berry wrote:
>
>> It was a bit more complicated than I thought, but it's done:
>>
>> http://perl5.git.perl.org/perl.git/commitdiff/619cec6d
>>
>> Any path in MANIFEST that starts with ext/ or vms/ext/ and the next
>> component in that path is a directory will have that component
>> converted to an extension name and added to known_extensions if it's
>> not already there.
>>
>> nonxs_ext is still to-do.
>
> Cool, thanks
>
> I removed ext/Safe/Makefile.PL with e74f76b27bd4a9c64ec8f4f10c74bbd59db04e7d
>
> diff --git a/MANIFEST b/MANIFEST
> index 67fddb6..6c51220 100644
> --- a/MANIFEST
> +++ b/MANIFEST
> @@ -1018,7 +1018,6 @@ ext/re/t/re_funcs.t               See if exportable 're' funcs in re.xs work
>  ext/re/t/regop.pl              generate debug output for various patterns
>  ext/re/t/regop.t               test RE optimizations by scraping debug output
>  ext/re/t/re.t                  see if re pragma works
> -ext/Safe/Makefile.PL           Safe extension Perl module
>  ext/Safe/Safe.pm               Safe extension Perl module
>  ext/Safe/t/safe1.t             See if Safe works
>  ext/Safe/t/safe2.t             See if Safe works
> diff --git a/ext/Safe/Makefile.PL b/ext/Safe/Makefile.PL
> deleted file mode 100644
> index b4aa932..0000000
> --- a/ext/Safe/Makefile.PL
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -# Yes, this is boilerplate and will be abolished "real soon now".
> -use strict;
> -use ExtUtils::MakeMaker;
> -
> -WriteMakefile(
> -    NAME       => 'Safe',
> -    VERSION_FROM => 'Safe.pm',
> -);
> diff --git a/make_ext.pl b/make_ext.pl
> index e9d318d..f74124c 100644
> --- a/make_ext.pl
> +++ b/make_ext.pl
> @@ -206,12 +206,13 @@ foreach my $spec (@extspec)  {
>     print "\tMaking $mname ($target)\n";
>
>     build_extension('ext', $ext_pathname, $up, $perl || "$up/miniperl",
> -                   "$up/lib",
> +                   "$up/lib", $mname,
>                    [@pass_through, @{$extra_passthrough{$spec} || []}]);
>  }
>
>  sub build_extension {
> -    my ($ext, $ext_dir, $return_dir, $perl, $lib_dir, $pass_through) = @_;
> +    my ($ext, $ext_dir, $return_dir, $perl, $lib_dir, $mname, $pass_through)
> +       = @_;
>     unless (chdir "$ext_dir") {
>        warn "Cannot cd to $ext_dir: $!";
>        return;
> @@ -229,6 +230,47 @@ sub build_extension {
>     }
>
>     if (!-f $makefile) {
> +       if (!-f 'Makefile.PL') {
> +           print "\nCreating Makefile.PL in $ext_dir for $mname\n";
> +           # We need to cope well with various possible layouts
> +           my @dirs = split /::/, $mname;
> +           my $leaf = pop @dirs;
> +           my $leafname = "$leaf.pm";
> +           my $pathname = join '/', @dirs, $leafname;
> +           my @locations = ($leafname, $pathname, "lib/$pathname");
> +           my $fromname;
> +           foreach (@locations) {
> +               if (-f $_) {
> +                   $fromname = $_;
> +                   last;
> +               }
> +           }
> +
> +           unless ($fromname) {
> +               die "For $mname tried @locations in in $ext_dir but can't find source";
> +           }
> +           open my $fh, '>', 'Makefile.PL'
> +               or die "Can't open Makefile.PL for writing: $!";
> +           print $fh <<"EOM";
> +#-*- buffer-read-only: t -*-
> +
> +# This Makefile.PL was written by $0.
> +# It will be deleted automatically by make realclean
> +
> +use strict;
> +use ExtUtils::MakeMaker;
> +
> +WriteMakefile(
> +    NAME          => '$mname',
> +    VERSION_FROM  => '$fromname',
> +    ABSTRACT_FROM => '$fromname',
> +    realclean     => {FILES => 'Makefile.PL'},
> +);
> +
> +# ex: set ro:
> +EOM
> +           close $fh or die "Can't close Makefile.PL: $!";
> +       }
>        print "\nRunning Makefile.PL in $ext_dir\n";
>
>        # Presumably this can be simplified
>
>
>
> I then moved Attribute::Handlers from lib to ext. In lib it's not possible to
> match the layout of the CPAN tarball. This makes maintenance trickier. In
> ext it is. The diff is noisy (file moves, and MANIFEST shuffling). The most
> interesting part is:
>
> diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl
> index c060e1c..660c131 100644
> --- a/Porting/Maintainers.pl
> +++ b/Porting/Maintainers.pl
> @@ -125,8 +125,7 @@ package Maintainers;
>        'Attribute::Handlers' =>
>                {
>                'MAINTAINER'    => 'rgarcia',
> -               'FILES'         => q[lib/Attribute/Handlers.pm
> -                                    lib/Attribute/Handlers],
> +               'FILES'         => q[ext/Attribute-Handlers],
>                'CPAN'          => 1,
>                 'UPSTREAM'      => "blead",
>                },
>
>
>
> At this point I think I should stop, because:
>
>
> 1: This isn't "stable" yet (anyone care to bet on how many emergent side
>   effects this will have?) so I'm not convinced that I can recommend to Dave
>   that the rearrangement goes into maint-5.10 right now. But if it doesn't
>   go in for 5.10.1, but blead rearranges, then it becomes much tricker to
>   merge dual life module updates as part of getting 5.10.1 done
>
> 2: I believe I've created debris for make distclean. Right now Makefile.SH,
>   win32/Makefile, win32/makefile.mk and vms/descrip_mms.template *each* have
>   to be taught how to delete every file installed from ext to lib
>   As I understand it, MakeMaker doesn't deal with them, because it assumes
>   that deleting blib/ in the extension directory will do the job for "clean".
>
>   I think we need to find a solution to this, to eliminate four-fold
>   complexity (and errors and omissions) in the Makefiles, but I'm not yet sure
>   what it is.
>
>   I think that the simplest thing that could possibly work is to delete the
>   *files*, and then have a general sweeper that removes all empty directories,
>   on the not-unreasonable assumption that the build added them, because the
>   distribution contains no empty directories.

Maybe a script that deletes anything in lib that is also in ext?

Find all files in the ext, calculate a sha1 and length of their
contents. Scan lib similarly, anything with the same SHA1 and length
in both directories gets deleted out of lib. Any directory made empty
by this process should itself also be deleted.

Does that sound sane?

cheers,
Yves



-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About