module-build-checkins Mailing List for Module::Build (Page 30)
Status: Beta
Brought to you by:
kwilliams
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(82) |
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(49) |
Feb
(57) |
Mar
(49) |
Apr
(49) |
May
(2) |
Jun
(147) |
Jul
(60) |
Aug
(55) |
Sep
(51) |
Oct
(68) |
Nov
(61) |
Dec
(44) |
2006 |
Jan
(27) |
Feb
(38) |
Mar
(89) |
Apr
(31) |
May
(17) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Ken W. <kwi...@us...> - 2005-04-13 01:08:29
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30752/t Modified Files: install.t Log Message: Switch to Test::More Index: install.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/install.t,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- install.t 12 Apr 2005 03:43:10 -0000 1.17 +++ install.t 13 Apr 2005 01:08:20 -0000 1.18 @@ -1,15 +1,16 @@ use strict; -use Test; -BEGIN { plan tests => 31 } +use File::Spec; +BEGIN { + my $common_pl = File::Spec->catfile('t', 'common.pl'); + require $common_pl; +} +use Test::More (tests => 34); use Module::Build; -use File::Spec; use File::Path; use Config; -my $common_pl = File::Spec->catfile('t', 'common.pl'); -require $common_pl; my $start_dir = Module::Build->cwd; @@ -30,7 +31,7 @@ { eval {$build->dispatch('install', destdir => $destdir)}; - ok $@, ''; + is $@, ''; my $libdir = strip_volume( $build->install_destination('lib') ); my $install_to = File::Spec->catfile($destdir, $libdir, 'Sample.pm'); @@ -39,18 +40,18 @@ local @INC = (@INC, File::Spec->catdir($destdir, $libdir)); eval {require Sample}; - ok $@, ''; + is $@, ''; # Make sure there's a packlist installed my $archdir = $build->install_destination('arch'); my ($v, $d) = File::Spec->splitpath($archdir, 1); my $packlist = File::Spec->catdir($destdir, $d, 'auto', 'Sample', '.packlist'); - ok -e $packlist, 1, "$packlist should be written"; + is -e $packlist, 1, "$packlist should be written"; } { eval {$build->dispatch('install', installdirs => 'core', destdir => $destdir)}; - ok $@, ''; + is $@, ''; my $libdir = strip_volume( $Config{installprivlib} ); my $install_to = File::Spec->catfile($destdir, $libdir, 'Sample.pm'); print "Should have installed module as $install_to\n"; @@ -60,7 +61,7 @@ { my $libdir = File::Spec->catdir(File::Spec->rootdir, 'foo', 'bar'); eval {$build->dispatch('install', install_path => {lib => $libdir}, destdir => $destdir)}; - ok $@, ''; + is $@, ''; my $install_to = File::Spec->catfile($destdir, $libdir, 'Sample.pm'); print "Should have installed module as $install_to\n"; ok -e $install_to; @@ -69,7 +70,7 @@ { my $libdir = File::Spec->catdir(File::Spec->rootdir, 'foo', 'base'); eval {$build->dispatch('install', install_base => $libdir, destdir => $destdir)}; - ok $@, ''; + is $@, ''; my $install_to = File::Spec->catfile($destdir, $libdir, 'lib', 'perl5', 'Sample.pm'); print "Should have installed module as $install_to\n"; ok -e $install_to; @@ -79,27 +80,31 @@ # Test the ConfigData stuff $build->config_data(foo => 'bar'); - $build->feature(baz => 1); + $build->features(baz => 1); + $build->auto_features(auto_foo => {requires => {'File::Spec' => 0}}); eval {$build->dispatch('install', destdir => $destdir)}; - ok $@, ''; + is $@, ''; my $libdir = strip_volume( $build->install_destination('lib') ); local @INC = (@INC, File::Spec->catdir($destdir, $libdir)); eval {require Sample::ConfigData}; - - if ($@) { - ok $@, ''; # Show what the failure was - skip_subtest("Couldn't reload ConfigData") for 1..3; - } else { + is $build->feature('auto_foo'), 1; + + SKIP: + { + skip $@, 5 if @_; # Make sure the values are present - ok( Sample::ConfigData->config('foo'), 'bar' ); + is( Sample::ConfigData->config('foo'), 'bar' ); ok( Sample::ConfigData->feature('baz') ); + ok( Sample::ConfigData->feature('auto_foo') ); + ok( not Sample::ConfigData->feature('nonexistent') ); +<STDIN>; # Add a new value to the config set Sample::ConfigData->set_config(floo => 'bhlar'); - ok( Sample::ConfigData->config('floo'), 'bhlar' ); + is( Sample::ConfigData->config('floo'), 'bhlar' ); # Make sure it actually got written Sample::ConfigData->write; @@ -108,22 +113,22 @@ local $^W; # Avoid warnings for subroutine redefinitions require Sample::ConfigData; } - ok( Sample::ConfigData->config('floo'), 'bhlar' ); + is( Sample::ConfigData->config('floo'), 'bhlar' ); } } eval {$build->dispatch('realclean')}; -ok $@, ''; +is $@, ''; { # Try again by running the script rather than with programmatic interface my $libdir = File::Spec->catdir('', 'foo', 'lib'); eval {$build->run_perl_script('Build.PL', [], ['--install_path', "lib=$libdir"])}; - ok $@, ''; + is $@, ''; eval {$build->run_perl_script('Build', [], ['install', '--destdir', $destdir])}; - ok $@, ''; + is $@, ''; my $install_to = File::Spec->catfile($destdir, $libdir, 'Sample.pm'); print "# Should have installed module as $install_to\n"; ok -e $install_to; @@ -131,13 +136,13 @@ my $basedir = File::Spec->catdir('', 'bar'); eval {$build->run_perl_script('Build', [], ['install', '--destdir', $destdir, '--install_base', $basedir])}; - ok $@, ''; + is $@, ''; $install_to = File::Spec->catfile($destdir, $libdir, 'Sample.pm'); - ok -e $install_to, 1, "Look for file at $install_to"; + is -e $install_to, 1, "Look for file at $install_to"; eval {$build->dispatch('realclean')}; - ok $@, ''; + is $@, ''; } { @@ -146,24 +151,24 @@ install_base => File::Spec->catdir('', 'foo'), install_path => {lib => File::Spec->catdir('', 'bar')}); ok $build; - ok $build->install_destination('lib'), File::Spec->catdir('', 'bar'); + is $build->install_destination('lib'), File::Spec->catdir('', 'bar'); } { # _find_file_by_type() isn't a public method, but this is currently # the only easy way to test that it works properly. my $pods = $build->_find_file_by_type('pod', 'lib'); - ok keys %$pods, 1; + is keys %$pods, 1; my $expect = $build->localize_file_path('lib/Sample/Docs.pod'); - ok $pods->{$expect}, $expect; + is $pods->{$expect}, $expect; my $pms = $build->_find_file_by_type('awefawef', 'lib'); ok $pms; - ok keys %$pms, 0; + is keys %$pms, 0; $pms = $build->_find_file_by_type('pod', 'awefawef'); ok $pms; - ok keys %$pms, 0; + is keys %$pms, 0; } sub strip_volume { |
From: Ken W. <kwi...@us...> - 2005-04-12 20:10:14
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29018/t Modified Files: common.pl Log Message: Push t/lib/ onto @INC here Index: common.pl =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/common.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- common.pl 14 Nov 2004 11:31:28 -0000 1.11 +++ common.pl 12 Apr 2005 20:09:42 -0000 1.12 @@ -1,6 +1,16 @@ use strict; use Config; +# In case the test wants to use Test::More or our other bundled +# modules, make sure they can be loaded. They'll still do "use +# Test::More" in the test script. +BEGIN { + my $t_lib = File::Spec->catdir('t', 'lib'); + push @INC, $t_lib; # Let user's installed version override +} + +use Test(); + sub have_module { my $module = shift; return eval "use $module; 1"; @@ -19,7 +29,7 @@ sub skip_subtest { my $msg = @_ ? shift() : '(no reason given)'; - skip "skip $msg", 1; + Test::skip "skip $msg", 1; } sub save_handle { |
From: Ken W. <kwi...@us...> - 2005-04-12 18:57:57
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19009/lib/Module/Build Modified Files: Base.pm Log Message: Fix a bug in setting new features Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.410 retrieving revision 1.411 diff -u -d -r1.410 -r1.411 --- Base.pm 12 Apr 2005 03:43:10 -0000 1.410 +++ Base.pm 12 Apr 2005 18:57:47 -0000 1.411 @@ -319,18 +319,19 @@ if ($ph->{features}->exists($key)) { return $ph->{features}->access($key, @_) } if (my $info = $ph->{auto_features}->access($key)) { - warn "Checking auto_feature '$key'"; return not $self->prereq_failures($info); } - return; + return $ph->{features}->access($key, @_); } - # No args - get the regular features & add the auto_features - my %features = $ph->{features}->access(); + # No args - get the auto_features & overlay the regular features + my %features; my %auto_features = $ph->{auto_features}->access(); while (my ($name, $info) = each %auto_features) { $features{$name} = not $self->prereq_failures($info); } + %features = (%features, $ph->{features}->access()); + return wantarray ? %features : \%features; } BEGIN { *feature = \&features } |
From: Ken W. <kwi...@us...> - 2005-04-12 03:43:20
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9747/t Modified Files: install.t Log Message: First stab at making auto_features dynamic. Still needs to write to the ConfigData.pm file. Index: install.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/install.t,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- install.t 16 Mar 2005 16:52:29 -0000 1.16 +++ install.t 12 Apr 2005 03:43:10 -0000 1.17 @@ -76,6 +76,8 @@ } { + # Test the ConfigData stuff + $build->config_data(foo => 'bar'); $build->feature(baz => 1); eval {$build->dispatch('install', destdir => $destdir)}; |
From: Ken W. <kwi...@us...> - 2005-04-12 03:43:19
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9747/lib/Module/Build Modified Files: Base.pm Notes.pm Log Message: First stab at making auto_features dynamic. Still needs to write to the ConfigData.pm file. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.409 retrieving revision 1.410 diff -u -d -r1.409 -r1.410 --- Base.pm 10 Apr 2005 17:46:46 -0000 1.409 +++ Base.pm 12 Apr 2005 03:43:10 -0000 1.410 @@ -32,7 +32,7 @@ $self->dist_version; $self->check_manifest; $self->check_prereq; - $self->set_autofeatures; + $self->check_autofeatures; $self->_set_install_paths; $self->_find_nested_builds; @@ -112,12 +112,19 @@ $self->_set_defaults; my ($p, $c, $ph) = ($self->{properties}, $self->{config}, $self->{phash}); - foreach (qw(notes config_data features runtime_params cleanup)) { + foreach (qw(notes config_data features runtime_params cleanup auto_features)) { my $file = File::Spec->catfile($self->config_dir, $_); $ph->{$_} = Module::Build::Notes->new(file => $file); $ph->{$_}->restore if -e $file; + if (exists $p->{$_}) { + my $vals = delete $p->{$_}; + while (my ($k, $v) = each %$vals) { + $self->$_($k, $v); + } + } } + # The following warning could be unnecessary if the user is running # an embedded perl, but there aren't too many of those around, and # embedded perls aren't usually used to install modules, and the @@ -296,11 +303,39 @@ } } +sub current_action { shift->{action} } + sub notes { shift()->{phash}{notes}->access(@_) } sub config_data { shift()->{phash}{config_data}->access(@_) } -sub feature { shift()->{phash}{features}->access(@_) } sub runtime_params { shift->{phash}{runtime_params}->read( @_ ? shift : () ) } # Read-only -sub current_action { shift->{action} } +sub auto_features { shift()->{phash}{auto_features}->access(@_) } + +sub features { + my $self = shift; + my $ph = $self->{phash}; + + if (@_) { + my $key = shift; + if ($ph->{features}->exists($key)) { return $ph->{features}->access($key, @_) } + + if (my $info = $ph->{auto_features}->access($key)) { + warn "Checking auto_feature '$key'"; + return not $self->prereq_failures($info); + } + return; + } + + # No args - get the regular features & add the auto_features + my %features = $ph->{features}->access(); + my %auto_features = $ph->{auto_features}->access(); + while (my ($name, $info) = each %auto_features) { + $features{$name} = not $self->prereq_failures($info); + } + return wantarray ? %features : \%features; +} +BEGIN { *feature = \&features } + + sub add_build_element { my $self = shift; @@ -327,7 +362,8 @@ module => $module_name, config_module => $notes_name, config_data => scalar $self->config_data, - feature => scalar $self->feature, + feature => scalar $self->features, + auto_features => scalar $self->auto_features, ); } @@ -656,7 +692,7 @@ sub has_config_data { my $self = shift; - return scalar grep $self->{phash}{$_}->has_data(), qw(config_data features); + return scalar grep $self->{phash}{$_}->has_data(), qw(config_data features auto_features); } sub _write_dumper { @@ -678,7 +714,7 @@ $self->_write_dumper('prereqs', { map { $_, $self->$_() } @items }); $self->_write_dumper('build_params', [$self->{args}, $self->{config}, $self->{properties}]); - $self->{phash}{$_}->write() foreach qw(notes cleanup features config_data runtime_params); + $self->{phash}{$_}->write() foreach qw(notes cleanup features auto_features config_data runtime_params); } sub config { shift()->{config} } @@ -688,26 +724,22 @@ sub build_requires { shift()->{properties}{build_requires} } sub conflicts { shift()->{properties}{conflicts} } -sub set_autofeatures { +sub check_autofeatures { my ($self) = @_; - my $features = delete $self->{properties}{auto_features} - or return; + my $features = $self->auto_features; while (my ($name, $info) = each %$features) { my $failures = $self->prereq_failures($info); if ($failures) { - $self->log_warn("Feature '$name' disabled because of the following prerequisite failures:\n"); - foreach my $type ( @{$self->prereq_action_types} ) { - next unless $failures->{$type}; + my $log_text = "Feature '$name' disabled because of the following prerequisite failures:\n"; + foreach my $type ( grep $failures->{$_}, @{$self->prereq_action_types} ) { while (my ($module, $status) = each %{$failures->{$type}}) { - $self->log_warn(" * $status->{message}\n"); + $log_text .= " * $status->{message}\n"; } - $self->log_warn("\n"); } - $self->feature($name => 0); + $self->log_warn("$log_text\n"); } else { $self->log_info("Feature '$name' enabled.\n\n"); - $self->feature($name => 1); } } } Index: Notes.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Notes.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Notes.pm 24 Mar 2005 16:36:09 -0000 1.3 +++ Notes.pm 12 Apr 2005 03:43:10 -0000 1.4 @@ -44,6 +44,11 @@ return keys %{$self->read()} > 0; } +sub exists { + my ($self, $key) = @_; + return exists($self->{new}{$key}) || exists($self->{disk}{$key}); +} + sub read { my $self = shift; @@ -100,6 +105,8 @@ sub write_config_data { my ($self, %args) = @_; + # XXX need to handle auto_features + my $fh = IO::File->new("> $args{file}") or die "Can't create '$args{file}': $!"; printf $fh <<'EOF', $args{config_module}; |
From: Ken W. <kwi...@us...> - 2005-04-10 17:47:10
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26483 Modified Files: Changes Log Message: add meta_add and meta_merge mechanisms Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.335 retrieving revision 1.336 diff -u -d -r1.335 -r1.336 --- Changes 31 Mar 2005 04:48:13 -0000 1.335 +++ Changes 10 Apr 2005 17:46:45 -0000 1.336 @@ -3,6 +3,9 @@ 0.27_01 (Beta for 0.28) + - Added the meta_add and meta_merge mechanisms, which let the module + author add/merge arbitrary entries into the META.yml file. + - Now reads per-action default options from '$ENV{HOME}/.modulebuildrc' if it exists. Commandline options override anything set in the rc file. |
From: Ken W. <kwi...@us...> - 2005-04-10 17:46:55
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26483/lib/Module/Build Modified Files: Authoring.pod Base.pm Log Message: add meta_add and meta_merge mechanisms Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.408 retrieving revision 1.409 diff -u -d -r1.408 -r1.409 --- Base.pm 10 Apr 2005 04:33:51 -0000 1.408 +++ Base.pm 10 Apr 2005 17:46:46 -0000 1.409 @@ -434,6 +434,8 @@ __PACKAGE__->add_property(build_class => 'Module::Build'); __PACKAGE__->add_property(html_css => ($^O =~ /Win32/) ? 'Active.css' : ''); __PACKAGE__->add_property(html_backlink => '__top'); +__PACKAGE__->add_property(meta_add => {}); +__PACKAGE__->add_property(meta_merge => {}); __PACKAGE__->add_property($_) for qw( base_dir dist_name @@ -2293,6 +2295,35 @@ return { map {$_, 1} qw(perl gpl artistic lgpl bsd open_source unrestricted restrictive unknown) }; } +sub meta_add { + my ($self, %add) = @_; + my $m = $self->{properties}{meta_add}; + while (my($k, $v) = each %add) { + $m->{$k} = $v; + } + return $m; +} + +sub meta_merge { + my ($self, %merge) = @_; + my $m = $self->{properties}{meta_merge}; + while (my($k, $v) = each %merge) { + $self->_hash_merge($m, $k, $v); + } + return $m; +} + +sub _hash_merge { + my ($self, $h, $k, $v) = @_; + if (ref $h->{$k} eq 'ARRAY') { + push @{$h->{$k}}, ref $v ? @$v : $v; + } elsif (ref $h->{$k} eq 'HASH') { + $h->{$k}{$_} = $v->{$_} foreach keys %$v; + } else { + $h->{$k} = $v; + } +} + sub _write_minimal_metadata { my $self = shift; my $p = $self->{properties}; @@ -2301,6 +2332,8 @@ my $fh = IO::File->new("> $file") or die "Can't open $file: $!"; + # XXX Add the meta_add & meta_merge stuff + print $fh <<"END_OF_META"; --- #YAML:1.0 name: $p->{dist_name} @@ -2311,8 +2344,6 @@ license: $p->{license} generated_by: Module::Build version $Module::Build::VERSION, without YAML.pm END_OF_META - - $fh->close(); } sub ACTION_distmeta { @@ -2340,33 +2371,32 @@ $self->depends_on('config_data'); push @INC, File::Spec->catdir($self->blib, 'lib'); } + require Module::Build::ConfigData; # Only works after the 'build' - unless (Module::Build::ConfigData->feature('YAML_support')) { + if (Module::Build::ConfigData->feature('YAML_support')) { + require YAML; + + # We use YAML::Node to get the order nice in the YAML file. + $self->prepare_metadata( my $node = YAML::Node->new({}) ); + + # YAML API changed after version 0.30 + my $yaml_sub = $YAML::VERSION le '0.30' ? \&YAML::StoreFile : \&YAML::DumpFile; + $self->{wrote_metadata} = $yaml_sub->($self->{metafile}, $node ); + + } else { $self->log_warn(<<EOM); \nCouldn't load YAML.pm, generating a minimal META.yml without it. Please check and edit the generated metadata, or consider installing YAML.pm.\n EOM - $self->_add_to_manifest('MANIFEST', $self->{metafile}); - return $self->_write_minimal_metadata(); + $self->_write_minimal_metadata; } - require YAML; - - # We use YAML::Node to get the order nice in the YAML file. - my $node = $self->prepare_metadata( YAML::Node->new({}) ); - - # YAML API changed after version 0.30 - my $yaml_sub = $YAML::VERSION le '0.30' ? \&YAML::StoreFile : \&YAML::DumpFile; - $self->{wrote_metadata} = $yaml_sub->($self->{metafile}, $node ); - $self->_add_to_manifest('MANIFEST', $self->{metafile}); } sub prepare_metadata { - my $self = shift; - my $node = shift; - + my ($self, $node) = @_; my $p = $self->{properties}; foreach (qw(dist_name dist_version dist_author dist_abstract license)) { @@ -2383,6 +2413,14 @@ $node->{generated_by} = "Module::Build version $Module::Build::VERSION"; + while (my($k, $v) = each %{$p->{meta_add}}) { + $node->{$k} = $v; + } + + while (my($k, $v) = each %{$p->{meta_merge}}) { + $self->_hash_merge($node, $k, $v); + } + return $node; } Index: Authoring.pod =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Authoring.pod,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Authoring.pod 24 Jan 2005 22:00:16 -0000 1.7 +++ Authoring.pod 10 Apr 2005 17:46:46 -0000 1.8 @@ -445,6 +445,24 @@ figuring I'd let people with actual working knowledge in this area tell me what to do. So if that's you, drop me a line. +=item meta_add + +A hash of key/value pairs that should be added to the F<META.yml> file +during the C<distmeta> action. Any existing entries with the same +names will be overridden. + +=item meta_merge + +A hash of key/value pairs that should be merged into the F<META.yml> +file during the C<distmeta> action. Any existing entries with the +same names will be overridden. + +The only difference between C<meta_add> and C<meta_merge> is their +behavior on hash-valued and array-valued entries: C<meta_add> will +completely blow away the existing hash or array value, but +C<meta_merge> will merge the supplied data into the existing hash or +array value. + =item module_name The C<module_name> is a shortcut for setting default values of |
From: Ken W. <kwi...@us...> - 2005-04-10 17:46:55
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26483/t Modified Files: extend.t Log Message: add meta_add and meta_merge mechanisms Index: extend.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/extend.t,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- extend.t 10 Apr 2005 03:58:35 -0000 1.11 +++ extend.t 10 Apr 2005 17:46:46 -0000 1.12 @@ -2,7 +2,7 @@ # Tests various ways to extend Module::Build, e.g. by subclassing. -use Test::More tests => 45; +use Test::More tests => 50; use Module::Build; ok 1; @@ -145,3 +145,28 @@ can_ok $build, 'bar'; is $build->bar, 'yow'; } + +{ + # Test the meta_add and meta_merge stuff + chdir $goto; + ok my $build = Module::Build->new( + module_name => 'Sample', + meta_add => {foo => 'bar'}, + conflicts => {'Foo::Barxx' => 0}, + ); + my %data; + $build->prepare_metadata( \%data ); + is $data{foo}, 'bar'; + + $build->meta_merge(foo => 'baz'); + $build->prepare_metadata( \%data ); + is $data{foo}, 'baz'; + + $build->meta_merge(conflicts => {'Foo::Fooxx' => 0}); + $build->prepare_metadata( \%data ); + is_deeply $data{conflicts}, {'Foo::Barxx' => 0, 'Foo::Fooxx' => 0}; + + $build->meta_add(conflicts => {'Foo::Bazxx' => 0}); + $build->prepare_metadata( \%data ); + is_deeply $data{conflicts}, {'Foo::Bazxx' => 0, 'Foo::Fooxx' => 0}; +} |
From: Ken W. <kwi...@us...> - 2005-04-10 04:34:00
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19665/lib/Module/Build Modified Files: Base.pm Log Message: Don't duplicate default stuff in multiple classes Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.407 retrieving revision 1.408 diff -u -d -r1.407 -r1.408 --- Base.pm 1 Apr 2005 08:55:29 -0000 1.407 +++ Base.pm 10 Apr 2005 04:33:51 -0000 1.408 @@ -332,92 +332,89 @@ } { - my %valid_properties = ( __PACKAGE__ => {} ); + my %valid_properties = ( __PACKAGE__, {} ); my %additive_properties; + sub _mb_classes { + my $class = ref($_[0]) || $_[0]; + return ($class, $class->mb_parents); + } + sub valid_property { - my $class = shift->_prop_class; - exists $valid_properties{$class}->{$_[0]} + my ($class, $prop) = @_; + return grep exists( $valid_properties{$_}{$prop} ), $class->_mb_classes; } sub valid_properties { - my $class = shift->_prop_class; - keys %{ $valid_properties{$class} }; + return keys %{ shift->valid_properties_defaults() }; + } + + sub valid_properties_defaults { + my %out; + for (reverse shift->_mb_classes) { + @out{ keys %{ $valid_properties{$_} } } = values %{ $valid_properties{$_} }; + } + return \%out; } sub array_properties { - my $class = shift->_prop_class; - return unless exists $additive_properties{$class}->{ARRAY}; - return @{$additive_properties{$class}->{ARRAY}}; + for (shift->_mb_classes) { + return @{$additive_properties{$_}->{ARRAY}} + if exists $additive_properties{$_}->{ARRAY}; + } } sub hash_properties { - my $class = shift->_prop_class; - return unless exists $additive_properties{$class}->{'HASH'}; - return @{$additive_properties{$class}->{'HASH'}}; + for (shift->_mb_classes) { + return @{$additive_properties{$_}->{'HASH'}} + if exists $additive_properties{$_}->{'HASH'}; + } } sub add_property { - my ($class, $property, $default) = @_; - unless (exists $valid_properties{$class}) { - # Set it up with the properties from the parent classes, first. - for my $parent (reverse $class->mb_parents) { - $valid_properties{$class}->{$_} = $valid_properties{$parent}->{$_} - for keys %{ $valid_properties{$parent} }; - } - } + my ($class, $property, $default) = @_; + die "Property '$property' already exists" if $class->valid_property($property); - return $class unless $property; + $valid_properties{$class}{$property} = $default; - die qq{Property "$property" already exists\n} - if $class->valid_property($property); - if (my $type = ref $default) { - push @{$additive_properties{$class}->{$type}}, $property; - } + if (my $type = ref $default) { + push @{$additive_properties{$class}->{$type}}, $property; + } - $valid_properties{$class}->{$property} = $default; - return $class if $class->can($property); + unless ($class->can($property)) { no strict 'refs'; *{"$class\::$property"} = sub { - my $self = shift; - $self->{properties}{$property} = shift if @_; - return $self->{properties}{$property}; - }; - return $class; - } - - sub _prop_class { - my $class = ref $_[0] || $_[0]; - unless (exists $valid_properties{$class}) { - if (my @parents = $class->mb_parents) { - do { - $class = shift @parents; - } until (exists $valid_properties{$class} || !@parents); - } - } - return $class; + my $self = shift; + $self->{properties}{$property} = shift if @_; + return $self->{properties}{$property}; + }; + } + return $class; } sub _set_defaults { - my $self = shift; - my $class = $self->_prop_class; - # Set the build class. - $self->{properties}{build_class} ||= ref $self; + my $self = shift; - for my $prop ($self->valid_properties) { - $self->{properties}{$prop} = $valid_properties{$class}->{$prop} - unless exists $self->{properties}{$prop}; - } - # Copy defaults for arrays any arrays. - for my $prop ($self->array_properties) { - $self->{properties}{$prop} = [@{$valid_properties{$class}->{$prop}}] - unless exists $self->{properties}{$prop}; - } - # Copy defaults for arrays any hashes. - for my $prop ($self->hash_properties) { - $self->{properties}{$prop} = {%{$valid_properties{$class}->{$prop}}} - unless exists $self->{properties}{$prop}; - } + # Set the build class. + $self->{properties}{build_class} ||= ref $self; + + my $defaults = $self->valid_properties_defaults; + + foreach my $prop (keys %$defaults) { + $self->{properties}{$prop} = $defaults->{$prop} + unless exists $self->{properties}{$prop}; + } + + # Copy defaults for arrays any arrays. + for my $prop ($self->array_properties) { + $self->{properties}{$prop} = [@{$defaults->{$prop}}] + unless exists $self->{properties}{$prop}; + } + # Copy defaults for arrays any hashes. + for my $prop ($self->hash_properties) { + $self->{properties}{$prop} = {%{$defaults->{$prop}}} + unless exists $self->{properties}{$prop}; + } } } |
From: Ken W. <kwi...@us...> - 2005-04-10 03:58:46
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2755 Modified Files: extend.t Log Message: Oops, didn't mean to change the number of tests Index: extend.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/extend.t,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- extend.t 10 Apr 2005 03:18:59 -0000 1.10 +++ extend.t 10 Apr 2005 03:58:35 -0000 1.11 @@ -2,7 +2,7 @@ # Tests various ways to extend Module::Build, e.g. by subclassing. -use Test::More tests => 47; +use Test::More tests => 45; use Module::Build; ok 1; |
From: Ken W. <kwi...@us...> - 2005-04-10 03:19:07
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15074 Modified Files: extend.t Log Message: Don't require such a specific format for the error message (I like single quotes, not double here) Index: extend.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/extend.t,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- extend.t 23 Mar 2005 01:53:23 -0000 1.9 +++ extend.t 10 Apr 2005 03:18:59 -0000 1.10 @@ -2,7 +2,7 @@ # Tests various ways to extend Module::Build, e.g. by subclassing. -use Test::More tests => 45; +use Test::More tests => 47; use Module::Build; ok 1; @@ -73,7 +73,7 @@ # Catch an exception adding an existing property. eval { __PACKAGE__->add_property('module_name')}; - like "$@", qr/Property "module_name" already exists/; + like "$@", qr/already exists/; } { |
From: Randy W. S. <si...@us...> - 2005-04-07 01:51:50
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23135/t Modified Files: xs.t Log Message: Make sure verbose output from Module::Build and test output from sub-tests are not picked up by Test::Harness. Index: xs.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/xs.t,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- xs.t 24 Mar 2005 01:44:34 -0000 1.18 +++ xs.t 7 Apr 2005 01:51:40 -0000 1.19 @@ -11,10 +11,13 @@ { local $SIG{__WARN__} = sub {}; + my $m = Module::Build->current; + $m->verbose( 0 ); + my $have_c_compiler; - stderr_of( sub {$have_c_compiler = Module::Build->current->have_c_compiler} ); + stderr_of( sub {$have_c_compiler = $m->have_c_compiler} ); - if ( !Module::Build->current->feature('C_support') ) { + if ( ! $m->feature('C_support') ) { print("1..0 # Skipped: C_support not enabled\n"); exit(0); } elsif ( !$have_c_compiler ) { @@ -23,15 +26,15 @@ } } -plan tests => 12; - ######################### End of black magic. +plan tests => 12; + # Pretend we're in the t/XSTest/ subdirectory my $build_dir = File::Spec->catdir('t','XSTest'); chdir $build_dir or die "Can't change to $build_dir : $!"; -my $m = Module::Build->new_from_context; +my $m = Module::Build->new_from_context('skip_rcfile' => '1'); ok(1); eval {$m->dispatch('clean')}; |
From: Ken W. <kwi...@us...> - 2005-04-06 20:36:38
|
Update of /cvsroot/module-build/Module-Build/lib/Module In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27230 Modified Files: Build.pm Log Message: Change a little POD markup to use F<file> tags Index: Build.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build.pm,v retrieving revision 1.177 retrieving revision 1.178 diff -u -d -r1.177 -r1.178 --- Build.pm 31 Mar 2005 08:13:06 -0000 1.177 +++ Build.pm 6 Apr 2005 20:36:27 -0000 1.178 @@ -492,7 +492,7 @@ =head2 Default Commandline Options (F<.modulebuildrc>) When Module::Build starts up it will look for a file, -C<'$ENV{HOME}/.modulebuildrc'>. If the file exists it will use the +F<$ENV{HOME}/.modulebuildrc>. If the file exists it will use the options specified there as defaults, as if they were typed on the commandline. The defaults can be overridden by specifying new values on the commandline. |
From: Randy W. S. <si...@us...> - 2005-04-01 08:55:46
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32479/lib/Module/Build Modified Files: Base.pm Log Message: Fix merge_modulebuildrc() so that it handles nested options (eg --config cc=gcc). Formalize the priority of options: commandline options get highest priorty, then action specific rc options, and finally global rc options. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.406 retrieving revision 1.407 diff -u -d -r1.406 -r1.407 --- Base.pm 31 Mar 2005 09:40:13 -0000 1.406 +++ Base.pm 1 Apr 2005 08:55:29 -0000 1.407 @@ -1177,13 +1177,37 @@ return \%args, $action; } +# merge Module::Build argument lists that have already been parsed +# by read_args(). Takes two references to option hashes and merges +# the contents, giving priority to the first. +sub _merge_arglist { + my( $self, $opts1, $opts2 ) = @_; + + my %new_opts = %$opts1; + while (my ($key, $val) = each %$opts2) { + if ( exists( $opts1->{$key} ) ) { + if ( ref( $val ) eq 'HASH' ) { + while (my ($k, $v) = each %$val) { + $new_opts{$key}{$k} = $v unless exists( $opts1->{$key}{$k} ); + } + } + } else { + $new_opts{$key} = $val + } + } + + return %new_opts; +} + +# read ~/.modulebuildrc returning global options '*' and +# options specific to the currently executing $action. sub read_modulebuildrc { my( $self, $action ) = @_; - return {} unless exists( $ENV{HOME} ) && -e $ENV{HOME}; + return () unless exists( $ENV{HOME} ) && -e $ENV{HOME}; my $modulebuildrc = File::Spec->catfile( $ENV{HOME}, '.modulebuildrc' ); - return {} unless -e $modulebuildrc; + return () unless -e $modulebuildrc; my $fh = IO::File->new( $modulebuildrc ) or die "Can't open $modulebuildrc: $!"; @@ -1211,28 +1235,22 @@ $options{$action} .= $options . ' '; # merge if more than one line } + my ($global_opts) = + $self->read_args( $self->split_like_shell( $options{'*'} || '' ) ); + my ($action_opts) = + $self->read_args( $self->split_like_shell( $options{$action} || '' ) ); - my $cmdline .= join ' ', grep defined && length, - map { exists( $options{$_} ) ? $options{$_} : '' } - ( '*', $action ); - - my @args = $self->split_like_shell( $cmdline ); - my( $args ) = $self->read_args( @args ); - - return defined( $args ) ? $args : {}; + # specific $action options take priority over global options '*' + return $self->_merge_arglist( $action_opts, $global_opts ); } +# merge the relevant options in ~/.modulebuildrc into Module::Build's +# option list where they do not conflict with commandline options. sub merge_modulebuildrc { - my( $self, $action, %args ) = @_; - - my $rc_args = $self->read_modulebuildrc( $action || 'build' ); - - my %app_args; - while (my ($key, $val) = each %$rc_args) { - $app_args{$key} = $val unless exists( $args{$key} ); - } - - $self->merge_args( $action, %app_args ); + my( $self, $action, %cmdline_opts ) = @_; + my %rc_opts = $self->read_modulebuildrc( $action || $self->{action} || 'build' ); + my %new_opts = $self->_merge_arglist( \%cmdline_opts, \%rc_opts ); + $self->merge_args( $action, %new_opts ); } sub merge_args { |
From: Randy W. S. <si...@us...> - 2005-03-31 09:40:59
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15706/lib/Module/Build Modified Files: Base.pm Log Message: Fix tests to ignore any user defined '~/.modulebuildrc' file. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.405 retrieving revision 1.406 diff -u -d -r1.405 -r1.406 --- Base.pm 31 Mar 2005 09:01:38 -0000 1.405 +++ Base.pm 31 Mar 2005 09:40:13 -0000 1.406 @@ -476,7 +476,7 @@ skip_rcfile ); -INIT { +{ my @prereq_actions = ( 'Build_PL', __PACKAGE__->known_actions ); my @prereq_types = qw( requires recommends conflicts ); __PACKAGE__->add_property(prereq_actions => \@prereq_actions); @@ -1024,10 +1024,11 @@ sub _call_action { my ($self, $action) = @_; - return if $self->{_completed_actions}{$action}++; $self->validate_action_prereqs( $action ); + return if $self->{_completed_actions}{$action}++; + local $self->{action} = $action; my $method = "ACTION_$action"; die "No action '$action' defined, try running the 'help' action.\n" unless $self->can($method); |
From: Randy W. S. <si...@us...> - 2005-03-31 09:40:59
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15706/t Modified Files: basic.t compat.t Log Message: Fix tests to ignore any user defined '~/.modulebuildrc' file. Index: compat.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/compat.t,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- compat.t 17 Feb 2005 02:25:18 -0000 1.22 +++ compat.t 31 Mar 2005 09:40:14 -0000 1.23 @@ -103,6 +103,7 @@ my $libdir = File::Spec->catdir( $startdir, 't', 'libdir' ); my $result = $build->run_perl_script('Makefile.PL', [], [ + 'SKIP_RCFILE=1', "LIB=$libdir", 'TEST_VERBOSE=1', 'INSTALLDIRS=perl', Index: basic.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/basic.t,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- basic.t 7 Jan 2005 10:15:53 -0000 1.36 +++ basic.t 31 Mar 2005 09:40:14 -0000 1.37 @@ -124,7 +124,7 @@ chdir 'Sample'; - eval {Module::Build->run_perl_script('Build.PL', [], ['--config', "foocakes=barcakes", '--foo', '--bar', '--bar', '-bat=hello', 'gee=whiz', '--any', 'hey', '--destdir', 'yo', '--verbose', '1'])}; + eval {Module::Build->run_perl_script('Build.PL', [], ['skip_rcfile=1', '--config', "foocakes=barcakes", '--foo', '--bar', '--bar', '-bat=hello', 'gee=whiz', '--any', 'hey', '--destdir', 'yo', '--verbose', '1'])}; ok $@, ''; my $b = Module::Build->resume(); @@ -143,7 +143,7 @@ ok $b->runtime_params('verbose'), '1'; ok !$b->runtime_params('license'); ok my %runtime = $b->runtime_params; - ok scalar keys %runtime, 3; + ok scalar keys %runtime, 4; ok $runtime{destdir}, 'yo'; ok $runtime{verbose}, '1'; ok $runtime{config}; |
From: Randy W. S. <si...@us...> - 2005-03-31 09:02:00
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25972/lib/Module/Build Modified Files: Base.pm Log Message: Merge arguments after commandline arguments so that we can support an option ('skip_rcfile') to skip reading the '~/.modulebuildrc' file. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.404 retrieving revision 1.405 diff -u -d -r1.404 -r1.405 --- Base.pm 31 Mar 2005 08:14:04 -0000 1.404 +++ Base.pm 31 Mar 2005 09:01:38 -0000 1.405 @@ -473,6 +473,7 @@ ignore_prereq_conflicts ignore_prereq_requires ignore_prereqs + skip_rcfile ); INIT { @@ -1220,13 +1221,23 @@ return defined( $args ) ? $args : {}; } +sub merge_modulebuildrc { + my( $self, $action, %args ) = @_; + + my $rc_args = $self->read_modulebuildrc( $action || 'build' ); + + my %app_args; + while (my ($key, $val) = each %$rc_args) { + $app_args{$key} = $val unless exists( $args{$key} ); + } + + $self->merge_args( $action, %app_args ); +} + sub merge_args { - my ($self, $action, %cmd_args) = @_; + my ($self, $action, %args) = @_; $self->{action} = $action if defined $action; - my $rc_args = $self->read_modulebuildrc( $self->{action} || 'build' ); - my %args = ( %$rc_args, %cmd_args ); - my %additive = map { $_ => 1 } $self->hash_properties; # Extract our 'properties' from $cmd_args, the rest are put in 'args'. @@ -1250,6 +1261,7 @@ my $self = shift; my ($args, $action) = $self->read_args(@_); $self->merge_args($action, %$args); + $self->merge_modulebuildrc( $action, %$args ) unless $self->skip_rcfile; } sub super_classes { |
From: Randy W. S. <si...@us...> - 2005-03-31 08:14:14
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32687/lib/Module/Build Modified Files: Base.pm Log Message: Guard against undefined values in read_modulebuildrc() Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.403 retrieving revision 1.404 diff -u -d -r1.403 -r1.404 --- Base.pm 31 Mar 2005 06:03:08 -0000 1.403 +++ Base.pm 31 Mar 2005 08:14:04 -0000 1.404 @@ -1206,10 +1206,15 @@ if ( $buffer ) { # anything left in $buffer ? my( $action, $options ) = split( /\s+/, $buffer, 2 ); - $options{$action} .= $options . ' '; + $options{$action} .= $options . ' '; # merge if more than one line } - my @args = $self->split_like_shell( "$options{'*'} $options{$action}" ); + + my $cmdline .= join ' ', grep defined && length, + map { exists( $options{$_} ) ? $options{$_} : '' } + ( '*', $action ); + + my @args = $self->split_like_shell( $cmdline ); my( $args ) = $self->read_args( @args ); return defined( $args ) ? $args : {}; |
From: Randy W. S. <si...@us...> - 2005-03-31 08:13:17
|
Update of /cvsroot/module-build/Module-Build/lib/Module In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32337/lib/Module Modified Files: Build.pm Log Message: More documentation for .modulebuildrc Index: Build.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build.pm,v retrieving revision 1.176 retrieving revision 1.177 diff -u -d -r1.176 -r1.177 --- Build.pm 31 Mar 2005 04:48:15 -0000 1.176 +++ Build.pm 31 Mar 2005 08:13:06 -0000 1.177 @@ -502,7 +502,9 @@ as they would be on the commandline. They can be seperated by any amount of whitespace, including newlines as long there is a space at the beginning of the continued line. Any thing following a hash mark -is considered a comment, and is stripped before parsing. +is considered a comment, and is stripped before parsing. If more than +one line begins with the same action name, those lines are merged into +one commandline. Besides the regular actions, there are two special options. You can use the action name '*' (asterisk) for any global options that should |
From: Randy W. S. <si...@us...> - 2005-03-31 06:03:34
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2868/lib/Module/Build Modified Files: Base.pm Log Message: Revert change to split_like_shell() method, and have read_modulebuildrc() returns a empty hash if the file isn't found or there are no matching actions. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.402 retrieving revision 1.403 diff -u -d -r1.402 -r1.403 --- Base.pm 31 Mar 2005 04:48:17 -0000 1.402 +++ Base.pm 31 Mar 2005 06:03:08 -0000 1.403 @@ -1178,10 +1178,10 @@ sub read_modulebuildrc { my( $self, $action ) = @_; - return unless exists( $ENV{HOME} ) && -e $ENV{HOME}; + return {} unless exists( $ENV{HOME} ) && -e $ENV{HOME}; my $modulebuildrc = File::Spec->catfile( $ENV{HOME}, '.modulebuildrc' ); - return unless -e $modulebuildrc; + return {} unless -e $modulebuildrc; my $fh = IO::File->new( $modulebuildrc ) or die "Can't open $modulebuildrc: $!"; @@ -1209,10 +1209,10 @@ $options{$action} .= $options . ' '; } - my @args = $self->split_like_shell( $options{'*'}, $options{$action} ); + my @args = $self->split_like_shell( "$options{'*'} $options{$action}" ); my( $args ) = $self->read_args( @args ); - return $args; + return defined( $args ) ? $args : {}; } sub merge_args { @@ -2626,9 +2626,7 @@ } sub split_like_shell { - my ($self, @strings) = @_; - - my $string = join( ' ', map {s/\s+$//; $_} @strings ); + my ($self, $string) = @_; return () unless defined($string); return @$string if UNIVERSAL::isa($string, 'ARRAY'); |
From: Randy W. S. <si...@us...> - 2005-03-31 06:03:18
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build/Platform In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2868/lib/Module/Build/Platform Modified Files: Windows.pm Log Message: Revert change to split_like_shell() method, and have read_modulebuildrc() returns a empty hash if the file isn't found or there are no matching actions. Index: Windows.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Platform/Windows.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- Windows.pm 31 Mar 2005 04:48:20 -0000 1.22 +++ Windows.pm 31 Mar 2005 06:03:09 -0000 1.23 @@ -76,8 +76,7 @@ # (mostly Randy), and there are a lot of regression tests, so we # should feel free to adjust if desired. - my ($self, @strings) = @_; - local $_ = join( ' ', map {s/\s+$//; $_} @strings ); + (my $self, local $_) = @_; return @$_ if defined() && UNIVERSAL::isa($_, 'ARRAY'); |
From: Randy W. S. <si...@us...> - 2005-03-31 04:49:14
|
Update of /cvsroot/module-build/Module-Build/lib/Module In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28318/lib/Module Modified Files: Build.pm Log Message: Read default commandline options from '$ENV{HOME}/.modulebuildrc' if it exists. Index: Build.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build.pm,v retrieving revision 1.175 retrieving revision 1.176 diff -u -d -r1.175 -r1.176 --- Build.pm 24 Mar 2005 00:06:18 -0000 1.175 +++ Build.pm 31 Mar 2005 04:48:15 -0000 1.176 @@ -489,6 +489,32 @@ =back +=head2 Default Commandline Options (F<.modulebuildrc>) + +When Module::Build starts up it will look for a file, +C<'$ENV{HOME}/.modulebuildrc'>. If the file exists it will use the +options specified there as defaults, as if they were typed on the +commandline. The defaults can be overridden by specifying new values +on the commandline. + +The action name must come at the beginning of the line followed by any +amount of whitespace and then the options. Options are given the same +as they would be on the commandline. They can be seperated by any +amount of whitespace, including newlines as long there is a space at +the beginning of the continued line. Any thing following a hash mark +is considered a comment, and is stripped before parsing. + +Besides the regular actions, there are two special options. You can +use the action name '*' (asterisk) for any global options that should +be applied to all actions. And there is the 'Build_PL' action which +specifies options to be applied when you invoke C<perl Build.PL>. + + * verbose=1 # global options + diff flags=-u + install install_base=/home/ken + --install_path html=/home/ken/docs/html + + =head2 How Installation Paths are Determined When you invoke Module::Build's C<build> action, it needs to figure |
From: Randy W. S. <si...@us...> - 2005-03-31 04:49:11
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28318 Modified Files: Changes Log Message: Read default commandline options from '$ENV{HOME}/.modulebuildrc' if it exists. Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.334 retrieving revision 1.335 diff -u -d -r1.334 -r1.335 --- Changes 31 Mar 2005 03:20:20 -0000 1.334 +++ Changes 31 Mar 2005 04:48:13 -0000 1.335 @@ -3,6 +3,9 @@ 0.27_01 (Beta for 0.28) + - Now reads per-action default options from '$ENV{HOME}/.modulebuildrc' + if it exists. Commandline options override anything set in the rc file. + - Extend prerequisite specifications to apply to all actions. It is now a fatal error if 'requires' or 'conflicts' for a given action are not satisfied, except where necessary for backwards compatability. |
From: Randy W. S. <si...@us...> - 2005-03-31 04:48:52
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28318/lib/Module/Build Modified Files: Base.pm Log Message: Read default commandline options from '$ENV{HOME}/.modulebuildrc' if it exists. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.401 retrieving revision 1.402 diff -u -d -r1.401 -r1.402 --- Base.pm 31 Mar 2005 03:20:18 -0000 1.401 +++ Base.pm 31 Mar 2005 04:48:17 -0000 1.402 @@ -22,10 +22,11 @@ sub new { my $self = shift()->_construct(@_); + $self->{action} = 'Build_PL'; $self->cull_args(@ARGV); die "Too early to specify a build action '$self->{action}'. Do 'Build $self->{action}' instead.\n" - if $self->{action}; + if $self->{action} && $self->{action} ne 'Build_PL'; $self->dist_name; $self->dist_version; @@ -475,14 +476,14 @@ ); INIT { - my @prereq_actions = ( 'Build.PL', __PACKAGE__->known_actions ); + my @prereq_actions = ( 'Build_PL', __PACKAGE__->known_actions ); my @prereq_types = qw( requires recommends conflicts ); __PACKAGE__->add_property(prereq_actions => \@prereq_actions); __PACKAGE__->add_property(prereq_types => \@prereq_types); my @prereq_action_types; foreach my $action ( @prereq_actions ) { foreach my $type ( @prereq_types ) { - my $req = $action eq 'Build.PL' ? '' : $action . '_'; + my $req = $action eq 'Build_PL' ? '' : $action . '_'; $req .= $type; __PACKAGE__->add_property( $req => {} ); push( @prereq_action_types, $req ); @@ -1174,10 +1175,53 @@ return \%args, $action; } +sub read_modulebuildrc { + my( $self, $action ) = @_; + + return unless exists( $ENV{HOME} ) && -e $ENV{HOME}; + + my $modulebuildrc = File::Spec->catfile( $ENV{HOME}, '.modulebuildrc' ); + return unless -e $modulebuildrc; + + my $fh = IO::File->new( $modulebuildrc ) + or die "Can't open $modulebuildrc: $!"; + + my %options; my $buffer = ''; + while (defined( my $line = <$fh> )) { + chomp( $line ); + $line =~ s/#.*$//; + next unless length( $line ); + + if ( $line =~ /^\S/ ) { + if ( $buffer ) { + my( $action, $options ) = split( /\s+/, $buffer, 2 ); + $options{$action} .= $options . ' '; + $buffer = ''; + } + $buffer = $line; + } else { + $buffer .= $line; + } + } + + if ( $buffer ) { # anything left in $buffer ? + my( $action, $options ) = split( /\s+/, $buffer, 2 ); + $options{$action} .= $options . ' '; + } + + my @args = $self->split_like_shell( $options{'*'}, $options{$action} ); + my( $args ) = $self->read_args( @args ); + + return $args; +} + sub merge_args { - my ($self, $action, %args) = @_; + my ($self, $action, %cmd_args) = @_; $self->{action} = $action if defined $action; + my $rc_args = $self->read_modulebuildrc( $self->{action} || 'build' ); + my %args = ( %$rc_args, %cmd_args ); + my %additive = map { $_ => 1 } $self->hash_properties; # Extract our 'properties' from $cmd_args, the rest are put in 'args'. @@ -2582,7 +2626,9 @@ } sub split_like_shell { - my ($self, $string) = @_; + my ($self, @strings) = @_; + + my $string = join( ' ', map {s/\s+$//; $_} @strings ); return () unless defined($string); return @$string if UNIVERSAL::isa($string, 'ARRAY'); |
From: Randy W. S. <si...@us...> - 2005-03-31 04:48:51
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build/Platform In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28318/lib/Module/Build/Platform Modified Files: Windows.pm Log Message: Read default commandline options from '$ENV{HOME}/.modulebuildrc' if it exists. Index: Windows.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Platform/Windows.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- Windows.pm 6 Dec 2004 04:00:40 -0000 1.21 +++ Windows.pm 31 Mar 2005 04:48:20 -0000 1.22 @@ -76,7 +76,8 @@ # (mostly Randy), and there are a lot of regression tests, so we # should feel free to adjust if desired. - (my $self, local $_) = @_; + my ($self, @strings) = @_; + local $_ = join( ' ', map {s/\s+$//; $_} @strings ); return @$_ if defined() && UNIVERSAL::isa($_, 'ARRAY'); |