From ec16d2bb4da058562fbb80d2bc0b89717283ec29 Mon Sep 17 00:00:00 2001 From: Ken Williams Date: Thu, 9 Jun 2005 23:27:17 +0000 Subject: [PATCH] Backport the build_class stuff git-svn-id: http://svn.perl.org/modules/Module-Build/branches/release-0_26_branch@5378 50811bd7-b8ce-0310-adc1-d9db26280581 --- Changes | 5 +++++ lib/Module/Build/Base.pm | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 33121b05..f584ec0c 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,11 @@ Revision history for Perl extension Module::Build. - Fix the output of an informational message that we output when changing the 'shebang line' in installable scripts. [Robin Barker] + - Backported a change from the 0.27_xx branch that keeps track of any + custom Module::Build subclass that might have been created in the + Build.PL script, so that we can reinstantiate the right class in + new_from_context(). [Requested by Jos Boumans] + 0.2610 Fri Apr 15 08:25:01 CDT 2005 - new_from_context() was losing its arguments in some cases (and not diff --git a/lib/Module/Build/Base.pm b/lib/Module/Build/Base.pm index f5a69708..f3d203c4 100644 --- a/lib/Module/Build/Base.pm +++ b/lib/Module/Build/Base.pm @@ -37,6 +37,21 @@ sub resume { $self->read_config; + # If someone called Module::Build->current() or + # Module::Build->new_from_context() and the correct class to use is + # actually a *subclass* of Module::Build, we may need to load that + # subclass here and re-delegate the resume() method to it. + unless ( UNIVERSAL::isa($self, $self->build_class) ) { + my $build_class = $self->build_class; + my $config_dir = $self->config_dir || '_build'; + my $build_lib = File::Spec->catdir( $config_dir, 'lib' ); + unshift( @INC, $build_lib ); + unless ( $build_class->can('new') ) { + eval "require $build_class; 1" or die "Failed to re-load '$build_class': $@"; + } + return $build_class->resume(@_); + } + unless ($self->_perl_is_same($self->{properties}{perl})) { my $perl = $self->find_perl_interpreter; warn(" * WARNING: Configuration was initially created with '$self->{properties}{perl}',\n". @@ -98,9 +113,11 @@ sub _construct { %input, }, }, $package; - + my ($p, $c) = ($self->{properties}, $self->{config}); + $p->{build_class} ||= ref $self; + # 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 @@ -419,6 +436,7 @@ EOF # XXX huge hack alert - will revisit this later my %valid_properties = map {$_ => 1} qw( + build_class module_name dist_name dist_version