| 1 |
package FFI::Build::Plugin; |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use autodie; |
| 6 |
use File::Spec::Functions qw( catdir catfile ); |
| 7 |
|
| 8 |
# ABSTRACT: Platform and local customizations of FFI::Build |
| 9 |
our $VERSION = '2.12'; # VERSION |
| 10 |
|
| 11 |
|
| 12 |
sub new |
| 13 |
{ |
| 14 |
my($class) = @_; |
| 15 |
|
| 16 |
my %plugins; |
| 17 |
|
| 18 |
foreach my $inc (@INC) |
| 19 |
{ |
| 20 |
# CAVEAT: won't work with an @INC hook. Plugins must be in a "real" directory. |
| 21 |
my $path = catdir($inc, 'FFI', 'Build', 'Plugin'); |
| 22 |
next unless -d $path; |
| 23 |
my $dh; |
| 24 |
opendir $dh, $path; |
| 25 |
my @list = readdir $dh; |
| 26 |
closedir $dh; |
| 27 |
|
| 28 |
foreach my $name (map { my $x = $_; $x =~ s/\.pm$//; $x } grep /\.pm$/, @list) |
| 29 |
{ |
| 30 |
next if defined $plugins{$name}; |
| 31 |
my $pm = catfile('FFI', 'Build', 'Plugin', "$name.pm"); |
| 32 |
require $pm; |
| 33 |
my $class = "FFI::Build::Plugin::$name"; |
| 34 |
if($class->can("api_version") && $class->api_version == 0) |
| 35 |
{ |
| 36 |
$plugins{$name} = $class->new; |
| 37 |
} |
| 38 |
else |
| 39 |
{ |
| 40 |
warn "$class is not the correct api version. You may need to upgrade the plugin, platypus or uninstall the plugin"; |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
bless \%plugins, $class; |
| 46 |
} |
| 47 |
|
| 48 |
sub call |
| 49 |
{ |
| 50 |
my($self, $method, @args) = @_; |
| 51 |
|
| 52 |
foreach my $name (sort keys %$self) |
| 53 |
{ |
| 54 |
my $plugin = $self->{$name}; |
| 55 |
$plugin->$method(@args) if $plugin->can($method); |
| 56 |
} |
| 57 |
|
| 58 |
1; |
| 59 |
} |
| 60 |
|
| 61 |
1; |
| 62 |
|
| 63 |
__END__ |
| 64 |
|
| 65 |
=pod |
| 66 |
|
| 67 |
=encoding UTF-8 |
| 68 |
|
| 69 |
=head1 NAME |
| 70 |
|
| 71 |
FFI::Build::Plugin - Platform and local customizations of FFI::Build |
| 72 |
|
| 73 |
=head1 VERSION |
| 74 |
|
| 75 |
version 2.12 |
| 76 |
|
| 77 |
=head1 SYNOPSIS |
| 78 |
|
| 79 |
perldoc FFI::Build |
| 80 |
|
| 81 |
=head1 DESCRIPTION |
| 82 |
|
| 83 |
This class is experimental, but may do something useful in the future. |
| 84 |
|
| 85 |
=head1 SEE ALSO |
| 86 |
|
| 87 |
=over 4 |
| 88 |
|
| 89 |
=item L<FFI::Platypus> |
| 90 |
|
| 91 |
=item L<FFI::Build> |
| 92 |
|
| 93 |
=back |
| 94 |
|
| 95 |
=head1 AUTHOR |
| 96 |
|
| 97 |
Author: Graham Ollis E<lt>[email protected]<gt> |
| 98 |
|
| 99 |
Contributors: |
| 100 |
|
| 101 |
Bakkiaraj Murugesan (bakkiaraj) |
| 102 |
|
| 103 |
Dylan Cali (calid) |
| 104 |
|
| 105 |
pipcet |
| 106 |
|
| 107 |
Zaki Mughal (zmughal) |
| 108 |
|
| 109 |
Fitz Elliott (felliott) |
| 110 |
|
| 111 |
Vickenty Fesunov (vyf) |
| 112 |
|
| 113 |
Gregor Herrmann (gregoa) |
| 114 |
|
| 115 |
Shlomi Fish (shlomif) |
| 116 |
|
| 117 |
Damyan Ivanov |
| 118 |
|
| 119 |
Ilya Pavlov (Ilya33) |
| 120 |
|
| 121 |
Petr Písař (ppisar) |
| 122 |
|
| 123 |
Mohammad S Anwar (MANWAR) |
| 124 |
|
| 125 |
Håkon Hægland (hakonhagland, HAKONH) |
| 126 |
|
| 127 |
Meredith (merrilymeredith, MHOWARD) |
| 128 |
|
| 129 |
Diab Jerius (DJERIUS) |
| 130 |
|
| 131 |
Eric Brine (IKEGAMI) |
| 132 |
|
| 133 |
szTheory |
| 134 |
|
| 135 |
José Joaquín Atria (JJATRIA) |
| 136 |
|
| 137 |
Pete Houston (openstrike, HOUSTON) |
| 138 |
|
| 139 |
Lukas Mai (MAUKE) |
| 140 |
|
| 141 |
=head1 COPYRIGHT AND LICENSE |
| 142 |
|
| 143 |
This software is copyright (c) 2015-2022 by Graham Ollis. |
| 144 |
|
| 145 |
This is free software; you can redistribute it and/or modify it under |
| 146 |
the same terms as the Perl 5 programming language system itself. |
| 147 |
|
| 148 |
=cut |