line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
3159721
|
use strict; |
|
2
|
|
|
|
|
31
|
|
|
2
|
|
|
|
|
73
|
|
2
|
2
|
|
|
2
|
|
16
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
3
|
2
|
|
|
2
|
|
57
|
use 5.020; |
|
2
|
|
|
|
|
8
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::FFI::Mint 0.03 { |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
564
|
use Moose; |
|
2
|
|
|
|
|
479779
|
|
|
2
|
|
|
|
|
27
|
|
8
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileMunger', 'Dist::Zilla::Role::FileGatherer', 'Dist::Zilla::Role::ModuleMaker'; |
9
|
2
|
|
|
2
|
|
15796
|
use experimental qw( signatures postderef ); |
|
2
|
|
|
|
|
3667
|
|
|
2
|
|
|
|
|
16
|
|
10
|
2
|
|
|
2
|
|
1502
|
use Dist::Zilla::File::InMemory; |
|
2
|
|
|
|
|
629648
|
|
|
2
|
|
|
|
|
142
|
|
11
|
2
|
|
|
2
|
|
28
|
use namespace::autoclean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
21
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Generate module and modify dist.ini for use with FFI |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has lib_name => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
isa => 'Str', |
18
|
|
|
|
|
|
|
lazy => 1, |
19
|
|
|
|
|
|
|
default => sub ($self) { |
20
|
|
|
|
|
|
|
$self->zilla->chrome->prompt_str("Library name (for libfoo.so or foo.dll enter 'foo')"); |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has alien_name => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
isa => 'Str', |
27
|
|
|
|
|
|
|
lazy => 1, |
28
|
|
|
|
|
|
|
default => sub ($self) { |
29
|
|
|
|
|
|
|
$self->zilla->chrome->prompt_str("Fallback Alien name"); |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has module_package => ( |
34
|
|
|
|
|
|
|
is => 'rw', |
35
|
|
|
|
|
|
|
isa => 'Str', |
36
|
|
|
|
|
|
|
init_arg => undef, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has module_filename => ( |
40
|
|
|
|
|
|
|
is => 'rw', |
41
|
|
|
|
|
|
|
isa => 'Str', |
42
|
|
|
|
|
|
|
init_arg => undef, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has lib_package => ( |
46
|
|
|
|
|
|
|
is => 'ro', |
47
|
|
|
|
|
|
|
isa => 'Str', |
48
|
|
|
|
|
|
|
init_arg => undef, |
49
|
|
|
|
|
|
|
lazy => 1, |
50
|
|
|
|
|
|
|
default => sub ($self) { |
51
|
|
|
|
|
|
|
$self->module_package . "::Lib"; |
52
|
|
|
|
|
|
|
}, |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has lib_filename => ( |
56
|
|
|
|
|
|
|
is => 'ro', |
57
|
|
|
|
|
|
|
isa => 'Str', |
58
|
|
|
|
|
|
|
init_arg => undef, |
59
|
|
|
|
|
|
|
lazy => 1, |
60
|
|
|
|
|
|
|
default => sub ($self) { |
61
|
|
|
|
|
|
|
$self->module_filename =~ s/\.pm$/\/Lib.pm/r; |
62
|
|
|
|
|
|
|
}, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has test_filename => ( |
66
|
|
|
|
|
|
|
is => 'ro', |
67
|
|
|
|
|
|
|
isa => 'Str', |
68
|
|
|
|
|
|
|
init_arg => undef, |
69
|
|
|
|
|
|
|
lazy => 1, |
70
|
|
|
|
|
|
|
default => sub ($self) { |
71
|
|
|
|
|
|
|
't/' . lc($self->module_package =~ s/::/_/gr) . ".t"; |
72
|
|
|
|
|
|
|
}, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub munge_files ($self) |
76
|
1
|
|
|
1
|
0
|
10931
|
{ |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
77
|
1
|
|
|
|
|
2
|
my($dist_ini) = grep { $_->name eq 'dist.ini' } @{ $self->zilla->files }; |
|
5
|
|
|
|
|
311
|
|
|
1
|
|
|
|
|
44
|
|
78
|
1
|
50
|
|
|
|
61
|
$self->log_fatal("unable to find dist.ini") unless defined $dist_ini; |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
5
|
$self->log("Munge: @{[ $dist_ini->name ]}"); |
|
1
|
|
|
|
|
5
|
|
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
590
|
my $code = $dist_ini->code; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# this is hilariously stupid but this is what we are doing. |
85
|
|
|
|
|
|
|
$dist_ini->code(sub { |
86
|
1
|
|
|
1
|
|
9392
|
my $content = $code->(); |
87
|
1
|
|
|
|
|
3189
|
$content =~ s/##LIB_FILENAME##/$self->lib_filename/eg; |
|
1
|
|
|
|
|
44
|
|
88
|
1
|
|
|
|
|
10
|
$content =~ s/##LIB_MODULENAME##/$self->lib_package/eg; |
|
1
|
|
|
|
|
36
|
|
89
|
1
|
|
|
|
|
7
|
$content =~ s/##ALIEN_NAME##/$self->alien_name/eg; |
|
1
|
|
|
|
|
36
|
|
90
|
1
|
|
|
|
|
4
|
$content; |
91
|
1
|
|
|
|
|
63
|
}); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub gather_files ($self) |
95
|
1
|
|
|
1
|
0
|
647
|
{ |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
96
|
1
|
|
|
|
|
3
|
$self->log("Generate: @{[ $self->lib_filename ]}"); |
|
1
|
|
|
|
|
40
|
|
97
|
1
|
|
|
|
|
323
|
$self->add_file( |
98
|
|
|
|
|
|
|
Dist::Zilla::File::InMemory->new({ |
99
|
|
|
|
|
|
|
name => $self->lib_filename, |
100
|
|
|
|
|
|
|
content => <<"END1", |
101
|
1
|
|
|
|
|
35
|
package @{[ $self->lib_package ]}; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
use strict; |
104
|
|
|
|
|
|
|
use warnings; |
105
|
|
|
|
|
|
|
use FFI::CheckLib 0.28 qw( find_lib ); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub lib { |
108
|
1
|
|
|
|
|
51
|
find_lib lib => '@{[ $self->lib_name ]}', alien => '@{[ $self->alien_name ]}'; |
|
1
|
|
|
|
|
36
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 NAME |
114
|
|
|
|
|
|
|
|
115
|
1
|
|
|
|
|
34
|
@{[ $self->lib_package ]} - Private class for @{[ $self->module_package ]} |
|
1
|
|
|
|
|
48
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SYNOPSIS |
118
|
|
|
|
|
|
|
|
119
|
1
|
|
|
|
|
35
|
perldoc @{[ $self->module_package ]} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DESCRIPTION |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This class is private. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 SEE ALSO |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=over 4 |
128
|
|
|
|
|
|
|
|
129
|
1
|
|
|
|
|
33
|
=item @{[ $self->module_package ]} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
END1 |
135
|
|
|
|
|
|
|
}) |
136
|
|
|
|
|
|
|
); |
137
|
|
|
|
|
|
|
|
138
|
1
|
|
|
|
|
722
|
$self->log("Generate: @{[ $self->test_filename ]}"); |
|
1
|
|
|
|
|
35
|
|
139
|
1
|
|
|
|
|
320
|
$self->add_file( |
140
|
|
|
|
|
|
|
Dist::Zilla::File::InMemory->new({ |
141
|
|
|
|
|
|
|
name => $self->test_filename, |
142
|
|
|
|
|
|
|
content => <<"END2", |
143
|
|
|
|
|
|
|
use Test2::V0; |
144
|
1
|
|
|
|
|
35
|
use @{[ $self->module_package ]}; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
ok 1; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
done_testing; |
149
|
|
|
|
|
|
|
END2 |
150
|
|
|
|
|
|
|
}), |
151
|
|
|
|
|
|
|
); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
1
|
|
|
|
|
3
|
sub make_module ($self, $arg) |
155
|
1
|
|
|
1
|
0
|
245325
|
{ |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
156
|
1
|
|
|
|
|
37
|
$self->module_package($arg->{name}); |
157
|
1
|
|
|
|
|
42
|
$self->module_filename("lib/" . ($arg->{name} =~ s/::/\//gr) . ".pm"); |
158
|
1
|
|
|
|
|
3
|
$self->log("Creating main module: @{[ $self->module_filename ]}"); |
|
1
|
|
|
|
|
34
|
|
159
|
|
|
|
|
|
|
|
160
|
1
|
|
|
|
|
334
|
my $file = Dist::Zilla::File::InMemory->new({ |
161
|
|
|
|
|
|
|
name => $self->module_filename, |
162
|
|
|
|
|
|
|
content => <<"END3", |
163
|
1
|
|
|
|
|
34
|
package @{[ $self->module_package ]}; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
use strict; |
166
|
|
|
|
|
|
|
use warnings; |
167
|
|
|
|
|
|
|
use FFI::Platypus 1.00; |
168
|
1
|
|
|
|
|
32
|
use @{[ $self->module_package ]}::Lib; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
my \$ffi = FFI::Platypus->new( |
171
|
|
|
|
|
|
|
api => 1, |
172
|
1
|
|
|
|
|
33
|
lib => [@{[ $self->module_package ]}::Lib->lib], |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
#\$ffi->attach( ... ); |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 NAME |
180
|
|
|
|
|
|
|
|
181
|
1
|
|
|
|
|
33
|
@{[ $self->module_package ]} - Bindings for ... |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 SYNOPSIS |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
... |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 DESCRIPTION |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
... |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |
192
|
|
|
|
|
|
|
END3 |
193
|
|
|
|
|
|
|
}); |
194
|
1
|
|
|
|
|
503
|
$self->add_file($file); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
1; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
__END__ |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=pod |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=encoding UTF-8 |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 NAME |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Dist::Zilla::Plugin::FFI::Mint - Generate module and modify dist.ini for use with FFI |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 VERSION |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
version 0.03 |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 SYNOPSIS |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
dzil new -P FFI Foo::FFI |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 DESCRIPTION |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
This plugin will prompt you for a library which will be used by your |
223
|
|
|
|
|
|
|
FFI module. Its intended use if by the FFI minting profile, but may |
224
|
|
|
|
|
|
|
be useful in your own FFI related profiles. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 SEE ALSO |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=over 4 |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=item L<FFI::Platypus> |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item L<Dist::Zilla::MintingProfile::FFI> |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item L<Dist::Zilla> |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=back |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 AUTHOR |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Graham Ollis <plicease@cpan.org> |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Graham Ollis. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
247
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |