Skip to content

Commit 583cc85

Browse files
committed
Module::Build::Config now isa ExtUtils::Config
Module::Build::Config is deprecated in favor of ExtUtils::Config. Apart from the constructor they are identical.
1 parent e623124 commit 583cc85

File tree

7 files changed

+158
-54
lines changed

7 files changed

+158
-54
lines changed

Build.PL

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ my $build = ModuleBuildBuilder->new(
4848
'File::Path' => 0,
4949
'File::Spec' => ($^O eq 'MSWin32' ? 3.30 : '0.82'), # rel2abs()
5050
'ExtUtils::CBuilder' => 0.27, # major platform fixes
51+
'ExtUtils::Config' => 0.006,
5152
'ExtUtils::Install' => 0,
5253
'ExtUtils::Manifest' => 0,
5354
'ExtUtils::Mkbootstrap' => 0,

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Build.PL
33
Changes
44
contrib/bash_completion.module-build
55
inc/bootstrap.pl
6+
inc/ExtUtils/Config.pm
67
inc/MBVersion.pm
78
inc/Module/Metadata.pm
89
inc/Perl/OSType.pm

inc/ExtUtils/Config.pm

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
package ExtUtils::Config;
2+
{
3+
$ExtUtils::Config::VERSION = '0.006';
4+
}
5+
6+
use strict;
7+
use warnings;
8+
use Config;
9+
10+
sub new {
11+
my ($pack, $args) = @_;
12+
return bless {
13+
values => ($args ? { %$args } : {}),
14+
}, $pack;
15+
}
16+
17+
sub clone {
18+
my $self = shift;
19+
return __PACKAGE__->new($self->{values});
20+
}
21+
22+
sub get {
23+
my ($self, $key) = @_;
24+
return exists $self->{values}{$key} ? $self->{values}{$key} : $Config{$key};
25+
}
26+
27+
sub set {
28+
my ($self, $key, $val) = @_;
29+
$self->{values}{$key} = $val;
30+
}
31+
32+
sub clear {
33+
my ($self, $key) = @_;
34+
return delete $self->{values}{$key};
35+
}
36+
37+
sub exists {
38+
my ($self, $key) = @_;
39+
return exists $self->{values}{$key} || exists $Config{$key};
40+
}
41+
42+
sub values_set {
43+
my $self = shift;
44+
return { %{$self->{values}} };
45+
}
46+
47+
sub all_config {
48+
my $self = shift;
49+
return { %Config, %{ $self->{values}} };
50+
}
51+
52+
1;
53+
54+
55+
56+
=pod
57+
58+
=head1 NAME
59+
60+
ExtUtils::Config - A wrapper for perl's configuration
61+
62+
=head1 VERSION
63+
64+
version 0.006
65+
66+
=head1 SYNOPSIS
67+
68+
my $config = ExtUtils::Config->new();
69+
$config->set('installsitelib', "$ENV{HOME}/lib");
70+
71+
=head1 DESCRIPTION
72+
73+
ExtUtils::Config is an abstraction around the %Config hash.
74+
75+
=head1 METHODS
76+
77+
=head2 new(\%config)
78+
79+
Create a new ExtUtils::Config object. The values in C<\%config> are used to initialize the object.
80+
81+
=head2 get($key)
82+
83+
Get the value of C<$key>. If not overriden it will return the value in %Config.
84+
85+
=head2 exists($key)
86+
87+
Tests for the existence of $key.
88+
89+
=head2 set($key, $value)
90+
91+
Set/override the value of C<$key> to C<$value>.
92+
93+
=head2 clear($key)
94+
95+
Reset the value of C<$key> to its original value.
96+
97+
=head2 values_set
98+
99+
Get a hashref of all overridden values.
100+
101+
=head2 all_config
102+
103+
Get a hashref of the complete configuration, including overrides.
104+
105+
=head2 clone
106+
107+
Clone the current configuration object.
108+
109+
=head1 AUTHORS
110+
111+
=over 4
112+
113+
=item *
114+
115+
Ken Williams <[email protected]>
116+
117+
=item *
118+
119+
Leon Timmermans <[email protected]>
120+
121+
=back
122+
123+
=head1 COPYRIGHT AND LICENSE
124+
125+
This software is copyright (c) 2006 by Ken Williams, Leon Timmermans.
126+
127+
This is free software; you can redistribute it and/or modify it under
128+
the same terms as the Perl 5 programming language system itself.
129+
130+
=cut
131+
132+
133+
__END__
134+
135+
# ABSTRACT: A wrapper for perl's configuration
136+

inc/bootstrap.pl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ BEGIN
4141
eval "require Module::Metadata; 1"
4242
or die "BOOSTRAP FAIL: $@";
4343
}
44+
if ( ! eval "use ExtUtils::Config 0.006 (); 1" ) {
45+
print "*** BOOTSTRAPPING ExtUtils::Config ***\n";
46+
push @exit_warn, [ 'ExtUtils::Config', '0.006' ];
47+
delete $INC{'ExtUtils/Config.pm'};
48+
local @INC = @INC;
49+
push @INC, 'inc';
50+
eval "require ExtUtils::Config; 1"
51+
or die "BOOSTRAP FAIL: $@";
52+
}
4453
}
4554

4655
1;

lib/Module/Build/Base.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ sub _perl_is_same {
457457
# invoking the wrong perl.)
458458
sub _discover_perl_interpreter {
459459
my $proto = shift;
460-
my $c = ref($proto) ? $proto->{config} : 'Module::Build::Config';
460+
my $c = ref($proto) ? $proto->{config} : Module::Build::Config->new;
461461

462462
my $perl = $^X;
463463
my $perl_basename = File::Basename::basename($perl);
@@ -1005,7 +1005,7 @@ __PACKAGE__->add_property($_) for qw(
10051005

10061006
sub config {
10071007
my $self = shift;
1008-
my $c = ref($self) ? $self->{config} : 'Module::Build::Config';
1008+
my $c = ref($self) ? $self->{config} : Module::Build::Config->new;
10091009
return $c->all_config unless @_;
10101010

10111011
my $key = shift;
@@ -3102,7 +3102,7 @@ sub localize_dir_path {
31023102

31033103
sub fix_shebang_line { # Adapted from fixin() in ExtUtils::MM_Unix 1.35
31043104
my ($self, @files) = @_;
3105-
my $c = ref($self) ? $self->{config} : 'Module::Build::Config';
3105+
my $c = ref($self) ? $self->{config} : Module::Build::Config->new;
31063106

31073107
my ($does_shbang) = $c->get('sharpbang') =~ /^\s*\#\!/;
31083108
for my $file (@files) {

lib/Module/Build/Config.pm

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,13 @@ use strict;
44
use vars qw($VERSION);
55
$VERSION = '0.4005';
66
$VERSION = eval $VERSION;
7-
use Config;
87

9-
sub new {
10-
my ($pack, %args) = @_;
11-
return bless {
12-
stack => {},
13-
values => $args{values} || {},
14-
}, $pack;
15-
}
16-
17-
sub get {
18-
my ($self, $key) = @_;
19-
return $self->{values}{$key} if ref($self) && exists $self->{values}{$key};
20-
return $Config{$key};
21-
}
22-
23-
sub set {
24-
my ($self, $key, $val) = @_;
25-
$self->{values}{$key} = $val;
26-
}
27-
28-
sub push {
29-
my ($self, $key, $val) = @_;
30-
push @{$self->{stack}{$key}}, $self->{values}{$key}
31-
if exists $self->{values}{$key};
32-
$self->{values}{$key} = $val;
33-
}
8+
use base 'ExtUtils::Config';
349

35-
sub pop {
36-
my ($self, $key) = @_;
10+
### DEPRECATED in favor of ExtUtils::Config ###
3711

38-
my $val = delete $self->{values}{$key};
39-
if ( exists $self->{stack}{$key} ) {
40-
$self->{values}{$key} = pop @{$self->{stack}{$key}};
41-
delete $self->{stack}{$key} unless @{$self->{stack}{$key}};
42-
}
43-
44-
return $val;
45-
}
46-
47-
sub values_set {
48-
my $self = shift;
49-
return undef unless ref($self);
50-
return $self->{values};
51-
}
52-
53-
sub all_config {
54-
my $self = shift;
55-
my $v = ref($self) ? $self->{values} : {};
56-
return {%Config, %$v};
12+
sub new {
13+
my ($pack, %args) = @_;
14+
my $self = $pack->SUPER::new($args{values});
15+
return bless $self, $pack;
5716
}
58-
59-
1;

t/xs.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ SKIP: {
8989
skip( "skipping a Unixish-only tests", 1 )
9090
unless $mb->is_unixish;
9191

92-
$mb->{config}->push(ld => "FOO=BAR ".$mb->config('ld'));
92+
local $mb->{config} = $mb->{config}->clone;
93+
$mb->{config}->set(ld => "FOO=BAR " . $mb->config('ld'));
9394
eval {$mb->dispatch('build')};
9495
is $@, '';
95-
$mb->{config}->pop('ld');
9696
}
9797

9898
eval {$mb->dispatch('realclean')};

0 commit comments

Comments
 (0)