diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-12-23 12:31:26 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-12-23 12:31:26 +0000 |
commit | 77e96e885c8deb2690714e0ea791a75cf23d46a9 (patch) | |
tree | 8d0f0130d172ba7eb0b40da301b07d5e53cd29a5 | |
parent | cf16741603085845f81fd648e5e3d2673dbdf560 (diff) | |
download | perl-77e96e885c8deb2690714e0ea791a75cf23d46a9.tar.gz |
Upgrade to Module::Build 0.2806
p4raw-id: //depot/perl@29615
31 files changed, 554 insertions, 209 deletions
@@ -1978,6 +1978,7 @@ lib/Module/Build/Authoring.pod Module::Build lib/Module/Build/Base.pm Module::Build lib/Module/Build/Changes Module::Build lib/Module/Build/Compat.pm Module::Build +lib/Module/Build/Config.pm Module::Build lib/Module/Build/ConfigData.pm Module::Build lib/Module/Build/Cookbook.pm Module::Build lib/Module/Build/ModuleInfo.pm Module::Build diff --git a/lib/Module/Build.pm b/lib/Module/Build.pm index 0ad0a92013..e945d6d92a 100644 --- a/lib/Module/Build.pm +++ b/lib/Module/Build.pm @@ -15,7 +15,7 @@ use Module::Build::Base; use vars qw($VERSION @ISA); @ISA = qw(Module::Build::Base); -$VERSION = '0.2805'; +$VERSION = '0.2806'; $VERSION = eval $VERSION; # Okay, this is the brute-force method of finding out what kind of @@ -46,6 +46,7 @@ my %OSTYPES = qw( sunos Unix cygwin Unix os2 Unix + interix Unix dos Windows MSWin32 Windows @@ -149,22 +150,23 @@ This illustrates initial configuration and the running of three 'actions'. In this case the actions run are 'build' (the default action), 'test', and 'install'. Other actions defined so far include: - build install - clean manifest - code manpages + build manifest + clean manpages + code pardist config_data ppd diff ppmdist dist prereq_report distcheck pure_install distclean realclean - distdir skipcheck - distmeta test - distsign testcover - disttest testdb - docs testpod - fakeinstall testpodcoverage - help versioninstall - html + distdir retest + distmeta skipcheck + distsign test + disttest testcover + docs testdb + fakeinstall testpod + help testpodcoverage + html versioninstall + install You can run the 'help' action for a complete list of actions. @@ -347,7 +349,7 @@ F<META.yml> file must also be listed in F<MANIFEST> - if it's not, a warning will be issued. The current version of the F<META.yml> specification can be found at -L<http://module-build.sourceforge.net/META-spec-v1.2.html> +L<http://module-build.sourceforge.net/META-spec-current.html> =item distsign @@ -466,6 +468,15 @@ also supply or override install paths by specifying there values on the command line with the C<bindoc> and C<libdoc> installation targets. +=item pardist + +[version 0.2806] + +Generates a PAR binary distribution for use with L<PAR> or L<PAR::Dist>. + +It requires that the PAR::Dist module (version 0.17 and up) is +installed on your system. + =item ppd [version 0.20] @@ -520,6 +531,17 @@ C<_build> directory and the C<Build> script. If you run the C<realclean> action, you are essentially starting over, so you will have to re-create the C<Build> script again. +=item retest + +[version 0.2806] + +This is just like the C<test> action, but doesn't actually build the +distribution first, and doesn't add F<blib/> to the load path, and +therefore will test against a I<previously> installed version of the +distribution. This can be used to verify that a certain installed +distribution still works, or to see whether newer versions of a +distribution still pass the old regression tests, and so on. + =item skipcheck [version 0.05] @@ -848,8 +870,7 @@ system, you'll install as follows: libhtml => /home/ken/html Note that this is I<different> from how MakeMaker's C<PREFIX> -parameter works. See L</"Why PREFIX is not recommended"> for more -details. C<install_base> just gives you a default layout under the +parameter works. C<install_base> just gives you a default layout under the directory you specify, which may have little to do with the C<installdirs=site> layout. @@ -998,7 +1019,7 @@ repository at <https://svn.perl.org/modules/Module-Build/trunk/> =head1 COPYRIGHT -Copyright (c) 2001-2005 Ken Williams. All rights reserved. +Copyright (c) 2001-2006 Ken Williams. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. @@ -1006,11 +1027,11 @@ modify it under the same terms as Perl itself. =head1 SEE ALSO -perl(1), L<Module::Build::Cookbook>(3), L<Module::Build::Authoring>(3), -L<Module::Build::API>(3), L<ExtUtils::MakeMaker>(3), L<YAML>(3) +perl(1), L<Module::Build::Cookbook>, L<Module::Build::Authoring>, +L<Module::Build::API>, L<ExtUtils::MakeMaker>, L<YAML> F<META.yml> Specification: -L<http://module-build.sourceforge.net/META-spec-v1.2.html> +L<http://module-build.sourceforge.net/META-spec-current.html> L<http://www.dsmit.com/cons/> diff --git a/lib/Module/Build/API.pod b/lib/Module/Build/API.pod index 1737d89149..88a602bfd4 100644 --- a/lib/Module/Build/API.pod +++ b/lib/Module/Build/API.pod @@ -715,6 +715,7 @@ C<*.t> in the F<t/> subdirectory. If the C<recursive_test_files> property is true, then the C<t/> directory will be scanned recursively for C<*.t> files. + =item xs_files [version 0.19] @@ -920,14 +921,24 @@ exotic stuff will likely cause problems. In the future, the guts of this method might be replaced with a call out to C<version.pm>. -=item config() +=item config($key) + +=item config($key, $value) + +=item config() [deprecated] [version 0.22] -Returns a hash reference containing the C<Config.pm> hash, including -any changes the author or user has specified. This is a reference to -the actual internal hash we use, so you probably shouldn't modify -stuff there. +With a single argument C<$key>, returns the value associated with that +key in the C<Config.pm> hash, including any changes the author or user +has specified. + +With C<$key> and C<$value> arguments, sets the value for future +callers of C<config($key)>. + +With no arguments, returns a hash reference containing all such +key-value pairs. This usage is deprecated, though, because it's a +resource hog and violates encapsulation. =item config_data($name) @@ -1548,8 +1559,6 @@ accessor methods for the following properties: =item c_source() -=item config() - =item config_dir() =item conflicts() @@ -1648,6 +1657,6 @@ perl(1), L<Module::Build>(3), L<Module::Build::Authoring>(3), L<Module::Build::Cookbook>(3), L<ExtUtils::MakeMaker>(3), L<YAML>(3) F<META.yml> Specification: -L<http://module-build.sourceforge.net/META-spec-v1.2.html> +L<http://module-build.sourceforge.net/META-spec-current.html> =cut diff --git a/lib/Module/Build/Authoring.pod b/lib/Module/Build/Authoring.pod index e9bbceba01..b0b7f373c9 100644 --- a/lib/Module/Build/Authoring.pod +++ b/lib/Module/Build/Authoring.pod @@ -274,7 +274,7 @@ perl(1), L<Module::Build>(3), L<Module::Build::API>(3), L<Module::Build::Cookbook>(3), L<ExtUtils::MakeMaker>(3), L<YAML>(3) F<META.yml> Specification: -L<http://module-build.sourceforge.net/META-spec-v1.2.html> +L<http://module-build.sourceforge.net/META-spec-current.html> L<http://www.dsmit.com/cons/> diff --git a/lib/Module/Build/Base.pm b/lib/Module/Build/Base.pm index 67d2ac08ba..76a6634d64 100644 --- a/lib/Module/Build/Base.pm +++ b/lib/Module/Build/Base.pm @@ -17,6 +17,7 @@ use Text::ParseWords (); use Module::Build::ModuleInfo; use Module::Build::Notes; +use Module::Build::Config; #################### Constructors ########################### @@ -113,7 +114,7 @@ sub _construct { my $self = bless { args => {%$args}, - config => {%Config, %$config}, + config => Module::Build::Config->new(values => $config), properties => { base_dir => $package->cwd, mb_version => $Module::Build::VERSION, @@ -123,7 +124,7 @@ sub _construct { }, $package; $self->_set_defaults; - my ($p, $c, $ph) = ($self->{properties}, $self->{config}, $self->{phash}); + my ($p, $ph) = ($self->{properties}, $self->{phash}); foreach (qw(notes config_data features runtime_params cleanup auto_features)) { my $file = File::Spec->catfile($self->config_dir, $_); @@ -184,62 +185,62 @@ sub log_warn { sub _set_install_paths { my $self = shift; - my $c = $self->config; + my $c = $self->{config}; my $p = $self->{properties}; - my @libstyle = $c->{installstyle} ? - File::Spec->splitdir($c->{installstyle}) : qw(lib perl5); - my $arch = $c->{archname}; - my $version = $c->{version}; + my @libstyle = $c->get('installstyle') ? + File::Spec->splitdir($c->get('installstyle')) : qw(lib perl5); + my $arch = $c->get('archname'); + my $version = $c->get('version'); - my $bindoc = $c->{installman1dir} || undef; - my $libdoc = $c->{installman3dir} || undef; + my $bindoc = $c->get('installman1dir') || undef; + my $libdoc = $c->get('installman3dir') || undef; - my $binhtml = $c->{installhtml1dir} || $c->{installhtmldir} || undef; - my $libhtml = $c->{installhtml3dir} || $c->{installhtmldir} || undef; + my $binhtml = $c->get('installhtml1dir') || $c->get('installhtmldir') || undef; + my $libhtml = $c->get('installhtml3dir') || $c->get('installhtmldir') || undef; $p->{install_sets} = { core => { - lib => $c->{installprivlib}, - arch => $c->{installarchlib}, - bin => $c->{installbin}, - script => $c->{installscript}, + lib => $c->get('installprivlib'), + arch => $c->get('installarchlib'), + bin => $c->get('installbin'), + script => $c->get('installscript'), bindoc => $bindoc, libdoc => $libdoc, binhtml => $binhtml, libhtml => $libhtml, }, site => { - lib => $c->{installsitelib}, - arch => $c->{installsitearch}, - bin => $c->{installsitebin} || $c->{installbin}, - script => $c->{installsitescript} || - $c->{installsitebin} || $c->{installscript}, - bindoc => $c->{installsiteman1dir} || $bindoc, - libdoc => $c->{installsiteman3dir} || $libdoc, - binhtml => $c->{installsitehtml1dir} || $binhtml, - libhtml => $c->{installsitehtml3dir} || $libhtml, + lib => $c->get('installsitelib'), + arch => $c->get('installsitearch'), + bin => $c->get('installsitebin') || $c->get('installbin'), + script => $c->get('installsitescript') || + $c->get('installsitebin') || $c->get('installscript'), + bindoc => $c->get('installsiteman1dir') || $bindoc, + libdoc => $c->get('installsiteman3dir') || $libdoc, + binhtml => $c->get('installsitehtml1dir') || $binhtml, + libhtml => $c->get('installsitehtml3dir') || $libhtml, }, vendor => { - lib => $c->{installvendorlib}, - arch => $c->{installvendorarch}, - bin => $c->{installvendorbin} || $c->{installbin}, - script => $c->{installvendorscript} || - $c->{installvendorbin} || $c->{installscript}, - bindoc => $c->{installvendorman1dir} || $bindoc, - libdoc => $c->{installvendorman3dir} || $libdoc, - binhtml => $c->{installvendorhtml1dir} || $binhtml, - libhtml => $c->{installvendorhtml3dir} || $libhtml, + lib => $c->get('installvendorlib'), + arch => $c->get('installvendorarch'), + bin => $c->get('installvendorbin') || $c->get('installbin'), + script => $c->get('installvendorscript') || + $c->get('installvendorbin') || $c->get('installscript'), + bindoc => $c->get('installvendorman1dir') || $bindoc, + libdoc => $c->get('installvendorman3dir') || $libdoc, + binhtml => $c->get('installvendorhtml1dir') || $binhtml, + libhtml => $c->get('installvendorhtml3dir') || $libhtml, }, }; $p->{original_prefix} = { - core => $c->{installprefixexp} || $c->{installprefix} || - $c->{prefixexp} || $c->{prefix} || '', - site => $c->{siteprefixexp}, - vendor => $c->{usevendorprefix} ? $c->{vendorprefixexp} : '', + core => $c->get('installprefixexp') || $c->get('installprefix') || + $c->get('prefixexp') || $c->get('prefix') || '', + site => $c->get('siteprefixexp'), + vendor => $c->get('usevendorprefix') ? $c->get('vendorprefixexp') : '', }; $p->{original_prefix}{site} ||= $p->{original_prefix}{core}; @@ -346,7 +347,7 @@ sub _backticks { my ($self, @cmd) = @_; if ($self->have_forkpipe) { local *FH; - my $pid = open FH, "-|"; + my $pid = open *FH, "-|"; if ($pid) { return wantarray ? <FH> : join '', <FH>; } else { @@ -394,7 +395,7 @@ sub _perl_is_same { # invoking the wrong perl. sub find_perl_interpreter { my $proto = shift; - my $c = ref($proto) ? $proto->config : \%Config::Config; + my $c = ref($proto) ? $proto->{config} : 'Module::Build::Config'; my $perl = $^X; my $perl_basename = File::Basename::basename($perl); @@ -433,7 +434,7 @@ sub find_perl_interpreter { # PATH. We do not want to do either if we are running from an # uninstalled perl in a perl source tree. - push( @potential_perls, $c->{perlpath} ); + push( @potential_perls, $c->get('perlpath') ); push( @potential_perls, map File::Spec->catfile($_, $perl_basename), File::Spec->path() ); @@ -442,7 +443,7 @@ sub find_perl_interpreter { # Now that we've enumerated the potential perls, it's time to test # them to see if any of them match our configuration, returning the # absolute path of the first successful match. - my $exe = $c->{exe_ext}; + my $exe = $c->get('exe_ext'); foreach my $thisperl ( @potential_perls ) { if ($proto->os_type eq 'VMS') { @@ -683,7 +684,7 @@ sub ACTION_config_data { if ( $type eq 'HASH' ) { *{"$class\::$property"} = sub { my $self = shift; - my $x = ( $property eq 'config' ) ? $self : $self->{properties}; + my $x = $self->{properties}; return $x->{$property} unless @_; if ( defined($_[0]) && !ref($_[0]) ) { @@ -759,6 +760,7 @@ __PACKAGE__->add_property(recurse_into => []); __PACKAGE__->add_property(use_rcfile => 1); __PACKAGE__->add_property(create_packlist => 1); __PACKAGE__->add_property(allow_mb_mismatch => 0); +__PACKAGE__->add_property(config => undef); { my $Is_ActivePerl = eval {require ActivePerl::DocTools}; @@ -774,7 +776,6 @@ __PACKAGE__->add_property(allow_mb_mismatch => 0); } __PACKAGE__->add_property($_ => {}) for qw( - config get_options install_base_relpaths install_path @@ -824,6 +825,17 @@ __PACKAGE__->add_property($_) for qw( xs_files ); +sub config { + my $self = shift; + my $c = ref($self) ? $self->{config} : 'Module::Build::Config'; + return $c->all_config unless @_; + + my $key = shift; + return $c->get($key) unless @_; + + my $val = shift; + return $c->set($key => $val); +} sub mb_parents { # Code borrowed from Class::ISA. @@ -1000,7 +1012,9 @@ sub read_config { my $fh = IO::File->new($file) or die "Can't read '$file': $!"; my $ref = eval do {local $/; <$fh>}; die if $@; - ($self->{args}, $self->{config}, $self->{properties}) = @$ref; + my $c; + ($self->{args}, $c, $self->{properties}) = @$ref; + $self->{config} = Module::Build::Config->new(values => $c); close $fh; } @@ -1026,7 +1040,7 @@ sub write_config { my @items = @{ $self->prereq_action_types }; $self->_write_data('prereqs', { map { $_, $self->$_() } @items }); - $self->_write_data('build_params', [$self->{args}, $self->{config}, $self->{properties}]); + $self->_write_data('build_params', [$self->{args}, $self->{config}->values_set, $self->{properties}]); # Set a new magic number and write it to a file $self->_write_data('magicnum', $self->magic_number(int rand 1_000_000)); @@ -1127,7 +1141,8 @@ sub check_prereq { my $xs_files = $self->find_xs_files; if (keys %$xs_files && !$self->_mb_feature('C_support')) { $self->log_warn("Warning: this distribution contains XS files, ". - "but Module::Build is not configured with C_support"); + "but Module::Build is not configured with C_support. ". + "Please install ExtUtils::CBuilder to enable C_support.\n"); } # Check to see if there are any prereqs to check @@ -1269,7 +1284,7 @@ sub make_executable { my $self = shift; foreach (@_) { my $current_mode = (stat $_)[2]; - chmod $current_mode | 0111, $_; + chmod $current_mode | oct(111), $_; } } @@ -1618,7 +1633,7 @@ sub read_args { $args{ARGV} = \@argv; # Hashify these parameters - for ($self->hash_properties) { + for ($self->hash_properties, 'config') { next unless exists $args{$_}; my %hash; $args{$_} ||= []; @@ -1664,9 +1679,7 @@ sub read_args { sub _detildefy { my $arg = shift; - my($new_arg) = glob($arg) if $arg =~ /^~/; - - return defined($new_arg) ? $new_arg : $arg; + return $arg =~ /^~/ ? (glob $arg)[0] : $arg; } @@ -1794,15 +1807,19 @@ sub merge_args { while (my ($key, $val) = each %args) { $self->{phash}{runtime_params}->access( $key => $val ) if $self->valid_property($key); - my $add_to = ( $key eq 'config' ? $self->{config} - : $additive{$key} ? $self->{properties}{$key} - : $self->valid_property($key) ? $self->{properties} - : $self->{args}); - if ($additive{$key}) { - $add_to->{$_} = $val->{$_} foreach keys %$val; + if ($key eq 'config') { + $self->config($_ => $val->{$_}) foreach keys %$val; } else { - $add_to->{$key} = $val; + my $add_to = ( $additive{$key} ? $self->{properties}{$key} + : $self->valid_property($key) ? $self->{properties} + : $self->{args}); + + if ($additive{$key}) { + $add_to->{$_} = $val->{$_} foreach keys %$val; + } else { + $add_to->{$key} = $val; + } } } } @@ -1983,13 +2000,45 @@ sub _action_listing { return $out; } +sub ACTION_retest { + my ($self) = @_; + + # Protect others against our @INC changes + local @INC = @INC; + + # Filter out nonsensical @INC entries - some versions of + # Test::Harness will really explode the number of entries here + @INC = grep {ref() || -d} @INC if @INC > 100; + + $self->do_tests; +} + + sub ACTION_test { my ($self) = @_; my $p = $self->{properties}; - require Test::Harness; $self->depends_on('code'); + # Protect others against our @INC changes + local @INC = @INC; + + # Make sure we test the module in blib/ + unshift @INC, (File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'), + File::Spec->catdir($p->{base_dir}, $self->blib, 'arch')); + + # Filter out nonsensical @INC entries - some versions of + # Test::Harness will really explode the number of entries here + @INC = grep {ref() || -d} @INC if @INC > 100; + + $self->do_tests; +} + +sub do_tests { + my $self = shift; + my $p = $self->{properties}; + require Test::Harness; + # Do everything in our power to work with all versions of Test::Harness my @harness_switches = $p->{debugger} ? qw(-w -d) : (); local $Test::Harness::switches = join ' ', grep defined, $Test::Harness::switches, @harness_switches; @@ -2005,15 +2054,6 @@ sub ACTION_test { $ENV{TEST_VERBOSE}, $ENV{HARNESS_VERBOSE}) = ($p->{verbose} || 0) x 4; - # Make sure we test the module in blib/ - local @INC = (File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'), - File::Spec->catdir($p->{base_dir}, $self->blib, 'arch'), - @INC); - - # Filter out nonsensical @INC entries - some versions of - # Test::Harness will really explode the number of entries here - @INC = grep {ref() || -d} @INC if @INC > 100; - my $tests = $self->find_test_files; if (@$tests) { @@ -2071,7 +2111,8 @@ sub ACTION_testcover { my $cover_files = $self->rscan_dir('cover_db', sub {-f $_ and not /\.html$/}); $self->do_system(qw(cover -delete)) - unless $self->up_to_date($pm_files, $cover_files); + unless $self->up_to_date($pm_files, $cover_files) + && $self->up_to_date($self->test_files, $cover_files); } local $Test::Harness::switches = @@ -2269,9 +2310,9 @@ sub localize_dir_path { sub fix_shebang_line { # Adapted from fixin() in ExtUtils::MM_Unix 1.35 my ($self, @files) = @_; - my $c = $self->config; + my $c = ref($self) ? $self->{config} : 'Module::Build::Config'; - my ($does_shbang) = $c->{sharpbang} =~ /^\s*\#\!/; + my ($does_shbang) = $c->get('sharpbang') =~ /^\s*\#\!/; for my $file (@files) { my $FIXIN = IO::File->new($file) or die "Can't process '$file': $!"; local $/ = "\n"; @@ -2284,7 +2325,7 @@ sub fix_shebang_line { # Adapted from fixin() in ExtUtils::MM_Unix 1.35 $self->log_verbose("Changing sharpbang in $file to $interpreter"); my $shb = ''; - $shb .= "$c->{sharpbang}$interpreter $arg\n" if $does_shbang; + $shb .= $c->get('sharpbang')."$interpreter $arg\n" if $does_shbang; # I'm not smart enough to know the ramifications of changing the # embedded newlines here to \n, so I leave 'em in. @@ -2312,7 +2353,7 @@ eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}' unlink "$file.bak" or $self->log_warn("Couldn't clean up $file.bak, leaving it there"); - $self->do_system($c->{eunicefix}, $file) if $c->{eunicefix} ne ':'; + $self->do_system($c->get('eunicefix'), $file) if $c->get('eunicefix') ne ':'; } } @@ -2398,7 +2439,7 @@ sub manify_bin_pods { return unless keys %$files; my $mandir = File::Spec->catdir( $self->blib, 'bindoc' ); - File::Path::mkpath( $mandir, 0, 0777 ); + File::Path::mkpath( $mandir, 0, oct(777) ); require Pod::Man; foreach my $file (keys %$files) { @@ -2422,7 +2463,7 @@ sub manify_lib_pods { return unless keys %$files; my $mandir = File::Spec->catdir( $self->blib, 'libdoc' ); - File::Path::mkpath( $mandir, 0, 0777 ); + File::Path::mkpath( $mandir, 0, oct(777) ); require Pod::Man; while (my ($file, $relfile) = each %$files) { @@ -2508,7 +2549,7 @@ sub htmlify_pods { return unless %$pods; # nothing to do unless ( -d $htmldir ) { - File::Path::mkpath($htmldir, 0, 0755) + File::Path::mkpath($htmldir, 0, oct(755)) or die "Couldn't mkdir $htmldir: $!"; } @@ -2535,7 +2576,7 @@ sub htmlify_pods { next if $self->up_to_date($infile, $outfile); unless ( -d $fulldir ){ - File::Path::mkpath($fulldir, 0, 0755) + File::Path::mkpath($fulldir, 0, oct(755)) or die "Couldn't mkdir $fulldir: $!"; } @@ -2754,6 +2795,26 @@ sub ACTION_ppmdist { $self->delete_filetree( $ppm ); } +sub ACTION_pardist { + my ($self) = @_; + + # Need PAR::Dist + if ( not eval { require PAR::Dist; PAR::Dist->VERSION(0.17) } ) { + $self->log_warn( + "In order to create .par distributions, you need to\n" + . "install PAR::Dist first." + ); + return(); + } + + $self->depends_on( 'build' ); + + return PAR::Dist::blib_to_par( + name => $self->dist_name, + version => $self->dist_version, + ); +} + sub ACTION_dist { my ($self) = @_; @@ -2793,7 +2854,7 @@ sub _add_to_manifest { or return; my $mode = (stat $manifest)[2]; - chmod($mode | 0222, $manifest) or die "Can't make $manifest writable: $!"; + chmod($mode | oct(222), $manifest) or die "Can't make $manifest writable: $!"; my $fh = IO::File->new("< $manifest") or die "Can't read $manifest: $!"; my $last_line = (<$fh>)[-1] || "\n"; @@ -3384,9 +3445,9 @@ sub find_dist_packages { } } - # Stringify versions - for (grep exists $_->{version}, values %prime) { - $_->{version} = $_->{version}->stringify; + # Stringify versions. Can't use exists() here because of bug in YAML::Node. + for (grep defined $_->{version}, values %prime) { + $_->{version} = '' . $_->{version}; } return \%prime; @@ -3802,10 +3863,10 @@ sub compile_xs { } @typemaps = map {+'-typemap', $_} @typemaps; - my $cf = $self->config; + my $cf = $self->{config}; my $perl = $self->{properties}{perl}; - my @command = ($perl, "-I$cf->{installarchlib}", "-I$cf->{installprivlib}", $xsubpp, '-noprototypes', + my @command = ($perl, "-I".$cf->get('installarchlib'), "-I".$cf->get('installprivlib'), $xsubpp, '-noprototypes', @typemaps, $file); $self->log_info("@command\n"); @@ -3839,12 +3900,10 @@ sub run_perl_command { # this before documenting. my ($self, $args) = @_; $args = [ $self->split_like_shell($args) ] unless ref($args); - $args = [ split(/\s+/, $self->_quote_args($args)) ] if $self->os_type eq 'VMS'; my $perl = ref($self) ? $self->perl : $self->find_perl_interpreter; # Make sure our local additions to @INC are propagated to the subprocess - my $c = ref $self ? $self->config : \%Config::Config; - local $ENV{PERL5LIB} = join $c->{path_sep}, $self->_added_to_INC; + local $ENV{PERL5LIB} = join $self->config('path_sep'), $self->_added_to_INC; return $self->do_system($perl, @$args); } @@ -3880,20 +3939,19 @@ sub _infer_xs_spec { $spec{bs_file} = File::Spec->catfile($spec{archdir}, "${file_base}.bs"); $spec{lib_file} = File::Spec->catfile($spec{archdir}, - "${file_base}.$cf->{dlext}"); + "${file_base}.".$cf->get('dlext')); $spec{c_file} = File::Spec->catfile( $spec{src_dir}, "${file_base}.c" ); $spec{obj_file} = File::Spec->catfile( $spec{src_dir}, - "${file_base}$cf->{obj_ext}" ); + "${file_base}".$cf->get('obj_ext') ); return \%spec; } sub process_xs { my ($self, $file) = @_; - my $cf = $self->config; # For convenience my $spec = $self->_infer_xs_spec($file); @@ -3913,7 +3971,7 @@ sub process_xs { defines => {VERSION => qq{"$v"}, XS_VERSION => qq{"$v"}}); # archdir - File::Path::mkpath($spec->{archdir}, 0, 0777) unless -d $spec->{archdir}; + File::Path::mkpath($spec->{archdir}, 0, oct(777)) unless -d $spec->{archdir}; # .xs -> .bs $self->add_to_cleanup($spec->{bs_file}); @@ -3932,6 +3990,16 @@ sub process_xs { sub do_system { my ($self, @cmd) = @_; $self->log_info("@cmd\n"); + + # Some systems proliferate huge PERL5LIBs, try to ameliorate: + my %seen; + my $sep = $self->config('path_sep'); + local $ENV{PERL5LIB} = + ( length($ENV{PERL5LIB}) < 500 + ? $ENV{PERL5LIB} + : join $sep, grep { ! $seen{$_}++ and -d $_ } split($sep, $ENV{PERL5LIB}) + ); + my $status = system(@cmd); if ($status and $! =~ /Argument list too long/i) { my $env_entries = ''; @@ -3968,15 +4036,18 @@ sub copy_if_modified { return if $self->up_to_date($file, $to_path); # Already fresh - $self->delete_filetree($to_path); # delete destination if exists + { + local $self->{properties}{quiet} = 1; + $self->delete_filetree($to_path); # delete destination if exists + } # Create parent directories - File::Path::mkpath(File::Basename::dirname($to_path), 0, 0777); + File::Path::mkpath(File::Basename::dirname($to_path), 0, oct(777)); - $self->log_info("$file -> $to_path\n") if $args{verbose}; + $self->log_info("Copying $file -> $to_path\n") if $args{verbose}; File::Copy::copy($file, $to_path) or die "Can't copy('$file', '$to_path'): $!"; # mode is read-only + (executable if source is executable) - my $mode = 0444 | ( $self->is_executable($file) ? 0111 : 0 ); + my $mode = oct(444) | ( $self->is_executable($file) ? oct(111) : 0 ); chmod( $mode, $to_path ); return $to_path; @@ -4052,11 +4123,11 @@ Please see the C<Module::Build> documentation for more details. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 COPYRIGHT -Copyright (c) 2001-2005 Ken Williams. All rights reserved. +Copyright (c) 2001-2006 Ken Williams. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Module/Build/Changes b/lib/Module/Build/Changes index f7b14badf7..14407d4c04 100644 --- a/lib/Module/Build/Changes +++ b/lib/Module/Build/Changes @@ -1,5 +1,64 @@ Revision history for Perl extension Module::Build. + - On some systems (haven't identified the actual problem yet) + $ENV{PERL5LIB} can grow to enormous enough sizes that we can't + launch any more subprocesses because the environment table is full. + This is the now-infamous "Couldn't run Build.PL: Argument list too + long" error. Now we detect such situations and trim the directory + list to only include directories that actually exist, listed only + once each. Not the ideal solution, but it should work. + + - Silence a warning in M::B::ModuleInfo that happens when the author + is using the "$VERSION = eval $VERSION" idiom. + + - When running the 'testcover' action, do "cover --delete" if any of + the test files have changed (we already did so if any of the code + under test has changed). [Suggested by Chris Dolan, RT #23584] + + - Fixed a broken link in the documentation about PREFIX. [Spotted by + David Steinbrunner] + + - Changes to do_system() & friends on VMS to get system calls working + much better there. [Craig Berry] + + - Added the "pardist" target which creates a PAR binary distribution + akin to a PPM distribution. [Steffen Mueller] + + - Added the Interix platform as a Unix variant. [Stephen Hartland] + + - Improved the error message we emit when a distribution contains XS + files but the user has no C compiler. [Suggested by Andreas Koenig] + +0.2805_01 Thu Sep 7 21:57:29 CDT 2006 + + - Because of a weird behavior of YAML::Node, any distribution that + used version.pm objects to define their versions was generating the + wrong syntax for the versions in their META.yml file. They will + now appear as strings like v3.42.1 or similar, including the + leading v. + + - Upgraded to version 0.67 of version.pm. [John Peacock] + + - Added a contrib/ directory with a bash completion function for M::B + actions and switches. [Julian Mehnle] + + - When we eval() the embedded version.pm code we will now die() if + the eval() was unsuccessful, rather than continuing blindly on and + dying mysteriously later. + + - Added a 'retest' action that lets users run the current regression + tests on a previously-installed version of a distribution. + + * Instead of storing an entire dump of the Config.pm hash in the + _build/ directory upon startup, we now just store any overrides the + user or author has specified. Note that if you were doing anything + you weren't supposed to be doing, like poking around in the + internals of $buld->{config}, your code might break, so I've put + the asterisk of incompatibility on this one just to cover my + tuchus. [Idea originally by Randy Sims] + + - Made copying files via copy_if_modified() a little less chatty. + 0.2805 Sat Jul 29 22:01:24 CDT 2006 - We now embed a copy of version.pm right in the diff --git a/lib/Module/Build/Compat.pm b/lib/Module/Build/Compat.pm index c573cc568f..aea19605ae 100644 --- a/lib/Module/Build/Compat.pm +++ b/lib/Module/Build/Compat.pm @@ -434,12 +434,12 @@ versions of tools like CPAN and CPANPLUS. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 COPYRIGHT -Copyright (c) 2001-2005 Ken Williams. All rights reserved. +Copyright (c) 2001-2006 Ken Williams. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Module/Build/Config.pm b/lib/Module/Build/Config.pm new file mode 100644 index 0000000000..ccf58d90b9 --- /dev/null +++ b/lib/Module/Build/Config.pm @@ -0,0 +1,56 @@ +package Module::Build::Config; + +use strict; +use Config; + +sub new { + my ($pack, %args) = @_; + return bless { + stack => {}, + values => $args{values} || {}, + }, $pack; +} + +sub get { + my ($self, $key) = @_; + return $self->{values}{$key} if ref($self) && exists $self->{values}{$key}; + return $Config{$key}; +} + +sub set { + my ($self, $key, $val) = @_; + $self->{values}{$key} = $val; +} + +sub push { + my ($self, $key, $val) = @_; + push @{$self->{stack}{$key}}, $self->{values}{$key} + if exists $self->{values}{$key}; + $self->{values}{$key} = $val; +} + +sub pop { + my ($self, $key) = @_; + + my $val = delete $self->{values}{$key}; + if ( exists $self->{stack}{$key} ) { + $self->{values}{$key} = pop @{$self->{stack}{$key}}; + delete $self->{stack}{$key} unless @{$self->{stack}{$key}}; + } + + return $val; +} + +sub values_set { + my $self = shift; + return undef unless ref($self); + return $self->{values}; +} + +sub all_config { + my $self = shift; + my $v = ref($self) ? $self->{values} : {}; + return {%Config, %$v}; +} + +1; diff --git a/lib/Module/Build/Cookbook.pm b/lib/Module/Build/Cookbook.pm index 6439b05ac0..03341fa653 100644 --- a/lib/Module/Build/Cookbook.pm +++ b/lib/Module/Build/Cookbook.pm @@ -415,12 +415,12 @@ complete documentation on this. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 COPYRIGHT -Copyright (c) 2001-2005 Ken Williams. All rights reserved. +Copyright (c) 2001-2006 Ken Williams. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Module/Build/ModuleInfo.pm b/lib/Module/Build/ModuleInfo.pm index 5021ef1371..0a053590da 100644 --- a/lib/Module/Build/ModuleInfo.pm +++ b/lib/Module/Build/ModuleInfo.pm @@ -163,6 +163,12 @@ sub _parse_file { my $fh = IO::File->new( $filename ) or die( "Can't open '$filename': $!" ); + $self->_parse_fh($fh); +} + +sub _parse_fh { + my ($self, $fh) = @_; + my( $in_pod, $seen_end, $need_vers ) = ( 0, 0, 0 ); my( @pkgs, %vers, %pod, @pod ); my $pkg = 'main'; @@ -215,14 +221,16 @@ sub _parse_file { push( @pkgs, $vers_pkg ) unless grep( $vers_pkg eq $_, @pkgs ); $need_vers = 0 if $vers_pkg eq $pkg; - my $v = - $self->_evaluate_version_line( $vers_sig, $vers_fullname, $line ); unless ( defined $vers{$vers_pkg} && length $vers{$vers_pkg} ) { - $vers{$vers_pkg} = $v; + $vers{$vers_pkg} = + $self->_evaluate_version_line( $vers_sig, $vers_fullname, $line ); } else { - warn <<"EOM"; -Package '$vers_pkg' already declared with version '$vers{$vers_pkg}' -ignoring new version '$v'. + # Warn unless the user is using the "$VERSION = eval + # $VERSION" idiom (though there are probably other idioms + # that we should watch out for...) + warn <<"EOM" unless $line =~ /=\s*eval/; +Package '$vers_pkg' already declared with version '$vers{$vers_pkg}', +ignoring subsequent declaration. EOM } @@ -416,12 +424,12 @@ Can be called as either an object or a class method. =head1 AUTHOR -Ken Williams <ken@cpan.org>, Randy W. Sims <RandyS@ThePierianSpring.org> +Ken Williams <kwilliams@cpan.org>, Randy W. Sims <RandyS@ThePierianSpring.org> =head1 COPYRIGHT -Copyright (c) 2001-2005 Ken Williams. All rights reserved. +Copyright (c) 2001-2006 Ken Williams. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Module/Build/PPMMaker.pm b/lib/Module/Build/PPMMaker.pm index eb3e5403d8..07c77b8a72 100644 --- a/lib/Module/Build/PPMMaker.pm +++ b/lib/Module/Build/PPMMaker.pm @@ -173,12 +173,12 @@ L<http://aspn.activestate.com/ASPN/Downloads/ActivePerl/PPM/> =head1 AUTHOR -Dave Rolsky <autarch@urth.org>, Ken Williams <ken@cpan.org> +Dave Rolsky <autarch@urth.org>, Ken Williams <kwilliams@cpan.org> =head1 COPYRIGHT -Copyright (c) 2001-2005 Ken Williams. All rights reserved. +Copyright (c) 2001-2006 Ken Williams. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Module/Build/Platform/Amiga.pm b/lib/Module/Build/Platform/Amiga.pm index 55d87e51c4..34671a5c89 100644 --- a/lib/Module/Build/Platform/Amiga.pm +++ b/lib/Module/Build/Platform/Amiga.pm @@ -22,7 +22,7 @@ C<Module::Build::Base>. Please see the L<Module::Build> for the docs. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Platform/Default.pm b/lib/Module/Build/Platform/Default.pm index 1820378d95..c60e21cd42 100644 --- a/lib/Module/Build/Platform/Default.pm +++ b/lib/Module/Build/Platform/Default.pm @@ -21,7 +21,7 @@ C<Module::Build::Base>. Please see the L<Module::Build> for the docs. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Platform/EBCDIC.pm b/lib/Module/Build/Platform/EBCDIC.pm index 6031bfea6e..1c9094aad1 100644 --- a/lib/Module/Build/Platform/EBCDIC.pm +++ b/lib/Module/Build/Platform/EBCDIC.pm @@ -22,7 +22,7 @@ C<Module::Build::Base>. Please see the L<Module::Build> for the docs. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Platform/MPEiX.pm b/lib/Module/Build/Platform/MPEiX.pm index 66062f4f44..af3fdf2d22 100644 --- a/lib/Module/Build/Platform/MPEiX.pm +++ b/lib/Module/Build/Platform/MPEiX.pm @@ -22,7 +22,7 @@ C<Module::Build::Base>. Please see the L<Module::Build> for the docs. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Platform/MacOS.pm b/lib/Module/Build/Platform/MacOS.pm index 7927cca6f0..1ba1cf2e0d 100644 --- a/lib/Module/Build/Platform/MacOS.pm +++ b/lib/Module/Build/Platform/MacOS.pm @@ -14,11 +14,14 @@ sub new { my $self = $class->SUPER::new(@_); # $Config{sitelib} and $Config{sitearch} are, unfortunately, missing. - $self->{config}{sitelib} ||= $self->{config}{installsitelib}; - $self->{config}{sitearch} ||= $self->{config}{installsitearch}; + foreach ('sitelib', 'sitearch') { + $self->config($_ => $self->config("install$_")) + unless $self->config($_); + } # For some reason $Config{startperl} is filled with a bunch of crap. - $self->{config}{startperl} =~ s/.*Exit \{Status\}\s//; + (my $sp = $self->config('startperl')) =~ s/.*Exit \{Status\}\s//; + $self->config(startperl => $sp); return $self; } diff --git a/lib/Module/Build/Platform/RiscOS.pm b/lib/Module/Build/Platform/RiscOS.pm index 5784036ee0..3fec45307a 100644 --- a/lib/Module/Build/Platform/RiscOS.pm +++ b/lib/Module/Build/Platform/RiscOS.pm @@ -22,7 +22,7 @@ C<Module::Build::Base>. Please see the L<Module::Build> for the docs. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Platform/Unix.pm b/lib/Module/Build/Platform/Unix.pm index 18b68555a5..214a33b591 100644 --- a/lib/Module/Build/Platform/Unix.pm +++ b/lib/Module/Build/Platform/Unix.pm @@ -54,7 +54,7 @@ C<Module::Build::Base>. Please see the L<Module::Build> for the docs. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Platform/VMS.pm b/lib/Module/Build/Platform/VMS.pm index 7bc81f8d73..7a2b7c56c1 100644 --- a/lib/Module/Build/Platform/VMS.pm +++ b/lib/Module/Build/Platform/VMS.pm @@ -22,19 +22,17 @@ the general docs. =over 4 -=item new +=item _set_defaults Change $self->{build_script} to 'Build.com' so @Build works. =cut -sub new { - my $class = shift; - my $self = $class->SUPER::new(@_); +sub _set_defaults { + my $self = shift; + $self->SUPER::_set_defaults(@_); $self->{properties}{build_script} = 'Build.com'; - - return $self; } @@ -100,7 +98,7 @@ sub _prefixify { } else { my($path_vol, $path_dirs) = File::Spec->splitpath( $path ); - my $vms_prefix = $self->config->{vms_prefix}; + my $vms_prefix = $self->config('vms_prefix'); if( $path_vol eq $vms_prefix.':' ) { $self->log_verbose(" $vms_prefix: seen\n"); @@ -118,26 +116,98 @@ sub _prefixify { return $path; } +=item _quote_args + +Command-line arguments (but not the command itself) must be quoted +to ensure case preservation. + +=cut sub _quote_args { # Returns a string that can become [part of] a command line with - # proper quoting so that the subprocess sees this same list of args. + # proper quoting so that the subprocess sees this same list of args, + # or if we get a single arg that is an array reference, quote the + # elements of it and return the reference. my ($self, @args) = @_; - - my $return_args = ''; - for (@args) { - $return_args .= q( ").$_.q(") if !/^\"/ && length($_) > 0; - } - return $return_args; + my $got_arrayref = (scalar(@args) == 1 + && UNIVERSAL::isa($args[0], 'ARRAY')) + ? 1 + : 0; + + map { $_ = q(").$_.q(") if !/^\"/ && length($_) > 0 } + ($got_arrayref ? @{$args[0]} + : @args + ); + + return $got_arrayref ? $args[0] + : join(' ', @args); } +=item have_forkpipe + +There is no native fork(), so some constructs depending on it are not +available. + +=cut + sub have_forkpipe { 0 } +=item _backticks + +Override to ensure that we quote the arguments but not the command. + +=cut + +sub _backticks { + # The command must not be quoted but the arguments to it must be. + my ($self, @cmd) = @_; + my $cmd = shift @cmd; + my $args = $self->_quote_args(@cmd); + return `$cmd $args`; +} + +=item do_system + +Override to ensure that we quote the arguments but not the command. + +=cut + +sub do_system { + # The command must not be quoted but the arguments to it must be. + my ($self, @cmd) = @_; + $self->log_info("@cmd\n"); + my $cmd = shift @cmd; + my $args = $self->_quote_args(@cmd); + return !system("$cmd $args"); +} + +=item _infer_xs_spec + +Inherit the standard version but tweak the library file name to be +something Dynaloader can find. + +=cut + +sub _infer_xs_spec { + my $self = shift; + my $file = shift; + + my $spec = $self->SUPER::_infer_xs_spec($file); + + # Need to create with the same name as DynaLoader will load with. + if (defined &DynaLoader::mod2fname) { + my $file = DynaLoader::mod2fname([$$spec{base_name}]); + $$spec{lib_file} = File::Spec->catfile($$spec{archdir}, "$file.$self->{config}->{dlext}"); + } + + return $spec; +} + =back =head1 AUTHOR -Michael G Schwern <schwern@pobox.com>, Ken Williams <ken@cpan.org> +Michael G Schwern <schwern@pobox.com>, Ken Williams <kwilliams@cpan.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Platform/VOS.pm b/lib/Module/Build/Platform/VOS.pm index 523f888de3..2bd5f79a3c 100644 --- a/lib/Module/Build/Platform/VOS.pm +++ b/lib/Module/Build/Platform/VOS.pm @@ -22,7 +22,7 @@ C<Module::Build::Base>. Please see the L<Module::Build> for the docs. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Platform/Windows.pm b/lib/Module/Build/Platform/Windows.pm index 774db99d65..2cc3ffd950 100644 --- a/lib/Module/Build/Platform/Windows.pm +++ b/lib/Module/Build/Platform/Windows.pm @@ -239,7 +239,7 @@ L<Module::Build> for the docs. =head1 AUTHOR -Ken Williams <ken@cpan.org>, Randy W. Sims <RandyS@ThePierianSpring.org> +Ken Williams <kwilliams@cpan.org>, Randy W. Sims <RandyS@ThePierianSpring.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Platform/aix.pm b/lib/Module/Build/Platform/aix.pm index c166309e89..983b25d067 100644 --- a/lib/Module/Build/Platform/aix.pm +++ b/lib/Module/Build/Platform/aix.pm @@ -28,7 +28,7 @@ Please see the L<Module::Build> for the general docs. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Platform/darwin.pm b/lib/Module/Build/Platform/darwin.pm index 6ac60c9e7c..ef381c4804 100644 --- a/lib/Module/Build/Platform/darwin.pm +++ b/lib/Module/Build/Platform/darwin.pm @@ -28,7 +28,7 @@ Please see the L<Module::Build> for the general docs. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Platform/os2.pm b/lib/Module/Build/Platform/os2.pm index f83ef99671..0496d2ea1a 100644 --- a/lib/Module/Build/Platform/os2.pm +++ b/lib/Module/Build/Platform/os2.pm @@ -27,7 +27,7 @@ Please see the L<Module::Build> for the general docs. =head1 AUTHOR -Ken Williams <ken@cpan.org> +Ken Williams <kwilliams@cpan.org> =head1 SEE ALSO diff --git a/lib/Module/Build/Version.pm b/lib/Module/Build/Version.pm index 17a582a146..1e5a657520 100644 --- a/lib/Module/Build/Version.pm +++ b/lib/Module/Build/Version.pm @@ -25,9 +25,9 @@ if ($@) { # can't locate version files, use our own # but we eval them in reverse order since version depends on # version::vpp to already exist - eval $vpp; + eval $vpp; die $@ if $@; $INC{'version/vpp.pm'} = 'inside Module::Build::Version'; - eval $version; + eval $version; die $@ if $@; $INC{'version.pm'} = 'inside Module::Build::Version'; } @@ -94,7 +94,7 @@ use strict; use Scalar::Util; use vars qw ($VERSION @ISA @REGEXS); -$VERSION = 0.661; +$VERSION = 0.67; push @REGEXS, qr/ ^v? # optional leading 'v' @@ -133,6 +133,12 @@ sub new $value = $tvalue; } } + + # exponential notation + if ( $value =~ /\d+e-?\d+/ ) { + $value = sprintf("%.9f",$value); + $value =~ s/(0+)$//; + } # This is not very efficient, but it is morally equivalent # to the XS code (as that is the reference implementation). @@ -453,11 +459,6 @@ sub is_alpha { sub qv { my ($value) = @_; - if ( $value =~ /\d+e-?\d+/ ) { # exponential notation - $value = sprintf("%.9f",$value); - $value =~ s/(0+)//; - } - my $eval = eval 'Scalar::Util::isvstring($value)'; if ( !$@ and $eval ) { $value = sprintf("v%vd",$value); @@ -499,10 +500,6 @@ sub _verify { } if ( defined $req ) { - if ( $req =~ /\d+e-?\d+/ ) { # exponential notation - $req = sprintf("%.9f",$req); - $req =~ s/(0+)$//; - } unless ( defined $version ) { my $msg = "$class does not define ". "\$$class\::VERSION--version check failed"; diff --git a/lib/Module/Build/t/basic.t b/lib/Module/Build/t/basic.t index 0a914e5472..d05ea423bd 100644 --- a/lib/Module/Build/t/basic.t +++ b/lib/Module/Build/t/basic.t @@ -2,7 +2,7 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 55; +use MBTest tests => 49; use Cwd (); my $cwd = Cwd::cwd; @@ -145,6 +145,8 @@ my \$build = Module::Build->new( is $@, ''; my $mb = Module::Build->resume; + ok $mb->valid_property('config'); + is $mb->config('cc'), $Config{cc}; is $mb->config('foocakes'), 'barcakes'; @@ -156,14 +158,14 @@ my \$build = Module::Build->new( is $mb->args('any'), 'hey'; is $mb->args('dee'), 'goo'; is $mb->destdir, 'yo'; - is $mb->runtime_params('destdir'), 'yo'; - is $mb->runtime_params('verbose'), '1'; - ok ! $mb->runtime_params('license'); - ok my %runtime = $mb->runtime_params; - is scalar keys %runtime, 4; - is $runtime{destdir}, 'yo'; - is $runtime{verbose}, '1'; - ok $runtime{config}; + my %runtime = $mb->runtime_params; + is_deeply \%runtime, + { + verbose => 1, + destdir => 'yo', + use_rcfile => 0, + config => { foocakes => 'barcakes' }, + }; ok my $argsref = $mb->args; is $argsref->{foo}, 1; diff --git a/lib/Module/Build/t/ext.t b/lib/Module/Build/t/ext.t index e44fd56cdd..cbe2190a3e 100644 --- a/lib/Module/Build/t/ext.t +++ b/lib/Module/Build/t/ext.t @@ -95,9 +95,12 @@ foreach my $test (@win_splits) { { # Make sure run_perl_script() propagates @INC - local @INC = ('whosiewhatzit', @INC); + my $dir = 'whosiewhatzit'; + mkdir $dir, 0777; + local @INC = ($dir, @INC); my $output = stdout_of( sub { Module::Build->run_perl_script('', ['-le', 'print for @INC']) } ); - like $output, qr{^whosiewhatzit}m; + like $output, qr{^$dir}m; + rmdir $dir; } ################################################################## diff --git a/lib/Module/Build/t/extend.t b/lib/Module/Build/t/extend.t index 2c4a50367a..513483cff6 100644 --- a/lib/Module/Build/t/extend.t +++ b/lib/Module/Build/t/extend.t @@ -227,25 +227,30 @@ print "Hello, World!\n"; eval{ $mb->y_n('Prompt?', 'invalid default') }; like $@, qr/Invalid default/, "y_n() requires a default of 'y' or 'n'"; - SKIP:{ - skip "No available STDIN", 7 unless -t STDIN; + $ENV{PERL_MM_USE_DEFAULT} = 1; - $ENV{PERL_MM_USE_DEFAULT} = 1; + eval{ $mb->y_n('Is this a question?') }; + like $@, qr/ERROR:/, + 'Do not allow default-less y_n() for unattended builds'; - eval{ $mb->y_n("# Is this a question?") }; - like $@, qr/ERROR:/, 'Do not allow default-less y_n() for unattended builds'; + eval{ $ans = $mb->prompt('Is this a question?') }; + like $@, qr/ERROR:/, + 'Do not allow default-less prompt() for unattended builds'; - eval{ $ans = $mb->prompt('# Is this a question?') }; - like $@, qr/ERROR:/, 'Do not allow default-less prompt() for unattended builds'; + + # When running Test::Smoke under a cron job, STDIN will be closed which + # will fool our _is_interactive() method causing various failures. + { + local *{Module::Build::_is_interactive} = sub { 1 }; $ENV{PERL_MM_USE_DEFAULT} = 0; - $ans = $mb->prompt('# Is this a question?'); + $ans = $mb->prompt('Is this a question?'); print "\n"; # fake <enter> after input is $ans, 'y', "prompt() doesn't require default for interactive builds"; - $ans = $mb->y_n('# Say yes'); + $ans = $mb->y_n('Say yes'); print "\n"; # fake <enter> after input ok $ans, "y_n() doesn't require default for interactive build"; @@ -253,15 +258,16 @@ print "Hello, World!\n"; # Test Defaults *{Module::Build::_readline} = sub { '' }; - $ans = $mb->prompt("# Is this a question"); + $ans = $mb->prompt("Is this a question"); is $ans, '', "default for prompt() without a default is ''"; - $ans = $mb->prompt("# Is this a question", 'y'); + $ans = $mb->prompt("Is this a question", 'y'); is $ans, 'y', " prompt() with a default"; - $ans = $mb->y_n("# Is this a question", 'y'); + $ans = $mb->y_n("Is this a question", 'y'); ok $ans, " y_n() with a default"; } + } # cleanup diff --git a/lib/Module/Build/t/metadata.t b/lib/Module/Build/t/metadata.t index 939e665b4b..d5b5ee1739 100644 --- a/lib/Module/Build/t/metadata.t +++ b/lib/Module/Build/t/metadata.t @@ -2,7 +2,7 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 43; +use MBTest tests => 47; use Cwd (); my $cwd = Cwd::cwd; @@ -138,6 +138,21 @@ is_deeply($mb->find_dist_packages, 'Foo::Bar' => { file => 'lib/Simple.pm', version => '1.23' }}); +{ + $dist->change_file( 'lib/Simple.pm', <<'---' ); +package Simple; +$VERSION = version->new('0.60.' . qw$Revision: 128 $[1]); +package Simple::Simon; +$VERSION = version->new('0.61.' . qw$Revision: 129 $[1]); +--- + $dist->regen; + my $provides = new_build()->prepare_metadata()->{provides}; + is $provides->{'Simple'}{version}, 'v0.60.128', "Check version"; + is $provides->{'Simple::Simon'}{version}, 'v0.61.129', "Check version"; + is ref($provides->{'Simple'}{version}), '', "Versions from prepare_metadata() aren't refs"; + is ref($provides->{'Simple::Simon'}{version}), '', "Versions from prepare_metadata() aren't refs"; +} + # Single file with multiple differing packages, no corresponding package # Simple.pm => Foo diff --git a/lib/Module/Build/t/moduleinfo.t b/lib/Module/Build/t/moduleinfo.t index 1c2233f528..50c51041ba 100644 --- a/lib/Module/Build/t/moduleinfo.t +++ b/lib/Module/Build/t/moduleinfo.t @@ -2,7 +2,7 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 75; +use MBTest tests => 81; use Cwd (); my $cwd = Cwd::cwd; @@ -171,7 +171,10 @@ our $VERSION = "1.23"; package Simple; use version; our $VERSION = qv('1.230'); --- - + <<'---', # Two version assignments, should ignore second one + $Simple::VERSION = '1.230'; + $Simple::VERSION = eval $Simple::VERSION; +--- ); my( $i, $n ) = ( 1, scalar( @modules ) ); @@ -386,7 +389,7 @@ is( $name, q|Simple - It's easy.|, 'collected pod section' ); { - # examine properties of a module: name, pod, etc + # Make sure processing stops after __DATA__ $dist->change_file( 'lib/Simple.pm', <<'---' ); package Simple; $VERSION = '0.01'; @@ -404,6 +407,24 @@ __DATA__ is_deeply(\@packages, ['Simple']); } +{ + # Make sure we handle version.pm $VERSIONs well + $dist->change_file( 'lib/Simple.pm', <<'---' ); +package Simple; +$VERSION = version->new('0.60.' . qw$Revision: 128 $[1]); +package Simple::Simon; +$VERSION = version->new('0.61.' . qw$Revision: 129 $[1]); +--- + $dist->regen; + + $pm_info = Module::Build::ModuleInfo->new_from_file('lib/Simple.pm'); + is( $pm_info->name, 'Simple', 'found default package' ); + is( $pm_info->version, 'v0.60.128', 'version for default package' ); + my @packages = $pm_info->packages_inside; + is_deeply([sort @packages], ['Simple', 'Simple::Simon']); + is( $pm_info->version('Simple::Simon'), 'v0.61.129', 'version for embedded package' ); +} + # cleanup chdir( $cwd ) or die "Can't chdir to '$cwd': $!"; diff --git a/lib/Module/Build/t/xs.t b/lib/Module/Build/t/xs.t index 78ca6d9e03..c15a98f86f 100644 --- a/lib/Module/Build/t/xs.t +++ b/lib/Module/Build/t/xs.t @@ -65,10 +65,12 @@ is $@, ''; eval {$mb->dispatch('clean')}; is $@, ''; + $mb->create_build_script; - ok -e 'Build'; + my $script = $mb->build_script; + ok -e $script; - eval {$mb->run_perl_script('Build')}; + eval {$mb->run_perl_script($script)}; is $@, ''; } @@ -85,9 +87,10 @@ SKIP: { skip( "skipping a Unixish-only tests", 1 ) unless $mb->os_type eq 'Unix'; - local $mb->{config}{ld} = "FOO=BAR $mb->{config}{ld}"; + $mb->{config}->push(ld => "FOO=BAR ".$mb->config('ld')); eval {$mb->dispatch('build')}; is $@, ''; + $mb->{config}->pop('ld'); } eval {$mb->dispatch('realclean')}; |