Author: kwilliams
Date: Thu Oct 25 12:43:44 2007
New Revision: 10123
Modified:
Module-Build/trunk/Changes
Module-Build/trunk/lib/Module/Build/API.pod
Module-Build/trunk/lib/Module/Build/Base.pm
Log:
Expose the cbuilder object in the API
Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes (original)
+++ Module-Build/trunk/Changes Thu Oct 25 12:43:44 2007
@@ -1,5 +1,8 @@
Revision history for Perl extension Module::Build.
+ - Exposed the internal ExtUtils::CBuilder object as part of our API,
+ via the cbuilder() method. [Zefram]
+
- Upgraded to version.pm 0.74 (fixes bug #30004.)
- Overwrite core (post-5.9.4) Module::Build installs (bug #20528.)
Modified: Module-Build/trunk/lib/Module/Build/API.pod
==============================================================================
--- Module-Build/trunk/lib/Module/Build/API.pod (original)
+++ Module-Build/trunk/lib/Module/Build/API.pod Thu Oct 25 12:43:44 2007
@@ -855,6 +855,15 @@
Returns a hash reference indicating the C<build_requires>
prerequisites that were passed to the C<new()> method.
+=item cbuilder()
+
+[version 0.2809]
+
+Returns the internal ExtUtils::CBuilder object that can be used for
+compiling & linking C code. If no such object is available (e.g. if
+the system has no compiler installed) an exception will be thrown.
+
+
=item check_installed_status($module, $version)
[version 0.11]
Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm (original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm Thu Oct 25 12:43:44 2007
@@ -3902,13 +3902,14 @@
AutoSplit::autosplit($file, $dir);
}
-sub _cbuilder {
+sub cbuilder {
# Returns a CBuilder object
my $self = shift;
my $p = $self->{properties};
return $p->{_cbuilder} if $p->{_cbuilder};
- return unless $self->_mb_feature('C_support');
+ die "Module::Build is not configured with C_support"
+ unless $self->_mb_feature('C_support');
require ExtUtils::CBuilder;
return $p->{_cbuilder} = ExtUtils::CBuilder->new(
@@ -3924,7 +3925,7 @@
return $p->{have_compiler} if defined $p->{have_compiler};
$self->log_verbose("Checking if compiler tools configured... ");
- my $b = $self->_cbuilder;
+ my $b = eval { $self->cbuilder };
my $have = $b && $b->have_compiler;
$self->log_verbose($have ? "ok.\n" : "failed.\n");
return $p->{have_compiler} = $have;
@@ -3932,8 +3933,7 @@
sub compile_c {
my ($self, $file, %args) = @_;
- my $b = $self->_cbuilder
- or die "Module::Build is not configured with C_support";
+ my $b = $self->cbuilder;
my $obj_file = $b->object_file($file);
$self->add_to_cleanup($obj_file);
@@ -3966,9 +3966,7 @@
my $module_name = $self->module_name;
$module_name ||= $spec->{module_name};
- my $b = $self->_cbuilder
- or die "Module::Build is not configured with C_support";
- $b->link(
+ $self->cbuilder->link(
module_name => $module_name,
objects => [$spec->{obj_file}, @$objects],
lib_file => $spec->{lib_file},