line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::AlienBase::Wrapper 0.32 { |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
366821
|
use 5.014; |
|
2
|
|
|
|
|
15
|
|
4
|
2
|
|
|
2
|
|
691
|
use Moose; |
|
2
|
|
|
|
|
458773
|
|
|
2
|
|
|
|
|
20
|
|
5
|
2
|
|
|
2
|
|
15767
|
use List::Util qw( first ); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
2313
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Use aliens in your Makefile.PL or Build.PL |
8
|
|
|
|
|
|
|
# VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileMunger', |
12
|
|
|
|
|
|
|
'Dist::Zilla::Role::PrereqSource'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has alien => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
17
|
|
|
|
|
|
|
default => sub { [] }, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has _installer => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
lazy => 1, |
23
|
|
|
|
|
|
|
default => sub { |
24
|
|
|
|
|
|
|
my($self) = @_; |
25
|
|
|
|
|
|
|
my $name = first { /^(Build|Makefile)\.PL$/ } map { $_->name } @{ $self->zilla->files }; |
26
|
|
|
|
|
|
|
$self->log_fatal('Unable to find Makefile.PL or Build.PL') unless $name; |
27
|
|
|
|
|
|
|
$name; |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
around mvp_multivalue_args => sub { |
32
|
|
|
|
|
|
|
my($orig, $self) = @_; |
33
|
|
|
|
|
|
|
($self->$orig, 'alien'); |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $comment_begin = "# BEGIN code inserted by @{[ __PACKAGE__ ]}\n"; |
37
|
|
|
|
|
|
|
my $comment_end = "# END code inserted by @{[ __PACKAGE__ ]}\n"; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub register_prereqs |
40
|
|
|
|
|
|
|
{ |
41
|
2
|
|
|
2
|
0
|
5338
|
my($self) = @_; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
96
|
my $zilla = $self->zilla; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
41
|
$zilla->register_prereqs({ |
46
|
|
|
|
|
|
|
phase => 'configure', |
47
|
|
|
|
|
|
|
}, 'Alien::Base::Wrapper' => '1.02' ); |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
573
|
foreach my $spec (@{ $self->alien }) |
|
2
|
|
|
|
|
81
|
|
50
|
|
|
|
|
|
|
{ |
51
|
4
|
|
|
|
|
540
|
my ($alien, $version) = split /\@/, $spec; |
52
|
4
|
|
100
|
|
|
36
|
$version //= "0"; |
53
|
4
|
|
|
|
|
20
|
$zilla->register_prereqs({ |
54
|
|
|
|
|
|
|
phase => 'configure', |
55
|
|
|
|
|
|
|
}, $alien => $version); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub munge_files |
60
|
|
|
|
|
|
|
{ |
61
|
2
|
|
|
2
|
0
|
190692
|
my($self) = @_; |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
5
|
my @aliens = map { s/\@.*$//r } @{ $self->alien }; |
|
4
|
|
|
|
|
29
|
|
|
2
|
|
|
|
|
86
|
|
64
|
|
|
|
|
|
|
|
65
|
2
|
100
|
|
|
|
79
|
if($self->_installer eq 'Makefile.PL') |
|
|
50
|
|
|
|
|
|
66
|
|
|
|
|
|
|
{ |
67
|
1
|
|
|
|
|
10
|
my $code = "use Alien::Base::Wrapper qw( @aliens !export );\n" . |
68
|
|
|
|
|
|
|
"\%WriteMakefileArgs = (\%WriteMakefileArgs, Alien::Base::Wrapper->mm_args);\n"; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
3
|
|
7
|
my $file = first { $_->name eq 'Makefile.PL' } @{ $self->zilla->files }; |
|
3
|
|
|
|
|
131
|
|
|
1
|
|
|
|
|
30
|
|
71
|
1
|
|
|
|
|
56
|
my $content = $file->content; |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
100
|
my $ok = $content =~ s/(unless \( eval \{ ExtUtils::MakeMaker)/"$comment_begin$code$comment_end\n\n$1"/e; |
|
1
|
|
|
|
|
12
|
|
74
|
1
|
50
|
|
|
|
5
|
$self->log_fatal('unable to find the correct location to insert prereqs') |
75
|
|
|
|
|
|
|
unless $ok; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
4
|
$file->content($content); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
elsif($self->_installer eq 'Build.PL') |
81
|
|
|
|
|
|
|
{ |
82
|
1
|
|
|
|
|
9
|
my $code = "use Alien::Base::Wrapper qw( @aliens !export );\n" . |
83
|
|
|
|
|
|
|
"\%module_build_args = (\%module_build_args, Alien::Base::Wrapper->mb_args);\n"; |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
3
|
|
8
|
my $file = first { $_->name eq 'Build.PL' } @{ $self->zilla->files }; |
|
3
|
|
|
|
|
124
|
|
|
1
|
|
|
|
|
30
|
|
86
|
1
|
|
|
|
|
51
|
my $content = $file->content; |
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
89
|
my $ok = $content =~ s/(unless \( eval \{ Module::Build)/"$comment_begin$code$comment_end\n\n$1"/e; |
|
1
|
|
|
|
|
12
|
|
89
|
1
|
50
|
|
|
|
5
|
$self->log_fatal('unable to find the correct location to insert prereqs') |
90
|
|
|
|
|
|
|
unless $ok; |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
4
|
$file->content($content); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
else |
95
|
|
|
|
|
|
|
{ |
96
|
0
|
|
|
|
|
|
$self->log_fatal('unable to find Makefile.PL or Build.PL'); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=pod |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=encoding UTF-8 |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 NAME |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Dist::Zilla::Plugin::AlienBase::Wrapper - Use aliens in your Makefile.PL or Build.PL |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 VERSION |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
version 0.32 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SYNOPSIS |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
[AlienBase::Wrapper] |
122
|
|
|
|
|
|
|
alien = Alien::libfoo1@1.24 |
123
|
|
|
|
|
|
|
alien = Alien::libfoo2 |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 DESCRIPTION |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This L<Dist::Zilla> plugin adjusts the C<Makefile.PL> or C<Build.PL> in your C<XS> project to |
128
|
|
|
|
|
|
|
use L<Alien::Base::Wrapper> which allows you to use one or more L<Alien::Base> based L<Aliens>. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 PROPERTIES |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 alien |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
List of aliens that you want to use in your XS code. You ca suffix this with a at-version |
135
|
|
|
|
|
|
|
to specify a minimum version requirement. (Example C<Alien::Libarchive3@0.28>). |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SEE ALSO |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over 4 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item L<Alien::Base> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item L<Alien::Build::Manual::AlienUser> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=back |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 AUTHOR |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Graham Ollis <plicease@cpan.org> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Graham Ollis. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
156
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |