Permalink
Browse files

noignore Build

  • Loading branch information...
1 parent 4f820f5 commit 4ef9466a3971d24a99fde2431078b7e636228fdd @kazeburo committed Feb 28, 2013
Showing with 92 additions and 1 deletion.
  1. +1 −1 .gitignore
  2. +91 −0 lib/Module/Build/Pluggable/CPANfile.pm
View
@@ -5,7 +5,7 @@ ppport.h
*.sw[po]
*.bak
*.old
-Build
+/Build
_build/
xshelper.h
tags
@@ -0,0 +1,91 @@
+package Module::Build::Pluggable::CPANfile;
+
+use strict;
+use warnings;
+use 5.008005;
+use parent qw/Module::Build::Pluggable::Base/;
+use Module::CPANfile;
+
+our $VERSION = '0.01';
+
+sub HOOK_prepare {
+ my $self = shift;
+ my $args = shift;
+
+ my %copy_prereqs = (
+ 'configure_requires' => [qw/configure/],
+ 'build_requires' => [qw/build test devel/],
+ 'requires' => [qw/runtime/]
+ );
+
+ my $file = Module::CPANfile->load("cpanfile");
+ my $prereq = $file->prereq_specs;
+
+ for my $args_key ( keys %copy_prereqs ) {
+ my $requires = $args->{$args_key} || {};
+ for my $cpanfile_key ( @{$copy_prereqs{$args_key}} ) {
+ $requires = {
+ %$requires,
+ $prereq->{$cpanfile_key} ? %{$prereq->{$cpanfile_key}->{requires}} : ()
+ };
+ }
+ $args->{$args_key} = $requires if keys %$requires;
+ }
+
+}
+
+sub HOOK_configure {
+ my $self = shift;
+ $self->configure_requires("Module::CPANfile", $Module::CPANfile::VERSION);
+}
+
+1;
+__END__
+
+=encoding utf8
+
+=head1 NAME
+
+Module::Build::Pluggable::CPANfile - Include cpanfile
+
+=head1 SYNOPSIS
+
+ # cpanfile
+ requires 'Plack', 0.9;
+ on test => sub {
+ requires 'Test::Warn';
+ };
+
+ # Build.PL
+ use Module::Build::Pluggable (
+ 'CPANfile'
+ );
+
+ my $builder = Module::Build::Pluggable->new(
+ ... # normal M::B args execlude prereqs
+ );
+ $builder->create_build_script();
+
+=head1 DESCRIPTION
+
+Module::Build::Pluggable::CPANfile is plugin for Module::Build::Pluggable to include dependencies from cpanfile into meta files.
+This modules is L<Module::Install::CPANfile> for Module::Build
+
+B<THIS IS A DEVELOPMENT RELEASE. API MAY CHANGE WITHOUT NOTICE>.
+
+=head1 AUTHOR
+
+Masahiro Nagano E<lt>kazeburo@gmail.comE<gt>
+
+=head1 SEE ALSO
+
+L<Module::Install::CPANfile>, L<cpanfile>, L<Module::Build::Pluggable>
+
+=head1 LICENSE
+
+Copyright (C) Masahiro Nagano
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut

0 comments on commit 4ef9466

Please sign in to comment.