cpan/Module-Build/lib/Module/Build/Version.pm Module::Build
cpan/Module-Build/lib/Module/Build/YAML.pm Module::Build
cpan/Module-Build/scripts/config_data Module::Build
+cpan/Module-Build/t/00-compile.t Module::Build
cpan/Module-Build/t/actions/installdeps.t Module::Build
cpan/Module-Build/t/add_property.t Module::Build
cpan/Module-Build/t/basic.t Module::Build
'Module::Build' =>
{
'MAINTAINER' => 'kwilliams',
- 'DISTRIBUTION' => 'DAGOLDEN/Module-Build-0.35_09.tar.gz',
+ 'DISTRIBUTION' => 'DAGOLDEN/Module-Build-0.35_14.tar.gz',
'FILES' => q[cpan/Module-Build],
'EXCLUDED' => [ qw{ t/par.t t/signature.t },
qr!^contrib/!, qr!^devtools! ],
Revision history for Perl extension Module::Build.
+0.35_14 - Thu Dec 17 16:02:14 EST 2009
+
+ Bug fixes:
+
+ - If not set, the 'module_name' is detected from 'dist_version_from'
+ or from 'dist_name'. The directory is no longer used. [David Golden]
+
+ - The 'share_dir' property no longer defaults to 'share' and must be
+ explicitly set instead; this fixes problems for CPAN distributions that
+ already have a 'share' directory for whatever reason [David Golden]
+
+ - Change t/00-compile.t test for more portability [David Golden]
+
+ - Skip ppm.t if Pod::Html is not available [David Goldenj]
+
+ - Changed guts of inc::latest to work properly on older versions of Perl
+ [David Golden]
+
+ - Ensure bundle_inc.t doesn't accidentally uninstall the installed M::B
+ during testing if the user had 'uninst=1' set during Build.PL
+ [David Golden]
+
+0.35_13 - Sat Dec 5 11:26:36 EST 2009
+
+ Bug fixes:
+
+ - Protect against tempfile errors when checking ExtUtils::Installed
+ [David Golden]
+
+0.35_12 - Fri Dec 4 23:06:49 EST 2009
+
+ Bug fixes:
+
+ - Protect inc/ bundling tests against broken ExtUtils::Installed
+ [David Golden]
+
+0.35_11 - Thu Dec 3 11:07:44 EST 2009
+
+ *** API CHANGE ***
+
+ - The old API for prepare_metadata() has been restored to avoid breaking
+ distributions that were overriding it (e.g. BioPerl), but the method
+ has been marked deprecated and may be made private or may disappear in
+ some future version of Module::Build. [David Golden]
+
+ - A new get_metadata() method has been added as a simpler wrapper around
+ the old, kludgy prepare_metadata() API. [David Golden]
+
+0.35_10 - Tue Nov 24 22:49:19 EST 2009
+
+ Bug fixes:
+
+ - bundle_inc.t is more careful about permissions and open filehandles
+ to avoid failures/skips on Win32 [David Golden]
+
+ - Fix compilation error in Module::Build::Platform::VMS (RT#51766)
+ [David Golden]
+
+ - Don't generate a MANIFEST.SKIP during distclean and add any generated
+ MANIFEST.SKIP to cleanup list [reported by Zefram, fixed by David Golden]
+
+ - Module::Build::ModuleInfo version parsing would fail if a module sets
+ its $VERSION from another module, but the other module is not installed.
+ We now try to detect such failures, prepend 'lib' to @INC and try again.
+ [David Golden]
+
+ - MYMETA.yml used to be generated from scratch, overriding any
+ customizations used to create META.yml. Now, if META.yml exists, that
+ will be used as the base for MYMETA and only prereq fields will be
+ updated (to reflect any dynamic configuration); also, 'dynamic_config'
+ will be set to false and 'generated_by' will be updated [David Golden]
+
0.35_09 - Thu Nov 19 01:30:42 EST 2009
Bug fixes:
use vars qw($VERSION @ISA);
@ISA = qw(Module::Build::Base);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
# Okay, this is the brute-force method of finding out what kind of
'actions'. In this case the actions run are 'build' (the default
action), 'test', and 'install'. Other actions defined so far include:
- build manifest
- clean manpages
- code pardist
- config_data ppd
- diff ppmdist
- dist prereq_data
- distcheck prereq_report
- distclean pure_install
- distdir realclean
- distmeta retest
- distsign skipcheck
- disttest test
- docs testall
- fakeinstall testcover
- help testdb
- html testpod
- install testpodcoverage
- installdeps versioninstall
-
+<action_list>
You can run the 'help' action for a complete list of actions.
GZIP compression.
By default, this action will use the C<Archive::Tar> module. However, you can
-force it to use binary "tar" and "gzip" executables by supplying an explicit
+force it to use binary "tar" and "gzip" executables by supplying an explicit
C<tar> (and optional C<gzip>) parameter:
./Build dist --tar C:\path\to\tar.exe --gzip C:\path\to\zip.exe
[version 0.28]
This action is identical to the C<install> action. In the future,
-though, when C<install> starts writing to the file
+though, when C<install> starts writing to the file
F<$(INSTALLARCHLIB)/perllocal.pod>, C<pure_install> won't, and that
will be the only difference between them.
[version 0.25]
-This checks all the files described in the C<docs> action and
+This checks all the files described in the C<docs> action and
produces C<Test::Harness>-style output. If you are a module author,
this is useful to run before creating a new release.
[version 0.28]
-This checks the pod coverage of the distribution and
+This checks the pod coverage of the distribution and
produces C<Test::Harness>-style output. If you are a module author,
this is useful to run before creating a new release.
C<share_dir> property supports both distribution-level and
module-level share files.
-The default when C<share_dir> is not set is for any files in a F<share>
-directory at the top level of the distribution to be installed in
-distribution-level share directory. Alternatively, C<share_dir> can be set to
-a directory name or an arrayref of directory names containing files to be
-installed in the distribution-level share directory.
+The simplest use of C<share_dir> is to set it to a directory name or an
+arrayref of directory names containing files to be installed in the
+distribution-level share directory.
-If C<share_dir> is a hashref, it may have C<dist> or C<module> keys
-providing full flexibility in defining share directories to install.
+ share_dir => 'share'
+
+Alternatively, if C<share_dir> is a hashref, it may have C<dist> or
+C<module> keys providing full flexibility in defining how share
+directories should be installed.
share_dir => {
dist => [ 'examples', 'more_examples' ],
}
}
-If C<share_dir> is set (manually or automatically), then File::ShareDir
-will automatically be added to the C<requires> hash.
+If C<share_dir> is set, then File::ShareDir will automatically be added
+to the C<requires> hash.
=item sign
Returns a hash reference indicating the C<conflicts> prerequisites
that were passed to the C<new()> method.
-=item contains_pod($file)
+=item contains_pod($file) [deprecated]
[version 0.20]
Assigning the value C<undef> to an element causes it to be removed.
-=item prepare_metadata()
+=item get_metadata()
[version 0.36]
package My::Builder;
use base 'Module::Build';
- sub prepare_metadata {
- my $self = shift;
- my $data = $self->SUPER::prepare_metadata();
+ sub get_metadata {
+ my $self, @args = @_;
+ my $data = $self->SUPER::get_metadata(@args);
$data->{custom_field} = 'foo';
return $data;
}
+The only valid argument is C<fatal>, which indicates whether missing required
+metadata fields should be a fatal error or not. For META creation, it
+generally should, but for MYMETA creation for end-users, it should not be
+fatal.
+
+This method is a wrapper around the old prepare_metadata API now that we
+no longer use YAML::Node to hold metadata.
+
+=item prepare_metadata() [deprecated]
+
+[version 0.36]
+
+[Deprecated] As of 0.36, authors should use C<get_metadata> instead. This
+method is preserved for backwards compatibility only.
+
+It takes three positional arguments: a hashref (to which metadata will be
+added), an optional arrayref (to which metadata keys will be added in order if
+the arrayref exists), and a hashref of arguments (as provided to get_metadata).
+The latter argument is new as of 0.36. Earlier versions are always fatal on
+errors.
+
Prior to version 0.36, this method took a YAML::Node as an argument to hold
assembled metadata.
=over 4
-=item PL_files()
-
-=item allow_mb_mismatch()
-
-=item auto_configure_requires()
-
-=item autosplit()
-
-=item base_dir()
-
-=item bindoc_dirs()
-
-=item blib()
-
-=item build_bat()
-
-=item build_class()
-
-=item build_elements()
-
-=item build_requires()
-
-=item build_script()
-
-=item bundle_inc()
-
-=item bundle_inc_preload()
-
-=item c_source()
-
-=item config_dir()
-
-=item configure_requires()
-
-=item conflicts()
-
-=item cpan_client()
-
-=item create_license()
-
-=item create_makefile_pl()
-
-=item create_packlist()
-
-=item create_readme()
-
-=item debug()
-
-=item debugger()
-
-=item destdir()
-
-=item get_options()
-
-=item html_css()
-
-=item include_dirs()
-
-=item install_base()
-
-=item installdirs()
-
-=item libdoc_dirs()
-
-=item license()
-
-=item magic_number()
-
-=item mb_version()
-
-=item meta_add()
-
-=item meta_merge()
-
-=item metafile()
-
-=item module_name()
-
-=item mymetafile()
-
-=item needs_compiler()
-
-=item orig_dir()
-
-=item perl()
-
-=item pm_files()
-
-=item pod_files()
-
-=item pollute()
-
-=item prefix()
-
-=item prereq_action_types()
-
-=item program_name()
-
-=item quiet()
-
-=item recommends()
-
-=item recurse_into()
-
-=item recursive_test_files()
-
-=item requires()
-
-=item scripts()
-
-=item sign()
-
-=item tap_harness_args()
-
-=item test_file_exts()
-
-=item use_rcfile()
-
-=item use_tap_harness()
-
-=item verbose()
-
-=item xs_files()
+<autogenerated_accessors>
=back
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
BEGIN { require 5.00503 }
$p->{module_name} = $mi->name;
}
else {
- my $mod_path = my $mod_name = File::Basename::basename($self->base_dir);
+ my $mod_path = my $mod_name = $p->{dist_name};
$mod_name =~ s{-}{::}g;
$mod_path =~ s{-}{/}g;
$mod_path .= ".pm";
- if ( -e $mod_path || -e File::Spec->catfile('lib', $mod_path) ) {
+ if ( -e $mod_path || -e "lib/$mod_path" ) {
$p->{module_name} = $mod_name;
}
else {
return unless inc::latest->can('loaded_modules');
require ExtUtils::Installed;
# ExtUtils::Installed is buggy about finding additions to default @INC
- my $inst = ExtUtils::Installed->new(extra_libs => [@INC]);
+ my $inst = eval { ExtUtils::Installed->new(extra_libs => [@INC]) };
+ if ($@) {
+ $self->log_warn( << "EUI_ERROR" );
+Bundling in inc/ is disabled because ExtUtils::Installed could not
+create a list of your installed modules. Here is the error:
+$@
+EUI_ERROR
+ return;
+ }
my @bundle_list = map { [ $_, 0 ] } inc::latest->loaded_modules;
# XXX TODO: Need to get ordering of prerequisites correct so they are
EOF
}
-sub create_build_script {
+sub create_mymeta {
my ($self) = @_;
- $self->write_config;
-
- # Create MYMETA.yml
my $mymetafile = $self->mymetafile;
+ my $metafile = $self->metafile;
+
+ # cleanup
if ( $self->delete_filetree($mymetafile) ) {
$self->log_verbose("Removed previous '$mymetafile'\n");
}
$self->log_info("Creating new '$mymetafile' with configuration results\n");
- $self->write_metafile( $mymetafile, $self->prepare_metadata( fatal => 0 ) );
+
+ # use old meta and update prereqs, if possible
+ my $mymeta;
+ if ( -f $metafile ) {
+ $mymeta = eval { $self->read_metafile( $self->metafile ) };
+ }
+ # if we read META OK, just update it
+ if ( defined $mymeta ) {
+ my $prereqs = $self->_normalize_prereqs;
+ for my $t ( keys %$prereqs ) {
+ $mymeta->{$t} = $prereqs->{$t};
+ }
+ }
+ # but generate from scratch, ignoring errors if META doesn't exist
+ else {
+ $mymeta = $self->get_metadata( fatal => 0 );
+ }
+
+ # MYMETA is always static
+ $mymeta->{dynamic_config} = 0;
+ # Note which M::B created it
+ $mymeta->{generated_by} = "Module::Build version $Module::Build::VERSION";
+
+ $self->write_metafile( $mymetafile, $mymeta );
+ return 1;
+}
+
+sub create_build_script {
+ my ($self) = @_;
+
+ $self->write_config;
+ $self->create_mymeta;
# Create Build
my ($build_script, $dist_name, $dist_version)
while (my ($one, $two) = splice @actions, 0, 2) {
$out .= sprintf(" %-12s %-12s\n", $one, $two||'');
}
+ $out =~ s{\s*$}{}mg; # remove trailing spaces
return $out;
}
my @file_map;
if ( $share_dir->{dist} ) {
- my $prefix = File::Spec->catdir( "dist", $self->dist_name );
+ my $prefix = "dist/".$self->dist_name;
push @file_map, $self->_share_dir_map( $prefix, $share_dir->{dist} );
}
if ( $share_dir->{module} ) {
for my $mod ( keys %{ $share_dir->{module} } ) {
(my $altmod = $mod) =~ s{::}{-}g;
- my $prefix = File::Spec->catdir("module", $altmod);
+ my $prefix = "module/$altmod";
push @file_map, $self->_share_dir_map($prefix, $share_dir->{module}{$mod});
}
}
my %files;
for my $dir ( @$list ) {
for my $f ( @{ $self->rscan_dir( $dir, sub {-f} )} ) {
- $files{File::Spec->canonpath($f)} = File::Spec->catfile(
- $prefix, File::Spec->abs2rel( $f, $dir )
- );
+ $f =~ s{\A.*\Q$dir\E/}{};
+ $files{"$dir/$f"} = "$prefix/$f";
}
}
return %files;
sub ACTION_distcheck {
my ($self) = @_;
- $self->_check_manifest_skip;
+ $self->_check_manifest_skip unless $self->invoked_action eq 'distclean';
require ExtUtils::Manifest;
local $^W; # ExtUtils::Manifest is not warnings clean.
$content .= <<'EOF';
# Avoid configuration metadata file
-^MYMETA\.$
+^MYMETA\.
# Avoid Module::Build generated and utility files.
\bBuild$
\bBuild.COM$
\bBUILD.COM$
\bbuild.com$
+^MANIFEST\.SKIP
# Avoid archives of this distribution
EOF
my $maniskip = 'MANIFEST.SKIP';
if ( ! -e $maniskip ) {
- $self->log_warn("File '$maniskip' does not exist: Creating a default '$maniskip'\n");
+ $self->log_warn("File '$maniskip' does not exist: Creating a temporary '$maniskip'\n");
$self->_write_default_maniskip($maniskip);
+ $self->add_to_cleanup($maniskip);
}
else {
# MYMETA must not be added to MANIFEST, so always confirm the skip
# Always coerce to proper hash form
if ( ! defined $p->{share_dir} ) {
- # not set -- use default 'share' dir if exists
- $p->{share_dir} = { dist => [ 'share' ] } if -d 'share';
+ return;
}
elsif ( ! ref $p->{share_dir} ) {
# scalar -- treat as a single 'dist' directory
push @INC, File::Spec->catdir($self->blib, 'lib');
}
- if ( $self->write_metafile( $self->metafile, $self->prepare_metadata( fatal => 1 ) ) ) {
+ if ($self->write_metafile($self->metafile,$self->get_metadata(fatal=>1))){
$self->{wrote_metadata} = 1;
$self->_add_to_manifest('MANIFEST', $metafile);
}
return 1;
}
+sub read_metafile {
+ my $self = shift;
+ my ($metafile) = @_;
+ my $yaml;
+
+ my $class = $self->_mb_feature('YAML_support')
+ ? 'YAML::Tiny' : 'Module::Build::YAML' ;
+
+ eval "require $class; 1" or die $@;
+ my $meta = $class->read($metafile)
+ or $self->log_warn( "Error reading '$metafile': " . $class->errstr . "\n");
+
+ return $meta->[0] || {};
+}
+
sub write_metafile {
my $self = shift;
my ($metafile, $node) = @_;
return $version;
}
-sub prepare_metadata {
+sub _normalize_prereqs {
+ my ($self) = @_;
+ my $p = $self->{properties};
+
+ # copy prereq data structures so we can modify them before writing to META
+ my %prereq_types;
+ for my $type ( 'configure_requires', @{$self->prereq_action_types} ) {
+ if (exists $p->{$type}) {
+ for my $mod ( keys %{ $p->{$type} } ) {
+ $prereq_types{$type}{$mod} =
+ $self->normalize_version($p->{$type}{$mod});
+ }
+ }
+ }
+ return \%prereq_types;
+}
+
+
+# wrapper around old prepare_metadata API;
+sub get_metadata {
my ($self, %args) = @_;
- my $fatal = $args{fatal} || 0;
+ my $metadata = {};
+ $self->prepare_metadata( $metadata, undef, \%args );
+ return $metadata;
+}
+
+# To preserve compatibility with old API, $node *must* be a hashref
+# passed in to prepare_metadata. $keys is an arrayref holding a
+# list of keys -- it's use is optional and generally no longer needed
+# but kept for back compatibility. $args is an optional parameter to
+# support the new 'fatal' toggle
+
+sub prepare_metadata {
+ my ($self, $node, $keys, $args) = @_;
+ unless ( ref $node eq 'HASH' ) {
+ croak "prepare_metadata() requires a hashref argument to hold output\n";
+ }
+ my $fatal = $args->{fatal} || 0;
my $p = $self->{properties};
- my $node = {};
# A little helper sub
my $add_node = sub {
my ($name, $val) = @_;
$node->{$name} = $val;
+ push @$keys, $name if $keys;
};
foreach (qw(dist_name dist_version dist_author dist_abstract license)) {
# XXX we are silently omitting the url for any unknown license
}
- # copy prereq data structures so we can modify them before writing to META
- my %prereq_types;
- for my $type ( 'configure_requires', @{$self->prereq_action_types} ) {
- if (exists $p->{$type}) {
- for my $mod ( keys %{ $p->{$type} } ) {
- $prereq_types{$type}{$mod} =
- $self->normalize_version($p->{$type}{$mod});
- }
- }
- }
- for my $t ( keys %prereq_types ) {
- $add_node->($t, $prereq_types{$t});
+ my $prereqs = $self->_normalize_prereqs;
+ for my $t ( keys %$prereqs ) {
+ $add_node->($t, $prereqs->{$t});
}
if (exists $p->{dynamic_config}) {
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
use File::Basename ();
use File::Spec;
VENDOR => 'vendor',
);
-my %makefile_to_build =
+my %makefile_to_build =
(
TEST_VERBOSE => 'verbose',
VERBINST => 'verbose',
}
return %$merge;
}
-
-
+
+
sub create_makefile_pl {
my ($package, $type, $build, %args) = @_;
-
+
die "Don't know how to build Makefile.PL of type '$type'"
unless $type =~ /^(small|passthrough|traditional)$/;
if ($type eq 'passthrough') {
$build->log_warn(<<"HERE");
-
-IMPORTANT NOTE: The '$type' style of Makefile.PL is deprecated and
+
+IMPORTANT NOTE: The '$type' style of Makefile.PL is deprecated and
may be removed in a future version of Module::Build in favor of the
'configure_requires' property. See Module::Build::Compat
documentation for details.
print {$fh} "# Note: this file was auto-generated by ", __PACKAGE__, " version $VERSION\n";
- # Minimum perl version should be specified as "require 5.XXXXXX" in
+ # Minimum perl version should be specified as "require 5.XXXXXX" in
# Makefile.PL
my $requires = $build->requires;
if ( my $minimum_perl = $requires->{perl} ) {
} elsif ($type eq 'passthrough') {
printf {$fh} <<'EOF', $subclass_load, ref($build), ref($build);
-
+
unless (eval "use Module::Build::Compat 0.02; 1" ) {
print "This module requires Module::Build to install itself.\n";
-
+
require ExtUtils::MakeMaker;
my $yn = ExtUtils::MakeMaker::prompt
(' Install Module::Build now from CPAN?', 'y');
-
+
unless ($yn =~ /^y/i) {
die " *** Cannot install without Module::Build. Exiting ...\n";
}
-
+
require Cwd;
require File::Spec;
require CPAN;
-
+
# Save this 'cause CPAN will chdir all over the place.
my $cwd = Cwd::cwd();
-
+
CPAN::Shell->install('Module::Build::Compat');
CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate
or die "Couldn't install Module::Build, giving up.\n";
-
+
chdir $cwd or die "Cannot chdir() back to $cwd: $!";
}
eval "use Module::Build::Compat 0.02; 1" or die $@;
%s
Module::Build::Compat->run_build_pl(args => \@ARGV);
- my $build_script = 'Build';
+ my $build_script = 'Build';
$build_script .= '.com' if $^O eq 'VMS';
exit(0) unless(-e $build_script); # cpantesters convention
require %s;
Module::Build::Compat->write_makefile(build_class => '%s');
EOF
-
+
} elsif ($type eq 'traditional') {
my (%MM_Args, %prereq);
tie %MM_Args, 'Tie::IxHash'; # Don't care if it fails here
tie %prereq, 'Tie::IxHash'; # Don't care if it fails here
}
-
+
my %name = ($build->module_name
? (NAME => $build->module_name)
: (DISTNAME => $build->dist_name));
-
+
my %version = ($build->dist_version_from
? (VERSION_FROM => $build->dist_version_from)
: (VERSION => $build->dist_version)
);
%MM_Args = (%name, %version);
-
+
%prereq = _merge_prereq( $build->requires, $build->build_requires );
%prereq = map {$_, $prereq{$_}} sort keys %prereq;
-
+
delete $prereq{perl};
$MM_Args{PREREQ_PM} = \%prereq;
-
+
$MM_Args{INSTALLDIRS} = $build->installdirs eq 'core' ? 'perl' : $build->installdirs;
-
+
$MM_Args{EXE_FILES} = [ sort keys %{$build->script_files} ] if $build->script_files;
-
+
$MM_Args{PL_FILES} = $build->PL_files || {};
if ($build->recursive_test_files) {
local $Data::Dumper::Terse = 1;
my $args = Data::Dumper::Dumper(\%MM_Args);
$args =~ s/\{(.*)\}/($1)/s;
-
+
print $fh <<"EOF";
use ExtUtils::MakeMaker;
WriteMakefile
sub subclass_dir {
my ($self, $build) = @_;
-
+
return (Module::Build::ModuleInfo->find_module_dir_by_name(ref $build)
|| File::Spec->catdir($build->config_dir, 'lib'));
}
my @out;
foreach my $arg (@_) {
next if $arg eq '';
-
+
my ($key, $val) = ($arg =~ /^(\w+)=(.+)/ ? ($1, $2) :
die "Malformed argument '$arg'");
}
}
}
- push @out, (config => \%config) if %config;
+ push @out, (config => \%config) if %config;
return @out;
}
$perl $Build $action
EOF
}
-
+
if ($self->_is_vms_mms) {
# Roll our own .EXPORT as MMS/MMK don't honor that directive.
- $maketext .= "\n.FIRST\n\t\@ $noop\n";
+ $maketext .= "\n.FIRST\n\t\@ $noop\n";
for my $macro (keys %macro_to_build) {
$maketext .= ".IFDEF $macro\n\tDEFINE $macro \"\$($macro)\"\n.ENDIF\n";
}
- $maketext .= "\n";
+ $maketext .= "\n";
}
else {
$maketext .= "\n.EXPORT : " . join(' ', keys %macro_to_build) . "\n\n";
}
-
+
return $maketext;
}
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Config;
}
}
];
-$x; }
+$x; }
\ No newline at end of file
package Module::Build::Cookbook;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
=head1 NAME
# Find out what version of Module::Build is installed or fail quietly.
# This should be cross-platform.
- my $Installed_MB =
+ my $Installed_MB =
`$^X -e "eval q{require Module::Build; print Module::Build->VERSION} or exit 1";
# some operating systems put a newline at the end of every print.
package Module::Build::Dumper;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
# This is just a split-out of a wrapper function to do Data::Dumper
# stuff "the right way". See:
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use File::Spec;
\s+ # whitespace
([\w:]+) # a package name
\s* # optional whitespace
- ($V_NUM_REGEXP)? # optional version number
+ ($V_NUM_REGEXP)? # optional version number
\s* # optional whitesapce
; # semicolon line terminator
}x;
$need_vers = 0 if $vers_pkg eq $pkg;
unless ( defined $vers{$vers_pkg} && length $vers{$vers_pkg} ) {
- $vers{$vers_pkg} =
+ $vers{$vers_pkg} =
$self->_evaluate_version_line( $vers_sig, $vers_fullname, $line );
} else {
# Warn unless the user is using the "$VERSION = eval
local $^W;
# Try to get the $VERSION
eval $eval;
+ # some modules say $VERSION = $Foo::Bar::VERSION, but Foo::Bar isn't
+ # installed, so we need to hunt in ./lib for it
+ if ( $@ =~ /Can't locate/ && -d 'lib' ) {
+ local @INC = ('lib',@INC);
+ eval $eval;
+ }
warn "Error evaling version line '$eval' in $self->{filename}: $@\n"
if $@;
(ref($vsub) eq 'CODE') or
die "failed to build version sub for $self->{filename}";
my $result = eval { $vsub->() };
- die "Could not get version from $self->{filename} by executing:\n$eval\n\nThe fatal error was: $@\n"
+ die "Could not get version from $self->{filename} by executing:\n$eval\n\nThe fatal error was: $@\n"
if $@;
# Activestate apparently creates custom versions like '1.23_45_01', which
# Bless it into our own version class
eval { $result = Module::Build::Version->new($result) };
- die "Version '$result' from $self->{filename} does not appear to be valid:\n$eval\n\nThe fatal error was: $@\n"
+ die "Version '$result' from $self->{filename} does not appear to be valid:\n$eval\n\nThe fatal error was: $@\n"
if $@;
return $result;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Data::Dumper;
use IO::File;
sub access {
my $self = shift;
return $self->read() unless @_;
-
+
my $key = shift;
return $self->read($key) unless @_;
-
+
my $value = shift;
$self->write({ $key => $value });
return $self->read($key);
return $self->{new}{$key} if exists $self->{new}{$key};
return $self->{disk}{$key};
}
-
+
# Return all data
my $out = (keys %{$self->{new}}
? {%{$self->{disk}}, %{$self->{new}}}
sub write {
my ($self, $href) = @_;
$href ||= {};
-
+
@{$self->{new}}{ keys %$href } = values %$href; # Merge
# Do some optimization to avoid unnecessary writes
next if ref $self->{disk}{$key} or !exists $self->{disk}{$key};
delete $self->{new}{$key} if $self->_same($self->{new}{$key}, $self->{disk}{$key});
}
-
+
if (my $file = $self->{file}) {
my ($vol, $dir, $base) = File::Spec->splitpath($file);
$dir = File::Spec->catpath($vol, $dir, '');
return unless -e $dir && -d $dir; # The user needs to arrange for this
return if -e $file and !keys %{ $self->{new} }; # Nothing to do
-
- @{$self->{disk}}{ keys %{$self->{new}} } = values %{$self->{new}}; # Merge
+
+ @{$self->{disk}}{ keys %{$self->{new}} } = values %{$self->{new}}; # Merge
$self->_dump($file, $self->{disk});
-
+
$self->{new} = {};
}
return $self->read;
sub _dump {
my ($self, $file, $data) = @_;
-
+
my $fh = IO::File->new("> $file") or die "Can't create '$file': $!";
print {$fh} Module::Build::Dumper->_data_dump($data);
}
# strip out private POD markers we use to keep pod from being
# recognized for *this* source file
$template =~ s{$_\n}{} for '=begin private', '=end private';
-
+
my $fh = IO::File->new("> $args{file}") or die "Can't create '$args{file}': $!";
print {$fh} $template;
print {$fh} "\n__DATA__\n";
sub feature {
my ($package, $key) = @_;
return $features->{$key} if exists $features->{$key};
-
+
my $info = $auto_features->{$key} or return 0;
-
+
# Under perl 5.005, each(%$foo) isn't working correctly when $foo
# was reanimated with Data::Dumper and eval(). Not sure why, but
# copying to a new hash seems to solve it.
my %info = %$info;
-
+
require Module::Build; # XXX should get rid of this
while (my ($type, $prereqs) = each %info) {
next if $type eq 'description' || $type eq 'recommends';
-
+
my %p = %$prereqs; # Ditto here.
while (my ($modname, $spec) = each %p) {
my $status = Module::Build->check_installed_status($modname, $spec);
use NOTES_NAME;
$value = NOTES_NAME->config('foo');
$value = NOTES_NAME->feature('bar');
-
+
@names = NOTES_NAME->config_names;
@names = NOTES_NAME->feature_names;
-
+
NOTES_NAME->set_config(foo => $new_value);
NOTES_NAME->set_feature(bar => $new_value);
NOTES_NAME->write; # Save changes
use strict;
use Config;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
# This code is mostly borrowed from ExtUtils::MM_Unix 6.10_03, with a
'<' => '<',
);
my $rx = join '|', keys %escapes;
-
+
sub _simple_xml_escape {
$_[1] =~ s/($rx)/$escapes{$1}/go;
}
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Base;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Base;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Base;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Base;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Base;
use vars qw(@ISA);
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
-
+
# $Config{sitelib} and $Config{sitearch} are, unfortunately, missing.
foreach ('sitelib', 'sitearch') {
$self->config($_ => $self->config("install$_"))
unless $self->config($_);
}
-
+
# For some reason $Config{startperl} is filled with a bunch of crap.
(my $sp = $self->config('startperl')) =~ s/.*Exit \{Status\}\s//;
$self->config(startperl => $sp);
-
+
return $self;
}
if( !@_ and !@ARGV ) {
require MacPerl;
-
+
# What comes first in the action list.
my @action_list = qw(build test install);
my %actions = map {+($_, 1)} $self->known_actions;
foreach (@action_list) {
$_ .= ' *' if $toolserver{$_};
}
-
+
my $cmd = MacPerl::Pick("What build command? ('*' requires ToolServer)", @action_list);
return unless defined $cmd;
$cmd =~ s/ \*$//;
$ARGV[0] = ($cmd);
-
+
my $args = MacPerl::Ask('Any extra arguments? (ie. verbose=1)', '');
return unless defined $args;
push @ARGV, $self->split_like_shell($args);
}
-
+
$self->SUPER::dispatch(@_);
}
sub ACTION_install {
my $self = shift;
-
+
return $self->SUPER::ACTION_install(@_)
if eval {ExtUtils::Install->VERSION('1.30'); 1};
-
+
local $^W = 0; # Avoid a 'redefine' warning
local *ExtUtils::Install::find = sub {
my ($code, @dirs) = @_;
return File::Find::find($code, @dirs);
};
-
+
return $self->SUPER::ACTION_install(@_);
}
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Base;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Base;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Base;
use Config;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Base;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Config;
# into words. The algorithm below was bashed out by Randy and Ken
# (mostly Randy), and there are a lot of regression tests, so we
# should feel free to adjust if desired.
-
+
(my $self, local $_) = @_;
-
+
return @$_ if defined() && UNIVERSAL::isa($_, 'ARRAY');
-
+
my @argv;
return @argv unless defined() && length();
-
+
my $arg = '';
my( $i, $quote_mode ) = ( 0, 0 );
-
+
while ( $i < length() ) {
-
+
my $ch = substr( $_, $i , 1 );
my $next_ch = substr( $_, $i+1, 1 );
-
+
if ( $ch eq '\\' && $next_ch eq '"' ) {
$arg .= '"';
$i++;
} else {
$arg .= $ch;
}
-
+
$i++;
}
-
+
push( @argv, $arg ) if defined( $arg ) && length( $arg );
return @argv;
}
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Platform::Unix;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Platform::Unix;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Platform::Unix;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Module::Build::Platform::Unix;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use vars qw(@ISA);
sub _myparse_from_filehandle {
my ($self, $fh) = @_;
-
+
local $_;
while (<$fh>) {
next unless /^=(?!cut)/ .. /^=cut/; # in POD
last if ($self->{abstract}) = /^ (?: [a-z:]+ \s+ - \s+ ) (.*\S) /ix;
}
-
+
my @author;
while (<$fh>) {
next unless /^=head1\s+AUTHORS?/i ... /^=/;
}
return unless @author;
s/^\s+|\s+$//g foreach @author;
-
+
$self->{author} = \@author;
-
+
return;
}
sub get_abstract {
my $self = shift;
return $self->{abstract} if defined $self->{abstract};
-
+
$self->parse_from_filehandle($self->{fh});
return $self->{abstract};
sub get_author {
my $self = shift;
return $self->{author} if defined $self->{author};
-
+
$self->parse_from_filehandle($self->{fh});
return $self->{author} || [];
map { $args{$_} = 1 } @_
}
else { # no parameters at all on use line
- %args =
+ %args =
(
qv => 1,
'UNIVERSAL::VERSION' => 1,
}
my $callpkg = caller();
-
+
if (exists($args{declare})) {
- *{$callpkg."::declare"} =
+ *{$callpkg."::declare"} =
sub {return $class->declare(shift) }
unless defined(&{$callpkg.'::declare'});
}
{
my ($class, $value) = @_;
my $self = bless ({}, ref ($class) || $class);
-
+
if ( ref($value) && eval('$value->isa("version")') ) {
# Can copy the elements directly
$self->{version} = [ @{$value->{version} } ];
$value = sprintf("%.9f",$value);
$value =~ s/(0+)$//; # trim trailing zeros
}
-
+
# This is not very efficient, but it is morally equivalent
# to the XS code (as that is the reference implementation).
# See vutil/vutil.c for details
}
$start = $last = $pos = $s;
-
+
# pre-scan the input string to check for decimals/underbars
while ( substr($value,$pos,1) =~ /[._\d,]/ ) {
if ( substr($value,$pos,1) eq '.' ) {
$orev = $rev;
$rev += substr($value,$s,1) * $mult;
$mult /= 10;
- if ( abs($orev) > abs($rev)
+ if ( abs($orev) > abs($rev)
|| abs($rev) > abs($VERSION_MAX) ) {
if ( warnings::enabled("overflow") ) {
require Carp;
$orev = $rev;
$rev += substr($value,$end,1) * $mult;
$mult *= 10;
- if ( abs($orev) > abs($rev)
+ if ( abs($orev) > abs($rev)
|| abs($rev) > abs($VERSION_MAX) ) {
if ( warnings::enabled("overflow") ) {
require Carp;
# Append revision
push @{$self->{version}}, $rev;
- if ( substr($value,$pos,1) eq '.'
+ if ( substr($value,$pos,1) eq '.'
&& substr($value,$pos+1,1) =~ /\d/ ) {
$s = ++$pos;
}
- elsif ( substr($value,$pos,1) eq '_'
+ elsif ( substr($value,$pos,1) eq '_'
&& substr($value,$pos+1,1) =~ /\d/ ) {
$s = ++$pos;
}
- elsif ( substr($value,$pos,1) eq ','
+ elsif ( substr($value,$pos,1) eq ','
&& substr($value,$pos+1,1) =~ /\d/ ) {
$s = ++$pos;
}
*parse = \&new;
-sub numify
+sub numify
{
my ($self) = @_;
unless (_verify($self)) {
return $string;
}
-sub normal
+sub normal
{
my ($self) = @_;
unless (_verify($self)) {
require Carp;
Carp::croak("Invalid version object");
}
- return exists $self->{original}
- ? $self->{original}
- : exists $self->{qv}
+ return exists $self->{original}
+ ? $self->{original}
+ : exists $self->{qv}
? $self->normal
: $self->numify;
}
}
# tiebreaker for alpha with identical terms
- if ( $retval == 0
- && $l == $r
+ if ( $retval == 0
+ && $l == $r
&& $left->{version}[$m] == $right->{version}[$m]
&& ( $lalpha || $ralpha ) ) {
}
}
- return $retval;
+ return $retval;
}
sub vbool {
return vcmp($self,$self->new("0"),1);
}
-sub vnoop {
- require Carp;
+sub vnoop {
+ require Carp;
Carp::croak("operation not supported with version object");
}
if ( defined $req ) {
unless ( defined $version ) {
require Carp;
- my $msg = $] < 5.006
+ my $msg = $] < 5.006
? "$class version $req required--this is only version "
: "$class does not define \$$class\::VERSION"
."--version check failed";
if ( $req > $version ) {
require Carp;
if ( $req->is_qv ) {
- Carp::croak(
+ Carp::croak(
sprintf ("%s version %s required--".
"this is only version %s", $class,
$req->normal, $version->normal)
);
}
else {
- Carp::croak(
+ Carp::croak(
sprintf ("%s version %s required--".
"this is only version %s", $class,
$req->stringify, $version->stringify)
# Class structure
require 5.004;
-
+
$Module::Build::YAML::VERSION = '1.40';
# Error storage
if ( wantarray ) {
return @$self;
} else {
- # Return only the last document to match YAML.pm,
+ # Return only the last document to match YAML.pm,
return $self->[-1];
}
}
package inc::latest;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use Carp;
my ($package, $mod, @args) = @_;
return unless(defined $mod);
- my $inc_path = './inc/latest.pm';
- my $private_path = './inc/latest/private.pm';
- if(-e $inc_path) {
- # delete our methods
- delete $inc::latest::{$_} for(keys %inc::latest::);
- # load the bundled module
- require $inc_path;
+ my $private_path = 'inc/latest/private.pm';
+ if(-e $private_path) {
+ # user mode - delegate work to bundled private module
require $private_path;
- my $import = inc::latest->can('import');
- goto $import;
+ splice( @_, 0, 1, 'inc::latest::private');
+ goto \&inc::latest::private::import;
}
- # author mode - just record and load the modules
+ # author mode - just record and load the modules
push(@loaded_modules, $mod);
require inc::latest::private;
goto \&inc::latest::private::_load_module;
sub bundle_module {
my ($package, $module, $where) = @_;
-
+
# create inc/inc_$foo
(my $dist = $module) =~ s{::}{-}g;
my $inc_lib = File::Spec->catdir($where,"inc_$dist");
The C<inc::latest> module helps bootstrap configure-time dependencies for CPAN
distributions. These dependencies get bundled into the C<inc> directory within
-a distribution and are used by Build.PL (or Makefile.PL).
+a distribution and are used by Build.PL (or Makefile.PL).
Arguments to C<inc::latest> are module names that are checked against both the
current C<@INC> array and against specially-named directories in C<inc>. If
package inc::latest::private;
use strict;
use vars qw($VERSION);
-$VERSION = '0.35_09';
+$VERSION = '0.35_14';
$VERSION = eval $VERSION;
use File::Spec;
# A bundled copy must be present
my ($bundled, $bundled_dir) = $package->_search_bundled($file)
or die "No bundled copy of $mod found";
-
+
my $from_inc = $package->_search_INC($file);
unless ($from_inc) {
# Only bundled is available
while (defined(my $e = readdir DH)) {
next unless $e =~ /^inc_/;
my $try = File::Spec->catfile($mypath, $e, $file);
-
+
return($try, File::Spec->catdir($mypath, $e)) if -e $try;
}
return;
-#!/usr/bin/perl
+#!/opt/perl/5.10.1/bin/perl
+
+eval 'exec /opt/perl/5.10.1/bin/perl -S $0 ${1+"$@"}'
+ if 0; # not running under some shell
use strict;
use Module::Build 0.25;
$mod =~ /^([\w:]+)$/
or die "Invalid module name '$mod'";
-
+
my $cf = $mod . "::ConfigData";
eval "require $cf";
die $@ if $@;
my %defs = @_;
my $out = "\nUsage: $0 [options]\n\n Options include:\n";
-
+
foreach my $name (sort keys %defs) {
$out .= " --$name";
-
+
for ($defs{$name}{type}) {
/^=s$/ and $out .= " <string>";
/^=s%$/ and $out .= " <string>=<value>";
# Get config/feature values
config_data --module Foo::Bar --feature bazzable
config_data --module Foo::Bar --config magic_number
-
+
# Set config/feature values
config_data --module Foo::Bar --set_feature bazzable=1
config_data --module Foo::Bar --set_config magic_number=42
-
+
# Print a usage message
config_data --help
--- /dev/null
+use strict;
+use warnings;
+use lib 't/lib';
+use MBTest;
+use File::Find qw/find/;
+
+my @files;
+find( sub { -f && /\.pm$/ && push @files, $File::Find::name }, 'lib' );
+
+plan tests => scalar @files;
+
+for my $f ( sort @files ) {
+ my $ec;
+ my $output = stdout_stderr_of( sub { $ec = system( $^X, '-c', $f ) } );
+ ok( ! $ec, "compiling $f" ) or diag $output;
+}
+
use IO::File;
use File::Spec;
use ExtUtils::Packlist;
+use ExtUtils::Installed;
use File::Path;
# Ensure any Module::Build modules are loaded from correct directory
if ( $ENV{PERL_CORE} ) {
plan skip_all => 'bundle_inc tests will never succeed in PERL_CORE';
}
+elsif ( ! MBTest::check_EUI() ) {
+ plan skip_all => 'ExtUtils::Installed takes too long on your system';
+}
elsif ( Module::Build::ConfigData->feature('inc_bundling_support') ) {
- plan tests => 18;
+ plan tests => 19;
} else {
plan skip_all => 'inc_bundling_support feature is not enabled';
}
unshift @INC, $lib_path, $arch_path;
local $ENV{PERL5LIB} = join( $Config{path_sep},
- $lib_path, $arch_path, ($ENV{PERL5LIB} ? $ENV{PERL5LIB} : () )
+ $lib_path, ($ENV{PERL5LIB} ? $ENV{PERL5LIB} : () )
);
-stdout_of( sub { $current_mb->dispatch('install', install_base => $temp_install) } );
+# must uninst=0 so we don't try to remove an installed M::B!
+stdout_of( sub { $current_mb->dispatch(
+ 'install', install_base => $temp_install, uninst => 0
+ )
+ }
+);
# create dist object in a temp directory
# enter the directory and generate the skeleton files
"Module::Build is flagged for bundling"
);
-# see what gets bundled
+# bundle stuff into distdir
stdout_stderr_of( sub { $mb->dispatch('distdir') } );
my $dist_inc = File::Spec->catdir($mb->dist_dir, 'inc');
ok( -e File::Spec->catfile( $dist_inc, 'latest.pm' ),
- "./inc/latest.pm created"
+ "dist_dir/inc/latest.pm created"
);
ok( -d File::Spec->catdir( $dist_inc, 'inc_Module-Build' ),
eval {
my $fh;
+ chmod 0666, $mb_file;
$fh = IO::File->new($mb_file, "<") or die "Could not read $mb_file: $!";
my $mb_code = do { local $/; <$fh> };
$mb_code =~ s{\$VERSION\s+=\s+\S+}{\$VERSION = 9999;};
chdir $mb->dist_dir;
stdout_of( sub { Module::Build->run_perl_script('Build.PL',[],[]) } );
+ ok( -e 'MYMETA.yml', 'MYMETA was created' );
my $meta = IO::File->new('MYMETA.yml');
- ok( $meta, "found MYMETA.yml" );
+ ok( $meta, "opened MYMETA.yml" );
ok( scalar( grep { /generated_by:.*9999/ } <$meta> ),
"dist_dir Build.PL loaded bundled Module::Build"
);
+ close $meta;
#--------------------------------------------------------------------------#
# test identification of dependencies
use vars qw($VERSION @ISA);
@ISA = qw(Module::Build);
$VERSION = 0.01;
-
+
# Add a new property.
ok(__PACKAGE__->add_property('foo'));
# Add a new property with a default value.
ok(__PACKAGE__->add_property('bar', 'hey'));
# Add a hash property.
ok(__PACKAGE__->add_property('hash', {}));
-
-
+
+
# Catch an exception adding an existing property.
eval { __PACKAGE__->add_property('module_name')};
like "$@", qr/already exists/;
use vars qw($VERSION @ISA);
@ISA = qw(Module::Build);
$VERSION = 0.01;
-
+
# Add a new property with a different default value than MBSub has.
ok(__PACKAGE__->add_property('bar', 'yow'));
}
isa_ok $mb, 'MBSub';
ok $mb->valid_property('foo');
can_ok $mb, 'module_name';
-
+
# Check foo property.
can_ok $mb, 'foo';
ok ! $mb->foo;
ok $mb->foo(1);
ok $mb->foo;
-
+
# Check bar property.
can_ok $mb, 'bar';
is $mb->bar, 'hey';
ok $mb->bar('you');
is $mb->bar, 'you';
-
+
# Check hash property.
ok $mb = MBSub->new(
module_name => $dist->name,
hash => { foo => 'bar', bin => 'foo'}
);
-
+
can_ok $mb, 'hash';
isa_ok $mb->hash, 'HASH';
is $mb->hash->{foo}, 'bar';
is $mb->hash->{bin}, 'foo';
-
+
# Check hash property passed via the command-line.
{
local @ARGV = (
isa_ok $mb->hash, 'HASH';
is $mb->hash->{foo}, 'bar';
is $mb->hash->{bin}, 'foo';
-
+
# Make sure that a different subclass with the same named property has a
# different default.
ok $mb = MBSub2->new( module_name => $dist->name );
meta_add => {foo => 'bar'},
conflicts => {'Foo::Barxx' => 0},
);
- my $data = $mb->prepare_metadata;
+ my $data = $mb->get_metadata;
is $data->{foo}, 'bar';
$mb->meta_merge(foo => 'baz');
- $data = $mb->prepare_metadata;
+ $data = $mb->get_metadata;
is $data->{foo}, 'baz';
$mb->meta_merge(conflicts => {'Foo::Fooxx' => 0});
- $data = $mb->prepare_metadata;
+ $data = $mb->get_metadata;
is_deeply $data->{conflicts}, {'Foo::Barxx' => 0, 'Foo::Fooxx' => 0};
$mb->meta_add(conflicts => {'Foo::Bazxx' => 0});
- $data = $mb->prepare_metadata;
+ $data = $mb->get_metadata;
is_deeply $data->{conflicts}, {'Foo::Bazxx' => 0, 'Foo::Fooxx' => 0};
}
blib_load('Module::Build');
-use File::Spec::Functions qw( catdir );
+use File::Spec::Functions qw( catdir catfile );
my $tmp = MBTest->tmpdir;
my $output;
$build->create_build_script();
===EOF===
-
+
#Test Build.PL exists ok?
$dist->add_file("etc/config", <<'===EOF===');
$output = stdout_of sub { $dist->run_build('install') };
$error = 0;
-$error++ unless ok(-e "$installdest/etc/simple/config", "installed etc/config");
-$error++ unless ok(-e "$installdest/shared/simple/data", "installed shared/data");
-$error++ unless ok(-e "$installdest/shared/simple/html/index.html", "installed shared/html");
+$error++ unless ok(-e catfile($installdest, qw/etc simple config/), "installed etc/config");
+$error++ unless ok(-e catfile($installdest, qw/shared simple data/), "installed shared/data");
+$error++ unless ok(-e catfile($installdest, qw/shared simple html index.html/), "installed shared/html");
diag "OUTPUT:\n$output" if $error;
sub dirname {
my $self = shift;
- my $dist = join( '-', split( /::/, $self->{name} ) );
+ my $dist = $self->{distdir} || join( '-', split( /::/, $self->{name} ) );
return File::Spec->catdir( $self->{dir}, $dist );
}
=item dir
The (parent) directory in which to create the distribution directory. The
-distribution will be created under this according to the "dist" form of C<name>
-(e.g. "Foo-Bar".) Defaults to a temporary directory.
+distribution will be created under this according to C<distdir> parameter
+below. Defaults to a temporary directory.
$dist = DistGen->new( dir => '/tmp/MB-test' );
$dist->regen;
# distribution files have been created in /tmp/MB-test/Simple
+=item distdir
+
+The name of the distribution directory to create. Defaults to the dist form of
+C<name>, e.g. 'Foo-Bar' if C<name> is 'Foo::Bar'.
+
=item xs
If true, generates an XS based module.
use strict;
+use IO::File ();
use File::Spec;
use File::Temp ();
use File::Path ();
check_compiler
have_module
blib_load
+ timed_out
);
push @EXPORT, @extra_exports;
__PACKAGE__->export(scalar caller, @extra_exports);
{ # backwards compatible temp filename recipe adapted from perlfaq
my $tmp_count = 0;
- my $tmp_base_name = sprintf("%d-%d", $$, time());
+ my $tmp_base_name = sprintf("MB-%d-%d", $$, time());
sub temp_file_name {
sprintf("%s-%04d", $tmp_base_name, ++$tmp_count)
}
sub save_handle {
my ($handle, $subr) = @_;
- my $outfile = temp_file_name();
+ my $outfile = File::Spec->catfile(File::Spec->tmpdir, temp_file_name());
local *SAVEOUT;
open SAVEOUT, ">&" . fileno($handle)
}
}
+sub timed_out {
+ my ($sub, $timeout) = @_;
+ return unless $sub;
+ $timeout ||= 60;
+
+ my $saw_alarm = 0;
+ eval {
+ local $SIG{ALRM} = sub { $saw_alarm++; die "alarm\n"; }; # NB: \n required
+ alarm $timeout;
+ $sub->();
+ alarm 0;
+ };
+ if ($@) {
+ die unless $@ eq "alarm\n"; # propagate unexpected errors
+ }
+ return $saw_alarm;
+}
+
+sub check_EUI {
+ my $timed_out;
+ stdout_stderr_of( sub {
+ $timed_out = timed_out( sub {
+ ExtUtils::Installed->new(extra_libs => [@INC])
+ }
+ );
+ }
+ );
+ return ! $timed_out;
+}
+
1;
# vim:ts=2:sw=2:et:sta
my $tmp = MBTest->tmpdir;
-my %metadata =
+my %metadata =
(
module_name => 'Simple',
dist_version => '3.14159265',
{
my $mb_prereq = { 'Module::Build' => $Module::Build::VERSION };
- my $mb_config_req = {
- 'Module::Build' => int($Module::Build::VERSION * 100)/100
+ my $mb_config_req = {
+ 'Module::Build' => int($Module::Build::VERSION * 100)/100
};
- my $node = $mb->prepare_metadata( );
+ my $node = $mb->get_metadata( );
# exists() doesn't seem to work here
is $node->{name}, $metadata{module_name};
{
my $mb_prereq = { 'Module::Build' => 0 };
$mb->configure_requires( $mb_prereq );
- my $node = $mb->prepare_metadata( );
+ my $node = $mb->get_metadata( );
# exists() doesn't seem to work here
$VERSION = version->new('0.61.' . (qw$Revision: 129 $)[1]);
---
$dist->regen;
- my $provides = new_build()->prepare_metadata()->{provides};
+ my $provides = new_build()->get_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";
+ is ref($provides->{'Simple'}{version}), '', "Versions from get_metadata() aren't refs";
+ is ref($provides->{'Simple::Simon'}{version}), '', "Versions from get_metadata() aren't refs";
}
use strict;
use lib 't/lib';
-use MBTest tests => 3;
+use MBTest;
+plan tests => 24;
blib_load('Module::Build');
+blib_load('Module::Build::YAML');
my $tmp = MBTest->tmpdir;
use DistGen;
my $dist = DistGen->new( dir => $tmp );
+$dist->change_file('Build.PL', <<"---");
+use strict;
+use Module::Build;
+
+my \$builder = Module::Build->new(
+ module_name => '$dist->{name}',
+ license => 'perl',
+ requires => {
+ 'File::Spec' => ( \$ENV{BUMP_PREREQ} ? 0.86 : 0 ),
+ },
+);
+
+\$builder->create_build_script();
+---
$dist->regen;
$dist->chdir_in;
# Test MYMETA generation
{
+ ok( ! -e "META.yml", "META.yml doesn't exist before Build.PL runs" );
ok( ! -e "MYMETA.yml", "MYMETA.yml doesn't exist before Build.PL runs" );
my $output;
$output = stdout_of sub { $dist->run_build_pl };
like($output, qr/Creating new 'MYMETA.yml' with configuration results/,
- "Saw MYMETA.yml creation message"
+ "Ran Build.PL and saw MYMETA.yml creation message"
+ );
+ ok( -e "MYMETA.yml", "MYMETA.yml exists" );
+}
+
+#########################
+
+# Test interactions between META/MYMETA
+{
+ my $output = stdout_of sub { $dist->run_build('distmeta') };
+ like($output, qr/Creating META.yml/,
+ "Ran Build distmeta to create META.yml");
+ my $meta = Module::Build::YAML->read('META.yml')->[0];
+ my $mymeta = Module::Build::YAML->read('MYMETA.yml')->[0];
+ is( delete $mymeta->{dynamic_config}, 0,
+ "MYMETA 'dynamic_config' is 0"
+ );
+ is_deeply( $meta, $mymeta, "Other generated MYMETA matches generated META" );
+ $output = stdout_stderr_of sub { $dist->run_build('realclean') };
+ like( $output, qr/Cleaning up/, "Ran realclean");
+ ok( ! -e 'Build', "Build file removed" );
+ ok( ! -e 'MYMETA.yml', "MYMETA file removed" );
+
+ # test that dynamic prereq is picked up
+ local $ENV{BUMP_PREREQ} = 1;
+ $output = stdout_of sub { $dist->run_build_pl };
+ like($output, qr/Creating new 'MYMETA.yml' with configuration results/,
+ "Ran Build.PL with dynamic config"
);
ok( -e "MYMETA.yml", "MYMETA.yml exists" );
+ $mymeta = Module::Build::YAML->read('MYMETA.yml')->[0];
+ isnt( $meta->{requires}{'File::Spec'},
+ $mymeta->{requires}{'File::Spec'},
+ "MYMETA requires differs from META"
+ );
+ $output = stdout_stderr_of sub { $dist->run_build('realclean') };
+ like( $output, qr/Cleaning up/, "Ran realclean");
+ ok( ! -e 'Build', "Build file removed" );
+ ok( ! -e 'MYMETA.yml', "MYMETA file removed" );
+
+ # manually change META and check that changes are preserved
+ $meta->{author} = ['John Gault'];
+ ok( Module::Build::YAML->new($meta)->write('META.yml'),
+ "Wrote manually modified META.yml" );
+
+ $output = stdout_of sub { $dist->run_build_pl };
+ like($output, qr/Creating new 'MYMETA.yml' with configuration results/,
+ "Ran Build.PL"
+ );
+ my $mymeta2 = Module::Build::YAML->read('MYMETA.yml')->[0];
+ is_deeply( $mymeta2->{author}, [ 'John Gault' ],
+ "MYMETA preserved META modifications"
+ );
+
+
+
}
#########################
+# Test cleanup
+{
+ my $output = stdout_stderr_of sub { $dist->run_build('distcheck') };
+ like($output, qr/Creating a temporary 'MANIFEST.SKIP'/,
+ "MANIFEST.SKIP created for distcheck"
+ );
+ unlike($output, qr/MYMETA/,
+ "MYMETA not flagged by distcheck"
+ );
+}
+
+
+{
+ my $output = stdout_of sub { $dist->run_build_pl };
+ like($output, qr/Creating new 'MYMETA.yml' with configuration results/,
+ "Ran Build.PL and saw MYMETA.yml creation message"
+ );
+ $output = stdout_stderr_of sub { $dist->run_build('distclean') };
+ ok( ! -f 'MYMETA.yml', "No MYMETA.yml after distclean" );
+ ok( ! -f 'MANIFEST.SKIP', "No MANIFEST.SKIP after distclean" );
+}
+
+
plan skip_all => 'No compiler found';
} elsif ( !$Config{usedl} ) {
plan skip_all => 'Perl not compiled for dynamic loading'
+ } elsif ( ! $HTML_support ) {
+ plan skip_all => "HTML support not installed";
} elsif ( ! eval {require Archive::Tar} ) {
plan skip_all => "Archive::Tar not installed to read archives.";
} elsif ( ! eval {IO::Zlib->VERSION(1.01)} ) {
# Ensure any Module::Build modules are loaded from correct directory
blib_load('Module::Build');
-# enter the directory and generate the skeleton files
-my $dist = DistGen->new( name => "Not::So::Simple" )->chdir_in;
+my $dist;
#--------------------------------------------------------------------------#
-# try getting module_name from dist directory name
+# try getting module_name from dist_name
#--------------------------------------------------------------------------#
+$dist = DistGen->new(
+ name => "Not::So::Simple",
+ distdir => 'Random-Name',
+)->chdir_in;
+
$dist->change_build_pl(
- dist_name => 'Random-Name',
+ dist_name => 'Not-So-Simple',
dist_version => 1,
)->regen;
my $mb = $dist->new_from_context();
isa_ok( $mb, "Module::Build" );
is( $mb->module_name, "Not::So::Simple",
- "module_name guessed from directory name"
+ "module_name guessed from dist_name"
);
#--------------------------------------------------------------------------#
# Test without a 'share' dir
ok( $mb, "Created Module::Build object" );
is( $mb->share_dir, undef,
- "default share undef if no 'share' dir exists"
+ "default share_dir undef if no 'share' dir exists"
);
ok( ! exists $mb->{properties}{requires}{'File::ShareDir'},
"File::ShareDir not added to 'requires'"
# Check default when share_dir is not given
stdout_stderr_of( sub { $mb = $dist->new_from_context });
-is_deeply( $mb->share_dir, { dist => [ 'share' ] },
- "Default share_dir set as dist-type share"
+is( $mb->share_dir, undef,
+ "Default share_dir is undef even if 'share' exists"
);
-is( $mb->{properties}{requires}{'File::ShareDir'}, '1.00',
- "File::ShareDir 1.00 added to 'requires'"
+ok( ! exists $mb->{properties}{requires}{'File::ShareDir'},
+ "File::ShareDir not added to 'requires'"
);
+
# share_dir set to scalar
$dist->change_build_pl(
{
is_deeply( $mb->_find_share_dir_files,
{
- catfile(qw/share foo.txt/) => catfile(qw/dist Simple-Share foo.txt/),
- catfile(qw/other share bar.txt/) => catfile(qw/module Simple-Share bar.txt/),
+ "share/foo.txt" => "dist/Simple-Share/foo.txt",
+ "other/share/bar.txt" => "module/Simple-Share/bar.txt",
},
"share_dir filemap for copying to lib complete"
);
my $tmp = MBTest->tmpdir;
use DistGen;
-my $dist = DistGen->new( dir => $tmp );
+my $dist = DistGen->new();
$dist->change_build_pl
({
module_name => 'Simple',
$vms_efs = VMS::Feature::current("efs_charset");
} else {
my $efs_charset = $ENV{'DECC$EFS_CHARSET'} || '';
- $vms_efs = $efs_charset =~ /^[ET1]/i;
+ $vms_efs = $efs_charset =~ /^[ET1]/i;
}
$Is_VMS_noefs = 0 if $vms_efs;
if ($Is_VMS_noefs) {
};
$all_ok &&= is($@, '');
$all_ok &&= like($output, qr/all tests successful/i);
-
+
# This is the output of lib/Simple/Script.PL
$all_ok &&= ok(-e $mb->localize_file_path('lib/Simple/Script'));
stdout_of( sub { $mb->dispatch('disttest') } )
};
is $@, '';
-
+
# After a test, the distdir should contain a blib/ directory
ok -e File::Spec->catdir('Simple-0.01', 'blib');
-
+
eval {$mb->dispatch('distdir')};
is $@, '';
-
+
# The 'distdir' should contain a lib/ directory
ok -e File::Spec->catdir('Simple-0.01', 'lib');
-
+
# The freshly run 'distdir' should never contain a blib/ directory, or
# else it could get into the tarball
ok ! -e File::Spec->catdir('Simple-0.01', 'blib');
# Make sure the 'script' file was recognized as a script.
my $scripts = $mb->script_files;
ok $scripts->{script};
-
+
# Check that a shebang line is rewritten
my $blib_script = File::Spec->catfile( qw( blib script script ) );
ok -e $blib_script;
-
+
SKIP: {
skip("We do not rewrite shebang on VMS", 1) if $^O eq 'VMS';
my $fh = IO::File->new($blib_script);
echo Hello, World!
---
- $dist = DistGen->new( dir => $tmp );
+ $dist = DistGen->new();
$dist->change_build_pl({
module_name => 'Simple',
scripts => [ 'bin/script.bat' ],