[Module-build-general] Re: MB MacOS fixes
Status: Beta
Brought to you by:
kwilliams
From: Ken W. <ke...@ma...> - 2002-11-28 01:35:17
|
[cc'd to Module::Build list] On Wednesday, November 27, 2002, at 10:48 PM, Michael G Schwern wrote: > Here it is. > > - Becuase its easy to run ./Build from the wrong cwd in > MacPerl, it has to > chdir() to the Module::Build directory in the BEGIN block so the lib/ > in @INC works to find the uninstalled Module::Build. Since > this is useful > in general I put it in M::B::Base Yup. > - 'use blib' normally looks for blib/lib and blib/arch but on > MacPerl, for > some reason, it looks for blib/lib and blib/MacPerl. Probably some > MakeMaker wackiness. As M::B follows a more sane naming scheme the > exception in blib.pm screws things up. So we just use the > much simpler > and much quieter "use lib blib/lib blib/arch" The problem isn't that it's looking for blib/MacPerl (at least, not on my box, 5.6.1r1), it's that it's blindly applying Unix naming conventions. When I fixed those, 'use blib;' worked fine. But you're right, we don't really need it to search up & down the file tree, we can just add these libs directly (though with File::Spec - I suspect it was finding your previously installed copy?). > - atime and mtime are the same thing on MacOS. So when stuff is copied > from lib to blib they wind up with the same -M. > copy_if_modified() was > checking if -M blib/foo < -M lib/foo but on MacOS they would be equal > after the copy. So its changed to -M blib/foo <= -M lib/foo to make > it work. This shouldn't hurt other platforms, so its in Base. I've changed copy_if_modified() to use the up_to_date() method, which I think was already doing it correctly. No use having this criterion in two places. > > The overrides in M::B::P::MacOS should be documented enough to > explain why > they're there. If you can't figure them out, I need to write > better docs. Looks good. > build, help, distcheck, distclean, clean and realclean were > confirmed to > work. test should work with ToolServer, Test::Harness is the problem. > fakeinstall and install work with a repaired ExtUtils::Install. Cool. -Ken > > > > diff -ru Module-Build-0.13.orig/lib/Module/Build/Base.pm Module- > Build-0.13/lib/Module/Build/Base.pm > --- Module-Build-0.13.orig/lib/Module/Build/Base.pm 2002-11-20 > 00:58:46.000000000 -0800 > +++ Module-Build-0.13/lib/Module/Build/Base.pm 2002-11-27 > 03:14:11.000000000 -0800 > @@ -456,9 +456,11 @@ > print $fh <<EOF; > $self->{config}{startperl} -w > > -BEGIN { \@INC = ($quoted_INC) } > +BEGIN { > + \@INC = ($quoted_INC); > + chdir('$base_dir') or die 'Cannot chdir to $base_dir: '.\$!; > +} > > -chdir('$base_dir') or die 'Cannot chdir to $base_dir: '.\$!; > use $build_package; > > # This should have just enough arguments to be able to > bootstrap the rest. > @@ -612,8 +614,7 @@ > > # Make sure we test the module in blib/ > { > - local $SIG{__WARN__} = sub {}; # shut blib.pm up > - eval "use blib"; > + eval "use lib 'blib/lib', 'blib/arch'"; > } > die $@ if $@; > > @@ -1003,7 +1004,7 @@ > } else { > $to_path = File::Spec->catfile($to, $file); > } > - return if -e $to_path and -M $to_path < -M $file; # Already fresh > + return if -e $to_path and -M $to_path <= -M $file; # Already fresh > > # Create parent directories > File::Path::mkpath(File::Basename::dirname($to_path), 0, 0777); > diff -ru Module- > Build-0.13.orig/lib/Module/Build/Platform/MacOS.pm Module- > Build-0.13/lib/Module/Build/Platform/MacOS.pm > --- Module-Build-0.13.orig/lib/Module/Build/Platform/MacOS.pm 2001-11-11 > 12:50:32.000000000 -0800 > +++ Module-Build-0.13/lib/Module/Build/Platform/MacOS.pm 2002-11-27 03:37: > 43.000000000 -0800 > @@ -7,10 +7,6 @@ > @ISA = qw(Module::Build::Base); > > > -1; > -__END__ > - > - > =head1 NAME > > Module::Build::Platform::MacOS - Builder class for MacOS platforms > @@ -20,9 +16,119 @@ > The sole purpose of this module is to inherit from > C<Module::Build::Base>. Please see the L<Module::Build> for the docs. > > +=head2 Overriden Methods > + > +=over 4 > + > +=item new > + > +MacPerl doesn't define $Config{sitelib} or $Config{sitearch} for some > +reason, but $Config{installsitelib} and $Config{installsitearch} are > +there. So we copy the install variables to the other location > + > +=cut > + > +sub new { > + my $class = shift; > + my $self = $class->SUPER::new(@_); > + > + $self->{config}{sitelib} ||= $self->{config}{installsitelib}; > + $self->{config}{sitearch} ||= $self->{config}{installsitearch}; > + > + return $self; > +} > + > +=item make_build_script_executable > + > +On MacOS we set the file type and creator to MacPerl so it will run > +with a double-click. > + > +=cut > + > +sub make_build_script_executable { > + my $self = shift; > + > + # Can't hurt to make it read-only. > + $self->SUPER::make_build_script_executable; > + > + require MacPerl; > + MacPerl::SetFileInfo('McPL', 'TEXT', > $self->{properties}{build_script}); > +} > + > +=item rm_previous_build_script > + > +MacOS maps chmod -w to locking the file. This mean we have to unlock > +it before removing it. > + > +=cut > + > +sub rm_previous_build_script { > + my $self = shift; > + > + if( $self->{properties}{build_script} ) { > + chmod 666, $self->{properties}{build_script}; > + } > + $self->SUPER::rm_previous_build_script; > +} > + > +=item dispatch > + > +Because there's no easy way to say "./Build test" on MacOS, if > +dispatch is called with no arguments and no @ARGV a dialog box will > +pop up asking what action to take and any extra arguments. > + > +Default action is "test". > + > +=cut > + > +sub dispatch { > + my $self = shift; > + > + if( !@_ and !@ARGV ) { > + require MacPerl; > + > + # What comes first in the action list. > + my @action_list = qw(test install build); > + my %actions; > + { > + no strict 'refs'; > + > + foreach my $class ($self->super_classes) { > + foreach ( keys %{ $class . '::' } ) { > + $actions{$1}++ if /ACTION_(\w+)/; > + } > + } > + } > + > + delete @actions{@action_list}; > + push @action_list, sort { $a cmp $b } keys %actions; > + $ARGV[0] = MacPerl::Pick('What build command?', @action_list); > + push @ARGV, split /\s+/, > + MacPerl::Ask('Any extra arguments? (ie. > verbose=1)', ''); > + } > + > + $self->SUPER::dispatch(@_); > +} > + > + > +=item ACTION_realclean > + > +Need to unlock the Build program before deleting. > + > +=cut > + > +sub ACTION_realclean { > + my $self = shift; > + chmod 666, $self->{properties}{build_script}; > + $self->SUPER::ACTION_realclean; > +} > + > + > +=back > + > =head1 AUTHOR > > -Ken Williams, ke...@fo... > +Michael G Schwern <sc...@po...> > > =head1 SEE ALSO |