1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
package ExtUtils::Builder::CPAN::Tool;
$ExtUtils::Builder::CPAN::Tool::VERSION = '0.020';
use 5.010;
use strict;
use warnings;
use parent 'ExtUtils::Builder::Planner::Extension';
sub add_methods {
my (undef, $planner, %args) = @_;
$planner->add_delegate('config', sub {
require ExtUtils::Config;
state $config = ExtUtils::Config->new;
});
$planner->add_delegate('meta', sub {
require CPAN::Meta;
state $meta = CPAN::Meta->load_file('META.json');
});
$planner->add_delegate('distribution', sub {
return $_[0]->meta->name;
});
$planner->add_delegate('version', sub {
return version->new($_[0]->meta->version);
});
$planner->add_delegate('main_module', sub {
state $main_module = do {
my $distribution = $_[0]->distribution;
$distribution =~ s/-/::/g;
$distribution;
};
});
$planner->add_delegate('perl_path', sub {
require ExtUtils::Builder::Util;
state $path = ExtUtils::Builder::Util::get_perl(config => $_[0]->config);
});
$planner->add_delegate($_, sub { !!0 }) for qw/verbose uninst pureperl_only/;
$planner->add_delegate('jobs', sub { 1 });
$planner->add_delegate('is_os', sub {
my ($self, @wanted) = @_;
return not not grep { $_ eq $^O } @wanted
});
$planner->add_delegate('is_os_type', sub {
my ($self, $wanted) = @_;
require Perl::OSType;
return Perl::OSType::is_os_type($wanted);
});
$planner->add_delegate('new_planner', sub {
my ($self, %options) = @_;
my $config = $self->config;
$config = $config->but($options{but}) if $options{but};
require ExtUtils::Builder::Planner;
my $inner = ExtUtils::Builder::Planner->new;
$inner->add_delegate('config', sub { $config });
return $inner;
});
}
1;
# ABSTRACT: A base implementation for CPAN build scripts.
__END__
=pod
=encoding UTF-8
=head1 NAME
ExtUtils::Builder::CPAN::Tool - A base implementation for CPAN build scripts.
=head1 VERSION
version 0.020
=head1 SYNOPSIS
my $planner = ExtUtils::Builder::Planner->new;
$planner->create_phony($_) for qw/code manify dynamic/;
$planner->create_phony('all', qw/code manify dynamic/);
$planner->load_extension('ExtUtils::Builder::CPAN::Tool');
$planner->new_scope->run_dsl($_) for glob 'planner/*.pl';
my $plan = $planner->materialize;
$plan->run('all');
=head1 DESCRIPTION
This provides a base implementation of the CPAN build script protocol. Known specializations of this extension are L<Dist::Build> and L<ExtUtils::Builder::MakeMaker>.
=head1 DELEGATES
=head2 config
The L<ExtUtils::Config|ExtUtils::Config> (or compatible) object for this build.
=head2 meta
A L<CPAN::Meta|CPAN::Meta> object representing the metadata for this distribution. By default this will just load the F<META.json> in the current directory.
=head2 distribution
The name of the distribution
=head2 version
The version of the distribution (as a version object).
=head2 main_module
The main module of the distribution.
=head2 perl_path
The path to the perl executable.
=head2 is_os(@os_names)
This returns true if the current operating system matches any of the listed ones.
=head2 is_os_type($os_type)
This returns true if the type of the OS matches C<$os_type>. Legal values are C<Unix>, C<Windows> and C<VMS>.
=head2 verbose
The requested verbosity. By default this is a stub that always returns false.
=head2 uninst
The value of the C<uninst> command line argument. By default this is a stub that always returns false.
=head2 jobs
The requested number of jobs for this build. By default this is a stub that always returns C<1>.
=head2 pureperl_only
The value of the pureperl_only argument. By default this is a stub that always returns false.
=head2 new_planner.
This creates a new planner, sharing a configuration object with the current one.
=for Pod::Coverage add_methods
=head1 AUTHOR
Leon Timmermans <fawaka@gmail.com>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|