t000755001750001750 014050305114 13633 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28ci.t100644001750001750 234114050305114 14553 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/tuse Test2::Require::EnvVar 'CIPSOMETHING'; use Test2::V0 -no_srand => 1; use FFI::CheckLib qw( find_lib ); use FFI::Platypus; # This test should only run under ci in a docker container with # libffi and libyaml development packages installed subtest 'libffi' => sub { my @ffi; is( [@ffi = find_lib lib => 'ffi'], bag { item match qr/libffi\.so/; etc; }, 'have ffi', ); note "lib = $_" for @ffi; my $ffi = FFI::Platypus->new; $ffi->lib(@ffi); my $ffi_raw_call = eval { $ffi->function('ffi_raw_call' => [] => 'void') }; ok $ffi_raw_call, "has symbol ffi_raw_call"; }; subtest 'yaml' => sub { my @yaml; is( [@yaml = find_lib lib => 'yaml', try_linker_script => 1], bag { item match qr/libyaml.*\.so/; etc; }, 'have yaml', ); note "lib = $_" for @yaml; my $ffi = FFI::Platypus->new; $ffi->lib(@yaml); my $yaml_get_version_string = eval { $ffi->function('yaml_get_version_string' => [] => 'string') }; ok $yaml_get_version_string, "has symbol yaml_get_version_string"; return unless $yaml_get_version_string; ok $yaml_get_version_string->(), "has a version yo"; note "yaml_get_version_string = ", $yaml_get_version_string->(); }; done_testing; FFI-CheckLib-0.28000755001750001750 014050305114 13447 5ustar00ollisgollisg000000000000README100644001750001750 2230514050305114 14432 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28NAME FFI::CheckLib - Check that a library is available for FFI VERSION version 0.28 SYNOPSIS use FFI::CheckLib; check_lib_or_exit( lib => 'jpeg', symbol => 'jinit_memory_mgr' ); check_lib_or_exit( lib => [ 'iconv', 'jpeg' ] ); # or prompt for path to library and then: print "where to find jpeg library: "; my $path = ; check_lib_or_exit( lib => 'jpeg', libpath => $path ); DESCRIPTION This module checks whether a particular dynamic library is available for FFI to use. It is modeled heavily on Devel::CheckLib, but will find dynamic libraries even when development packages are not installed. It also provides a find_lib function that will return the full path to the found dynamic library, which can be feed directly into FFI::Platypus or another FFI system. Although intended mainly for FFI modules via FFI::Platypus and similar, this module does not actually use any FFI to do its detection and probing. This module does not have any non-core runtime dependencies. The test suite does depend on Test2::Suite. FUNCTIONS All of these take the same named parameters and are exported by default. find_lib my(@libs) = find_lib(%args); This will return a list of dynamic libraries, or empty list if none were found. [version 0.05] If called in scalar context it will return the first library found. Arguments are key value pairs with these keys: lib Must be either a string with the name of a single library or a reference to an array of strings of library names. Depending on your platform, CheckLib will prepend lib or append .dll or .so when searching. [version 0.11] As a special case, if * is specified then any libs found will match. libpath A string or array of additional paths to search for libraries. systempath [version 0.11] A string or array of system paths to search for instead of letting FFI::CheckLib determine the system path. You can set this to [] in order to not search any system paths. symbol A string or a list of symbol names that must be found. verify A code reference used to verify a library really is the one that you want. It should take two arguments, which is the name of the library and the full path to the library pathname. It should return true if it is acceptable, and false otherwise. You can use this in conjunction with FFI::Platypus to determine if it is going to meet your needs. Example: use FFI::CheckLib; use FFI::Platypus; my($lib) = find_lib( lib => 'foo', verify => sub { my($name, $libpath) = @_; my $ffi = FFI::Platypus->new; $ffi->lib($libpath); my $f = $ffi->function('foo_version', [] => 'int'); return $f->call() >= 500; # we accept version 500 or better }, ); recursive [version 0.11] Recursively search for libraries in any non-system paths (those provided via libpath above). try_linker_script [version 0.24] Some vendors provide .so files that are linker scripts that point to the real binary shared library. These linker scripts can be used by gcc or clang, but are not directly usable by FFI::Platypus and friends. On select platforms, this options will use the linker command (ld) to attempt to resolve the real .so for non-binary files. Since there is extra overhead this is off by default. An example is libyaml on Red Hat based Linux distributions. On Debian these are handled with symlinks and no trickery is required. alien [version 0.25] If no libraries can be found, try the given aliens instead. The Alien classes specified must provide the Alien::Base interface for dynamic libraries, which is to say they should provide a method called dynamic_libs that returns a list of dynamic libraries. [version 0.28] In 0.28 and later, if the Alien is not installed then it will be ignored and this module will search in system or specified directories only. This module will still throw an exception, if the Alien doesn't look like a module name or if it does not provide a dynamic_libs method (which is implemented by all Alien::Base subclasses). assert_lib assert_lib(%args); This behaves exactly the same as find_lib, except that instead of returning empty list of failure it throws an exception. check_lib_or_exit check_lib_or_exit(%args); This behaves exactly the same as assert_lib, except that instead of dying, it warns (with exactly the same error message) and exists. This is intended for use in Makefile.PL or Build.PL find_lib_or_exit [version 0.05] my(@libs) = find_lib_or_exit(%args); This behaves exactly the same as find_lib, except that if the library is not found, it will call exit with an appropriate diagnostic. find_lib_or_die [version 0.06] my(@libs) = find_lib_or_die(%args); This behaves exactly the same as find_lib, except that if the library is not found, it will die with an appropriate diagnostic. check_lib my $bool = check_lib(%args); This behaves exactly the same as find_lib, except that it returns true (1) on finding the appropriate libraries or false (0) otherwise. which [version 0.17] my $path = where($name); Return the path to the first library that matches the given name. Not exported by default. where [version 0.17] my @paths = where($name); Return the paths to all the libraries that match the given name. Not exported by default. has_symbols [version 0.17] my $bool = has_symbols($path, @symbol_names); Returns true if all of the symbols can be found in the dynamic library located at the given path. Can be useful in conjunction with verify with find_lib above. Not exported by default. system_path [version 0.20] my $path = FFI::CheckLib::system_path; Returns the system path as a list reference. On some systems, this is PATH on others it might be LD_LIBRARY_PATH on still others it could be something completely different. So although you may add items to this list, you should probably do some careful consideration before you do so. This function is not exportable, even on request. FAQ Why not just use dlopen? Calling dlopen on a library name and then dlclose immediately can tell you if you have the exact name of a library available on a system. It does have a number of drawbacks as well. No absolute or relative path It only tells you that the library is somewhere on the system, not having the absolute or relative path makes it harder to generate useful diagnostics. POSIX only This doesn't work on non-POSIX systems like Microsoft Windows. If you are using a POSIX emulation layer on Windows that provides dlopen, like Cygwin, there are a number of gotchas there as well. Having a layer written in Perl handles this means that developers on Unix can develop FFI that will more likely work on these platforms without special casing them. inconsistent implementations Even on POSIX systems you have inconsistent implementations. OpenBSD for example don't usually include symlinks for .so files meaning you need to know the exact .so version. non-system directories By default dlopen only works for libraries in the system paths. Most platforms have a way of configuring the search for different non-system paths, but none of them are portable, and are usually discouraged anyway. Alien and friends need to do searches for dynamic libraries in non-system directories for share installs. My 64-bit Perl is misconfigured and has 32-bit libraries in its search path. Is that a bug in FFI::CheckLib? Nope. The way FFI::CheckLib is implemented it won't work on AIX, HP-UX, OpenVMS or Plan 9. I know for a fact that it doesn't work on AIX as currently implemented because I used to develop on AIX in the early 2000s, and I am aware of some of the technical challenges. There are probably other systems that it won't work on. I would love to add support for these platforms. Realistically these platforms have a tiny market share, and absent patches from users or the companies that own these operating systems (patches welcome), or hardware / CPU time donations, these platforms are unsupportable anyway. SEE ALSO FFI::Platypus Call library functions dynamically without a compiler. Dist::Zilla::Plugin::FFI::CheckLib Dist::Zilla plugin for this module. AUTHOR Author: Graham Ollis Contributors: Bakkiaraj Murugesan (bakkiaraj) Dan Book (grinnz, DBOOK) Ilya Pavlov (Ilya, ILUX) Shawn Laffan (SLAFFAN) Petr Pisar (ppisar) COPYRIGHT AND LICENSE This software is copyright (c) 2014-2018 by Graham Ollis. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Changes100644001750001750 1064114050305114 15045 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28Revision history for FFI-CheckLib 0.28 2021-05-16 15:10:34 -0600 - Avoid undef warning from File::Spec->catpath (gh#30, gh#33) - The alien option now works in fallback mode; if one or more of the Aliens are not installed then they will be ignored, previously this module would throw whatever exception was produced by require (gh#23, gh#34) - Move to PerlFFI org on GitHub (previously this dist lived in Perl5-FFI) (gh#24) 0.27 2020-05-11 14:24:08 -0400 - Added a FAQ section to the documentation (gh#22) 0.26 2020-01-22 05:54:02 -0700 - Name check on alien option is always done, even if the Alien is already loaded (gh#21) - Remove dependency on Module::Load (gh#21) 0.25 2019-06-25 12:27:58 -0400 - Add support for Alien::Base with alien option (gh#18) 0.24 2019-04-27 09:14:34 -0400 - Add try_linker_script option (gh#13, gh#15) 0.23 2018-11-18 00:07:49 -0500 - Handle DLLs on Windows with "dashed" version numbers (example: foo-1-2-3.dll) (gh#10, gh#11, SLAFFAN++) 0.22 2018-10-13 22:24:46 -0400 - Production version identical to 0.21_01 0.21_01 2018-10-11 22:53:43 -0400 - Documentation fixes - Handle DLLs with upper-case characters in extension on MSWin32 (gh#9) 0.20 2018-06-04 18:18:09 -0400 - Add system_path function. 0.19 2018-05-30 21:09:32 -0400 - Administrative release to note that this dist is moving its repository to the Perl5-FFI org on github.com 0.18 2017-10-25 10:00:47 -0400 - Production version identical to 0.17_02 0.17_02 2017-10-14 01:03:04 -0400 - Fix Windows testing regression introduced in 0.17_01 0.17_01 2017-10-13 15:58:30 -0400 - Filter out broken and recursive symlinks - Better handle symlinked .so files on platforms that support that. Previously, we preferred the longer .so names (ie, libfoo.so.1.2.3) over the shorter .so names (libfoo.so) since the latter is usually a symlink, and the former may have useful "version" information in the filename. That is a problem when a system is using symlinks to indicate a preference, (for example, if there are both libfoo.so.1.2.3, libfoo.so.1.2.4 and libfoo.so is a symlink to one of those). Now we still endevour to return the long .so name, but use the short name to see which one is preferred by the operating system, or user. In the absense of any symlinks to disambiguate two libraries with the same name, we prefer the one with a newer version number. That is libfoo.so.2.3.4 would be preferred over libfoo.so.1.2.3 - Slightly more consistent diagnostic messages. - Added functions: which, where, has_symbols None are exported by default, but may be requested. 0.16 2017-08-08 10:24:49 -0400 - Tentative support for msys 0.15 2016-05-05 19:53:32 -0400 - Add MSYS2 support 0.14 2015-09-09 08:25:15 -0400 - Version identical to 0.12 (0.12 was accidentally removed from CPAN) 0.12 2015-08-06 16:09:32 -0400 - Switch to MakeMaker since we are not using any features that require Module::Build 0.11 2015-02-13 08:45:23 -0500 - New recursive option - The experimental _r option will be keept beiefly then removed - The lib option allows '*' to match any library - New systempath option 0.10 2015-02-12 18:52:54 -0500 - Add experimental and undocumented _r option intended for use with Alien::Base only. 0.09 2015-01-28 17:10:53 -0500 - Skip undef found in system library path. (thanks bakkiaraj gh#3) On Windows this was causing a undef'd variable warning if %PATH% has a trailing ; 0.08 2015-01-25 04:54:37 -0500 - Prefer FFI::Platypus in documentation over other FFI systems 0.07 2015-01-16 10:22:22 -0500 - bugfix: forgot to export find_lib_or_die 0.06 2015-01-13 12:07:19 -0500 - add function find_lib_or_die 0.05 2015-01-10 17:31:34 -0500 - add function find_lib_or_exit (GH#2) - [API CHANGE] find_lib returns first library found if called in scalar context, instead of the number of libraries found. - better diagnostics for failure (GH#1) 0.04 2015-01-02 11:21:59 -0500 - works with .bundle files on OS X (previously only with .dylib files) 0.03 2014-10-26 16:35:22 -0400 - use DynaLoader for symbol resolution instead actual FFI - add verify option 0.02 2014-10-26 13:18:14 -0400 - first release to CPAN 0.01 2014-10-26 11:34:58 -0400 - initial version LICENSE100644001750001750 4367414050305114 14573 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28This software is copyright (c) 2014-2018 by Graham Ollis. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2014-2018 by Graham Ollis. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2014-2018 by Graham Ollis. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End INSTALL100644001750001750 433214050305114 14563 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28This is the Perl distribution FFI-CheckLib. Installing FFI-CheckLib is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm FFI::CheckLib If it does not have permission to install modules to the current perl, cpanm will automatically set up and install to a local::lib in your home directory. See the local::lib documentation (https://metacpan.org/pod/local::lib) for details on enabling it in your environment. ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan FFI::CheckLib ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, install configure prerequisites (see below), then build it: % perl Makefile.PL % make && make test Then install it: % make install On Windows platforms, you should use `dmake` or `nmake`, instead of `make`. If your perl is system-managed, you can create a local::lib in your home directory to install modules to. For details, see the local::lib documentation: https://metacpan.org/pod/local::lib The prerequisites of this distribution will also have to be installed manually. The prerequisites are listed in one of the files: `MYMETA.yml` or `MYMETA.json` generated by running the manual build process described above. ## Configure Prerequisites This distribution requires other modules to be installed before this distribution's installer can be run. They can be found under the "configure_requires" key of META.yml or the "{prereqs}{configure}{requires}" key of META.json. ## Other Prerequisites This distribution may require additional modules to be installed after running Makefile.PL. Look for prerequisites in the following phases: * to run make, PHASE = build * to use the module code itself, PHASE = runtime * to run tests, PHASE = test They can all be found in the "PHASE_requires" key of MYMETA.yml or the "{prereqs}{PHASE}{requires}" key of MYMETA.json. ## Documentation FFI-CheckLib documentation is available as POD. You can run `perldoc` from a shell to read the documentation: % perldoc FFI::CheckLib For more information on installing Perl modules via CPAN, please see: https://www.cpan.org/modules/INSTALL.html dist.ini100644001750001750 213514050305114 15175 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28name = FFI-CheckLib author = Graham Ollis license = Perl_5 copyright_holder = Graham Ollis copyright_year = 2014-2018 version = 0.28 [@Author::Plicease] :version = 2.47 release_tests = 1 irc = irc://irc.perl.org/#native test2_v0 = 1 diag = +Test2::Tools::Process diag = +DynaLoader diag = +FFI::Platypus github_user = PerlFFI github_repo = FFI-CheckLib workflow = linux workflow = macos workflow = cygwin [RemovePrereqs] remove = strict remove = warnings remove = constant remove = lib remove = base remove = Env remove = Carp remove = Exporter remove = File::Spec remove = File::Basename remove = DynaLoader remove = FFI::Platypus remove = Test2::Tools::Process [Author::Plicease::Upload] cpan = 1 [Author::Plicease::Thanks] current = Graham Ollis contributor = Bakkiaraj Murugesan (bakkiaraj) contributor = Dan Book (grinnz, DBOOK) contributor = Ilya Pavlov (Ilya, ILUX) contributor = Shawn Laffan (SLAFFAN) contributor = Petr Pisar (ppisar) [MetaNoIndex] directory = corpus META.yml100644001750001750 231414050305114 15001 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28--- abstract: 'Check that a library is available for FFI' author: - 'Graham Ollis ' build_requires: Test2::API: '1.302015' Test2::Require::EnvVar: '0.000060' Test2::Require::Module: '0.000060' Test2::V0: '0.000060' perl: '5.006' configure_requires: ExtUtils::MakeMaker: '0' perl: '5.006' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.017, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: FFI-CheckLib no_index: directory: - corpus requires: List::Util: '1.33' perl: '5.006' resources: IRC: irc://irc.perl.org/#native bugtracker: https://github.com/PerlFFI/FFI-CheckLib/issues homepage: https://metacpan.org/pod/FFI::CheckLib repository: git://github.com/PerlFFI/FFI-CheckLib.git version: '0.28' x_contributors: - 'Graham Ollis ' - 'Bakkiaraj Murugesan (bakkiaraj)' - 'Dan Book (grinnz, DBOOK)' - 'Ilya Pavlov (Ilya, ILUX)' - 'Shawn Laffan (SLAFFAN)' - 'Petr Pisar (ppisar)' x_generated_by_perl: v5.33.9 x_serialization_backend: 'YAML::Tiny version 1.73' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' x_use_unsafe_inc: 0 MANIFEST100644001750001750 512514050305114 14664 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.017. Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README author.yml corpus/cygwin/bin/cygapatosaurus-0.dll corpus/cygwin/bin/cygdinosaur.dll corpus/darwin/custom/libfoo.dylib corpus/darwin/foo-1.00/src/libs/libbar.dylib corpus/darwin/foo-1.00/src/libs/libbaz.dylib corpus/darwin/foo-1.00/src/libs/libfoo.dylib corpus/darwin/lib/libfoo.dylib corpus/darwin/lib/libfoo.dylib.2 corpus/darwin/lib/libfoo.dylib.2.3 corpus/darwin/lib/libfoo.dylib.2.3.4 corpus/darwin/usr/lib/libbar.dylib corpus/darwin/usr/lib/libbar.dylib.1 corpus/darwin/usr/lib/libbar.dylib.1.2 corpus/darwin/usr/lib/libbar.dylib.1.2.3 corpus/darwin/usr/lib/libfoo.a corpus/darwin/usr/lib/libfoo.dylib corpus/darwin/usr/lib/libfoo.dylib.1 corpus/darwin/usr/lib/libfoo.dylib.1.2 corpus/darwin/usr/lib/libfoo.dylib.1.2.3 corpus/generic.dll corpus/lib/Alien/libbar.pm corpus/unix/custom/libfoo.so corpus/unix/foo-1.00/src/libs/libbar.so corpus/unix/foo-1.00/src/libs/libbaz.so corpus/unix/foo-1.00/src/libs/libfoo.so corpus/unix/lib/libfoo.so corpus/unix/lib/libfoo.so.2 corpus/unix/lib/libfoo.so.2.3 corpus/unix/lib/libfoo.so.2.3.4 corpus/unix/usr/lib/libbar.so corpus/unix/usr/lib/libbar.so.1 corpus/unix/usr/lib/libbar.so.1.2 corpus/unix/usr/lib/libbar.so.1.2.3 corpus/unix/usr/lib/libcrypto.so.0.9.8 corpus/unix/usr/lib/libcrypto.so.1.0.0 corpus/unix/usr/lib/libfoo.a corpus/unix/usr/lib/libfoo.so corpus/unix/usr/lib/libfoo.so.1 corpus/unix/usr/lib/libfoo.so.1.2 corpus/unix/usr/lib/libfoo.so.1.2.3 corpus/unix/usr/lib/libxor.so corpus/unix/usr/lib/libxor.so.1 corpus/unix/usr/lib/libxor.so.1.2 corpus/unix/usr/lib/libxor.so.1.2.3 corpus/unix/usr/lib/libxor.so.1.2.4 corpus/windows/bin/dinosaur.dll corpus/windows/bin/dromornis_planei-3.0-7-0.dll corpus/windows/bin/libapatosaurus-0.dll corpus/windows/bin/libmaiasaura-3-7-0.dll corpus/windows/bin/libthylacaleo_carnifex-3-7___.dll corpus/windows/bincase/LIBbar.DLL corpus/windows/bincase/foo.DLL dist.ini example/wheredll.pl example/whichdll.pl lib/FFI/CheckLib.pm maint/cip-before-install perlcriticrc t/00_diag.t t/ci.t t/ffi_checklib.t t/ffi_checklib__exit.t t/ffi_checklib__os_cygwin.t t/ffi_checklib__os_darwin.t t/ffi_checklib__os_mswin32.t t/ffi_checklib__os_msys.t t/ffi_checklib__os_unix.t t/lib/Test2/Plugin/FauxOS.pm t/lib/Test2/Tools/FauxDynaLoader.pm t/lib/Test2/Tools/NoteStderr.pm xt/author/critic.t xt/author/eol.t xt/author/no_tabs.t xt/author/pod.t xt/author/pod_coverage.t xt/author/pod_spelling_common.t xt/author/pod_spelling_system.t xt/author/strict.t xt/author/version.t xt/release/changes.t xt/release/fixme.t META.json100644001750001750 505614050305114 15157 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28{ "abstract" : "Check that a library is available for FFI", "author" : [ "Graham Ollis " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.017, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "FFI-CheckLib", "no_index" : { "directory" : [ "corpus" ] }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0", "perl" : "5.006" } }, "develop" : { "requires" : { "FindBin" : "0", "Perl::Critic" : "0", "Test2::Require::Module" : "0.000060", "Test2::Tools::PerlCritic" : "0", "Test2::V0" : "0.000060", "Test::CPAN::Changes" : "0", "Test::EOL" : "0", "Test::Fixme" : "0.07", "Test::More" : "0.98", "Test::NoTabs" : "0", "Test::Pod" : "0", "Test::Pod::Coverage" : "0", "Test::Pod::Spelling::CommonMistakes" : "0", "Test::Spelling" : "0", "Test::Strict" : "0", "YAML" : "0" } }, "runtime" : { "requires" : { "List::Util" : "1.33", "perl" : "5.006" } }, "test" : { "requires" : { "Test2::API" : "1.302015", "Test2::Require::EnvVar" : "0.000060", "Test2::Require::Module" : "0.000060", "Test2::V0" : "0.000060", "perl" : "5.006" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/PerlFFI/FFI-CheckLib/issues" }, "homepage" : "https://metacpan.org/pod/FFI::CheckLib", "repository" : { "type" : "git", "url" : "git://github.com/PerlFFI/FFI-CheckLib.git", "web" : "https://github.com/PerlFFI/FFI-CheckLib" }, "x_IRC" : "irc://irc.perl.org/#native" }, "version" : "0.28", "x_contributors" : [ "Graham Ollis ", "Bakkiaraj Murugesan (bakkiaraj)", "Dan Book (grinnz, DBOOK)", "Ilya Pavlov (Ilya, ILUX)", "Shawn Laffan (SLAFFAN)", "Petr Pisar (ppisar)" ], "x_generated_by_perl" : "v5.33.9", "x_serialization_backend" : "Cpanel::JSON::XS version 4.26", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later", "x_use_unsafe_inc" : 0 } author.yml100644001750001750 104014050305114 15550 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28--- pod_spelling_system: skip: 0 # list of words that are spelled correctly # (regardless of what spell check thinks) stopwords: - libpath - Bakkiaraj - Murugesan - bakkiaraj - libs - systempath - grinnz - DBOOK - ILUX - Laffan - SLAFFAN - libyaml - Petr - Pisar - ppisar - UX pod_coverage: skip: 0 # format is "Class#method" or "Class", regex allowed # for either Class or method. private: [] unused_vars: skip: 0 global: ignore_vars: [] module: {} 00_diag.t100644001750001750 257614050305114 15375 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/tuse Test2::V0 -no_srand => 1; use Config; eval { require 'Test/More.pm' }; # This .t file is generated. # make changes instead to dist.ini my %modules; my $post_diag; $modules{$_} = $_ for qw( DynaLoader ExtUtils::MakeMaker FFI::Platypus List::Util Test2::API Test2::Require::EnvVar Test2::Require::Module Test2::Tools::Process Test2::V0 ); my @modules = sort keys %modules; sub spacer () { diag ''; diag ''; diag ''; } pass 'okay'; my $max = 1; $max = $_ > $max ? $_ : $max for map { length $_ } @modules; our $format = "%-${max}s %s"; spacer; my @keys = sort grep /(MOJO|PERL|\A(LC|HARNESS)_|\A(SHELL|LANG)\Z)/i, keys %ENV; if(@keys > 0) { diag "$_=$ENV{$_}" for @keys; if($ENV{PERL5LIB}) { spacer; diag "PERL5LIB path"; diag $_ for split $Config{path_sep}, $ENV{PERL5LIB}; } elsif($ENV{PERLLIB}) { spacer; diag "PERLLIB path"; diag $_ for split $Config{path_sep}, $ENV{PERLLIB}; } spacer; } diag sprintf $format, 'perl', "$] $^O $Config{archname}"; foreach my $module (sort @modules) { my $pm = "$module.pm"; $pm =~ s{::}{/}g; if(eval { require $pm; 1 }) { my $ver = eval { $module->VERSION }; $ver = 'undef' unless defined $ver; diag sprintf $format, $module, $ver; } else { diag sprintf $format, $module, '-'; } } if($post_diag) { spacer; $post_diag->(); } spacer; done_testing; Makefile.PL100644001750001750 316414050305114 15506 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28BEGIN { use strict; use warnings; unless(eval q{ use 5.006; 1}) { print "Perl 5.006 or better required\n"; exit; } } # This file was automatically generated by Dist::Zilla::Plugin::Author::Plicease::MakeMaker v2.63. use strict; use warnings; use 5.006; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Check that a library is available for FFI", "AUTHOR" => "Graham Ollis ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "FFI-CheckLib", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.006", "NAME" => "FFI::CheckLib", "PM" => { "lib/FFI/CheckLib.pm" => "\$(INST_LIB)/FFI/CheckLib.pm" }, "PREREQ_PM" => { "List::Util" => "1.33" }, "TEST_REQUIRES" => { "Test2::API" => "1.302015", "Test2::Require::EnvVar" => "0.000060", "Test2::Require::Module" => "0.000060", "Test2::V0" => "0.000060" }, "VERSION" => "0.28", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "List::Util" => "1.33", "Test2::API" => "1.302015", "Test2::Require::EnvVar" => "0.000060", "Test2::Require::Module" => "0.000060", "Test2::V0" => "0.000060" ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs);perlcriticrc100644001750001750 364314050305114 16146 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28severity = 1 only = 1 [Freenode::ArrayAssignAref] [Freenode::BarewordFilehandles] [Freenode::ConditionalDeclarations] [Freenode::ConditionalImplicitReturn] [Freenode::DeprecatedFeatures] [Freenode::DiscouragedModules] [Freenode::DollarAB] [Freenode::Each] [Freenode::IndirectObjectNotation] [Freenode::LexicalForeachIterator] [Freenode::LoopOnHash] [Freenode::ModPerl] [Freenode::OpenArgs] [Freenode::OverloadOptions] [Freenode::POSIXImports] [Freenode::PackageMatchesFilename] [Freenode::PreferredAlternatives] [Freenode::StrictWarnings] extra_importers = Test2::V0 [Freenode::Threads] ;[Freenode::Wantarray] [Freenode::WarningsSwitch] [Freenode::WhileDiamondDefaultAssignment] [BuiltinFunctions::ProhibitBooleanGrep] ;[BuiltinFunctions::ProhibitStringyEval] [BuiltinFunctions::ProhibitStringySplit] [BuiltinFunctions::ProhibitVoidGrep] [BuiltinFunctions::ProhibitVoidMap] [ClassHierarchies::ProhibitExplicitISA] [ClassHierarchies::ProhibitOneArgBless] [CodeLayout::ProhibitHardTabs] allow_leading_tabs = 0 [CodeLayout::ProhibitTrailingWhitespace] [CodeLayout::RequireConsistentNewlines] [ControlStructures::ProhibitLabelsWithSpecialBlockNames] [ControlStructures::ProhibitMutatingListFunctions] [ControlStructures::ProhibitUnreachableCode] [InputOutput::ProhibitBarewordFileHandles] [InputOutput::ProhibitJoinedReadline] [InputOutput::ProhibitTwoArgOpen] [Miscellanea::ProhibitFormats] [Miscellanea::ProhibitUselessNoCritic] [Modules::ProhibitConditionalUseStatements] ;[Modules::RequireEndWithOne] [Modules::RequireNoMatchVarsWithUseEnglish] [Objects::ProhibitIndirectSyntax] [RegularExpressions::ProhibitUselessTopic] [Subroutines::ProhibitNestedSubs] [ValuesAndExpressions::ProhibitLeadingZeros] [ValuesAndExpressions::ProhibitMixedBooleanOperators] [ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator] [ValuesAndExpressions::RequireUpperCaseHeredocTerminator] [Variables::ProhibitPerl4PackageNames] [Variables::ProhibitUnusedVariables] author000755001750001750 014050305114 15325 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xteol.t100644001750001750 51014050305114 16405 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xt/authoruse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::EOL' unless eval q{ use Test::EOL; 1 }; }; use Test::EOL; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); all_perl_files_ok(grep { -e $_ } qw( bin lib t Makefile.PL )); pod.t100644001750001750 47214050305114 16417 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xt/authoruse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Pod' unless eval q{ use Test::Pod; 1 }; }; use Test::Pod; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); all_pod_files_ok( grep { -e $_ } qw( bin lib )); ffi_checklib.t100644001750001750 772514050305114 16563 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/tuse lib 't/lib'; use Test2::V0 -no_srand => 1; use Test2::Plugin::FauxOS 'linux'; use Test2::Tools::FauxDynaLoader; use FFI::CheckLib qw( find_lib which where has_symbols ); subtest 'recursive' => sub { $FFI::CheckLib::system_path = []; my @libs = find_lib( libpath => File::Spec->catdir( 'corpus', 'unix', 'foo-1.00' ), lib => 'foo', recursive => 1, ); is scalar(@libs), 1, "libs = @libs"; like $libs[0], qr{libfoo.so}, "libs[0] = $libs[0]"; }; subtest 'star' => sub { $FFI::CheckLib::system_path = []; my @libs = find_lib( libpath => File::Spec->catdir( 'corpus', 'unix', 'foo-1.00' ), lib => '*', recursive => 1, ); is scalar(@libs), 3, "libs = @libs"; my @fn = sort map { (File::Spec->splitpath($_))[2] } @libs; is \@fn, [qw( libbar.so libbaz.so libfoo.so )], "fn = @fn"; }; subtest 'which' => sub { my %find_lib_args; my $mock = mock 'FFI::CheckLib' => ( override => [ find_lib => sub { %find_lib_args = @_; my @ret = qw( /usr/lib/libfoo.so.1.2.3 /usr/lib/libbar.so.1.2.3 ); wantarray ? @ret : $ret[0]; }, ], ); is( which('foo'), '/usr/lib/libfoo.so.1.2.3' ); is( \%find_lib_args, hash { field 'lib' => 'foo'; end; } ); }; subtest 'which' => sub { my %find_lib_args; my $mock = mock 'FFI::CheckLib' => ( override => [ find_lib => sub { %find_lib_args = @_; my @ret = qw( /usr/lib/libfoo.so.1.2.3 /usr/lib/libbar.so.1.2.3 ); wantarray ? @ret : $ret[0]; }, ], ); subtest 'with name' => sub { is( [where('foo')], ['/usr/lib/libfoo.so.1.2.3','/usr/lib/libbar.so.1.2.3'] ); is( \%find_lib_args, hash { field 'lib' => '*'; field 'verify' => T(); end; } ); }; subtest 'with wildcard' => sub { is( [where('*')], ['/usr/lib/libfoo.so.1.2.3','/usr/lib/libbar.so.1.2.3'] ); is( \%find_lib_args, hash { field 'lib' => '*'; end; } ); }; }; subtest 'has_symbols' => sub { my $mock = mock_dynaloader; is( has_symbols('corpus/generic.dll'), T(), ); is( has_symbols('corpus/generic.dll', qw( foo bar baz)), T(), ); is( has_symbols('corpus/generic.dll', qw( foo bar )), T(), ); is( has_symbols('corpus/generic.dll', qw( foo )), T(), ); is( has_symbols('corpus/generic.dll', qw( foo bar baz bogus )), F(), ); is( has_symbols('corpus/generic.dll', qw( bogus )), F(), ); }; subtest 'system_path' => sub { @{ $FFI::CheckLib::system_path } = (qw( /foo /bar /baz )); is( FFI::CheckLib::system_path(), [ qw( /foo /bar /baz ) ], ); }; subtest 'alien' => sub { @{ $FFI::CheckLib::system_path } = (); subtest 'preloaded' => sub { my $alien = mock 'Alien::libfoo' => ( add => [ dynamic_libs => sub { 'corpus/unix/lib/libfoo.so.2.3.4', }, ], ); is( [FFI::CheckLib::find_lib( lib => 'foo', alien => ['Alien::libfoo'])], array { item 0 => match qr/foo/; end; }, ); }; subtest 'autoload' => sub { local @INC = @INC; unshift @INC, 'corpus/lib'; is( [FFI::CheckLib::find_lib( lib => 'bar', alien => ['Alien::libbar'])], array { item 0 => match qr/bar/; end; }, ); }; subtest 'invalid name' => sub { is dies { FFI::CheckLib::find_lib( lib => 'bar', alien => ['x..y']) }, match qr/Doesn't appear to be a valid Alien name x\.\.y/; }; subtest 'no dynamic_libs method' => sub { { package Alien::libbaz; $INC{'Alien/libbaz.pm'} = __PACKAGE__; } is dies { FFI::CheckLib::find_lib( lib => 'baz', alien => ['Alien::libbaz']) }, match qr/Alien Alien::libbaz doesn't provide a dynamic_libs method/; }; subtest 'not installed' => sub { try_ok { FFI::CheckLib::find_lib( lib => 'baz', alien => ['Alien::libnotinstalled']); }; }; }; done_testing; corpus000755001750001750 014050305114 14703 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28generic.dll100644001750001750 3214050305114 17107 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpusgeneric 1.2.3 foo bar baz critic.t100644001750001750 51514050305114 17110 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xt/authoruse Test2::Require::Module 'Test2::Tools::PerlCritic'; use Test2::Require::Module 'Perl::Critic'; use Test2::Require::Module 'Perl::Critic::Freenode'; use Test2::V0; use Perl::Critic; use Test2::Tools::PerlCritic; my $critic = Perl::Critic->new( -profile => 'perlcriticrc', ); perl_critic_ok ['lib','t'], $critic; done_testing; strict.t100644001750001750 103114050305114 17155 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xt/authoruse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Strict' unless eval q{ use Test::Strict; 1 }; }; use Test::Strict; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); unshift @Test::Strict::MODULES_ENABLING_STRICT, 'ozo', 'Test2::Bundle::SIPS', 'Test2::V0', 'Test2::Bundle::Extended'; note "enabling strict = $_" for @Test::Strict::MODULES_ENABLING_STRICT; all_perl_files_ok( grep { -e $_ } qw( bin lib t Makefile.PL )); release000755001750001750 014050305114 15443 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xtfixme.t100644001750001750 61614050305114 17063 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xt/releaseuse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Fixme' unless eval q{ use Test::Fixme 0.14; 1 }; }; use Test::Fixme 0.07; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); run_tests( match => qr/FIXME/, where => [ grep { -e $_ } qw( bin lib t Makefile.PL Build.PL )], warn => 1, ); example000755001750001750 014050305114 15023 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28whichdll.pl100644001750001750 41214050305114 17273 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/exampleuse strict; use warnings; use FFI::CheckLib; my($name) = shift @ARGV; unless(defined $name) { print STDERR "usage: $0 name\n"; } my($path) = find_lib( lib => $name ); if($path) { print "$path\n"; exit 0; } else { print STDERR "not found.\n"; exit 2; } wheredll.pl100644001750001750 46114050305114 17307 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/exampleuse strict; use warnings; use FFI::CheckLib; my($name) = shift @ARGV; unless(defined $name) { print STDERR "usage: $0 name\n"; } my(@path) = find_lib( lib => '*', verify => sub { $_[0] eq $name } ); if(@path) { print "$_\n" for @path; exit 0; } else { print STDERR "not found.\n"; exit 2; } FFI000755001750001750 014050305114 14542 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/libCheckLib.pm100644001750001750 4130114050305114 16723 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/lib/FFIpackage FFI::CheckLib; use strict; use warnings; use File::Spec; use List::Util 1.33 qw( any ); use Carp qw( croak carp ); use base qw( Exporter ); our @EXPORT = qw( find_lib assert_lib check_lib check_lib_or_exit find_lib_or_exit find_lib_or_die ); our @EXPORT_OK = qw( which where has_symbols ); # ABSTRACT: Check that a library is available for FFI our $VERSION = '0.28'; # VERSION our $system_path = []; our $os ||= $^O; my $try_ld_on_text = 0; if($os eq 'MSWin32' || $os eq 'msys') { $system_path = eval { require Env; Env->import('@PATH'); \our @PATH; }; die $@ if $@; } else { $system_path = eval { require DynaLoader; no warnings 'once'; \@DynaLoader::dl_library_path; }; die $@ if $@; } our $pattern = [ qr{^lib(.*?)\.so(?:\.([0-9]+(?:\.[0-9]+)*))?$} ]; our $version_split = qr/\./; if($os eq 'cygwin') { push @$pattern, qr{^cyg(.*?)(?:-([0-9])+)?\.dll$}; } elsif($os eq 'msys') { # doesn't seem as though msys uses psudo libfoo.so files # in the way that cygwin sometimes does. we can revisit # this if we find otherwise. $pattern = [ qr{^msys-(.*?)(?:-([0-9])+)?\.dll$} ]; } elsif($os eq 'MSWin32') { # handle cases like libgeos-3-7-0___.dll and libgtk-2.0-0.dll $pattern = [ qr{^(?:lib)?(\w+?)(?:-([0-9-\.]+))?_*\.dll$}i ]; $version_split = qr/\-/; } elsif($os eq 'darwin') { push @$pattern, qr{^lib(.*?)(?:\.([0-9]+(?:\.[0-9]+)*))?\.(?:dylib|bundle)$}; } elsif($os eq 'linux') { if(-e '/etc/redhat-release' && -x '/usr/bin/ld') { $try_ld_on_text = 1; } } sub _matches { my($filename, $path) = @_; foreach my $regex (@$pattern) { return [ $1, # 0 capture group 1 library name File::Spec->catfile($path, $filename), # 1 full path to library defined $2 ? (split $version_split, $2) : (), # 2... capture group 2 library version ] if $filename =~ $regex; } return (); } sub _cmp { my($A,$B) = @_; return $A->[0] cmp $B->[0] if $A->[0] ne $B->[0]; my $i=2; while(1) { return 0 if !defined($A->[$i]) && !defined($B->[$i]); return -1 if !defined $A->[$i]; return 1 if !defined $B->[$i]; return $B->[$i] <=> $A->[$i] if $A->[$i] != $B->[$i]; $i++; } } my $diagnostic; sub _is_binary { -B $_[0] } sub find_lib { my(%args) = @_; undef $diagnostic; croak "find_lib requires lib argument" unless defined $args{lib}; my $recursive = $args{_r} || $args{recursive} || 0; # make arguments be lists. foreach my $arg (qw( lib libpath symbol verify alien )) { next if ref $args{$arg} eq 'ARRAY'; if(defined $args{$arg}) { $args{$arg} = [ $args{$arg} ]; } else { $args{$arg} = []; } } if(defined $args{systempath} && !ref($args{systempath})) { $args{systempath} = [ $args{systempath} ]; } my @path = @{ $args{libpath} }; @path = map { _recurse($_) } @path if $recursive; push @path, grep { defined } defined $args{systempath} ? @{ $args{systempath} } : @$system_path; my $any = any { $_ eq '*' } @{ $args{lib} }; my %missing = map { $_ => 1 } @{ $args{lib} }; my %symbols = map { $_ => 1 } @{ $args{symbol} }; my @found; delete $missing{'*'}; alien: foreach my $alien (@{ $args{alien} }) { unless($alien =~ /^([A-Za-z_][A-Za-z_0-9]*)(::[A-Za-z_][A-Za-z_0-9]*)*$/) { croak "Doesn't appear to be a valid Alien name $alien"; } unless(eval { $alien->can('dynamic_libs') }) { { my $pm = "$alien.pm"; $pm =~ s/::/\//g; local $@ = ''; eval { require $pm }; next alien if $@; } unless(eval { $alien->can('dynamic_libs') }) { croak "Alien $alien doesn't provide a dynamic_libs method"; } } push @path, [$alien->dynamic_libs]; } foreach my $path (@path) { next if ref $path ne 'ARRAY' && ! -d $path; my @maybe = # make determinist based on names and versions sort { _cmp($a,$b) } # Filter out the items that do not match the name that we are looking for # Filter out any broken symbolic links grep { ($any || $missing{$_->[0]} ) && (-e $_->[1]) } ref $path eq 'ARRAY' ? do { map { my($v, $d, $f) = File::Spec->splitpath($_); _matches($f, File::Spec->catpath($v,$d,'')); } @$path; } : do { my $dh; opendir $dh, $path; # get [ name, full_path ] mapping, # each entry is a 2 element list ref map { _matches($_,$path) } readdir $dh; }; if($try_ld_on_text && $args{try_linker_script}) { # This is tested in t/ci.t only @maybe = map { -B $_->[1] ? $_ : do { my($name, $so) = @$_; my $output = `/usr/bin/ld -t $so -o /dev/null -shared`; $output =~ /\((.*?lib.*\.so.*?)\)/ ? [$name, $1] : die "unable to parse ld output"; } } @maybe; } midloop: foreach my $lib (@maybe) { next unless $any || $missing{$lib->[0]}; foreach my $verify (@{ $args{verify} }) { next midloop unless $verify->(@$lib); } delete $missing{$lib->[0]}; if(%symbols) { require DynaLoader; my $dll = DynaLoader::dl_load_file($lib->[1],0); foreach my $symbol (keys %symbols) { if(DynaLoader::dl_find_symbol($dll, $symbol) ? 1 : 0) { delete $symbols{$symbol} } } DynaLoader::dl_unload_file($dll); } my $found = $lib->[1]; unless($any) { while(-l $found) { require File::Basename; my $dir = File::Basename::dirname($found); $found = File::Spec->rel2abs( readlink($found), $dir ); } } push @found, $found; } } if(%missing) { my @missing = sort keys %missing; if(@missing > 1) { $diagnostic = "libraries not found: @missing" } else { $diagnostic = "library not found: @missing" } } elsif(%symbols) { my @missing = sort keys %symbols; if(@missing > 1) { $diagnostic = "symbols not found: @missing" } else { $diagnostic = "symbol not found: @missing" } } return if %symbols; return $found[0] unless wantarray; return @found; } sub _recurse { my($dir) = @_; return unless -d $dir; my $dh; opendir $dh, $dir; my @list = grep { -d $_ } map { File::Spec->catdir($dir, $_) } grep !/^\.\.?$/, readdir $dh; closedir $dh; ($dir, map { _recurse($_) } @list); } sub assert_lib { croak $diagnostic || 'library not found' unless check_lib(@_); } sub check_lib_or_exit { unless(check_lib(@_)) { carp $diagnostic || 'library not found'; exit; } } sub find_lib_or_exit { my(@libs) = find_lib(@_); unless(@libs) { carp $diagnostic || 'library not found'; exit; } return unless @libs; wantarray ? @libs : $libs[0]; } sub find_lib_or_die { my(@libs) = find_lib(@_); unless(@libs) { croak $diagnostic || 'library not found'; } return unless @libs; wantarray ? @libs : $libs[0]; } sub check_lib { find_lib(@_) ? 1 : 0; } sub which { my($name) = @_; croak("cannot which *") if $name eq '*'; scalar find_lib( lib => $name ); } sub where { my($name) = @_; $name eq '*' ? find_lib(lib => '*') : find_lib(lib => '*', verify => sub { $_[0] eq $name }); } sub has_symbols { my($path, @symbols) = @_; require DynaLoader; my $dll = DynaLoader::dl_load_file($path, 0); my $ok = 1; foreach my $symbol (@symbols) { unless(DynaLoader::dl_find_symbol($dll, $symbol)) { $ok = 0; last; } } DynaLoader::dl_unload_file($dll); $ok; } sub system_path { $system_path; } 1; __END__ =pod =encoding UTF-8 =head1 NAME FFI::CheckLib - Check that a library is available for FFI =head1 VERSION version 0.28 =head1 SYNOPSIS use FFI::CheckLib; check_lib_or_exit( lib => 'jpeg', symbol => 'jinit_memory_mgr' ); check_lib_or_exit( lib => [ 'iconv', 'jpeg' ] ); # or prompt for path to library and then: print "where to find jpeg library: "; my $path = ; check_lib_or_exit( lib => 'jpeg', libpath => $path ); =head1 DESCRIPTION This module checks whether a particular dynamic library is available for FFI to use. It is modeled heavily on L, but will find dynamic libraries even when development packages are not installed. It also provides a L function that will return the full path to the found dynamic library, which can be feed directly into L or another FFI system. Although intended mainly for FFI modules via L and similar, this module does not actually use any FFI to do its detection and probing. This module does not have any non-core runtime dependencies. The test suite does depend on L. =head1 FUNCTIONS All of these take the same named parameters and are exported by default. =head2 find_lib my(@libs) = find_lib(%args); This will return a list of dynamic libraries, or empty list if none were found. [version 0.05] If called in scalar context it will return the first library found. Arguments are key value pairs with these keys: =over 4 =item lib Must be either a string with the name of a single library or a reference to an array of strings of library names. Depending on your platform, C will prepend C or append C<.dll> or C<.so> when searching. [version 0.11] As a special case, if C<*> is specified then any libs found will match. =item libpath A string or array of additional paths to search for libraries. =item systempath [version 0.11] A string or array of system paths to search for instead of letting L determine the system path. You can set this to C<[]> in order to not search I system paths. =item symbol A string or a list of symbol names that must be found. =item verify A code reference used to verify a library really is the one that you want. It should take two arguments, which is the name of the library and the full path to the library pathname. It should return true if it is acceptable, and false otherwise. You can use this in conjunction with L to determine if it is going to meet your needs. Example: use FFI::CheckLib; use FFI::Platypus; my($lib) = find_lib( lib => 'foo', verify => sub { my($name, $libpath) = @_; my $ffi = FFI::Platypus->new; $ffi->lib($libpath); my $f = $ffi->function('foo_version', [] => 'int'); return $f->call() >= 500; # we accept version 500 or better }, ); =item recursive [version 0.11] Recursively search for libraries in any non-system paths (those provided via C above). =item try_linker_script [version 0.24] Some vendors provide C<.so> files that are linker scripts that point to the real binary shared library. These linker scripts can be used by gcc or clang, but are not directly usable by L and friends. On select platforms, this options will use the linker command (C) to attempt to resolve the real C<.so> for non-binary files. Since there is extra overhead this is off by default. An example is libyaml on Red Hat based Linux distributions. On Debian these are handled with symlinks and no trickery is required. =item alien [version 0.25] If no libraries can be found, try the given aliens instead. The Alien classes specified must provide the L interface for dynamic libraries, which is to say they should provide a method called C that returns a list of dynamic libraries. [version 0.28] In 0.28 and later, if the L is not installed then it will be ignored and this module will search in system or specified directories only. This module I still throw an exception, if the L doesn't look like a module name or if it does not provide a C method (which is implemented by all L subclasses). =back =head2 assert_lib assert_lib(%args); This behaves exactly the same as L, except that instead of returning empty list of failure it throws an exception. =head2 check_lib_or_exit check_lib_or_exit(%args); This behaves exactly the same as L, except that instead of dying, it warns (with exactly the same error message) and exists. This is intended for use in C or C =head2 find_lib_or_exit [version 0.05] my(@libs) = find_lib_or_exit(%args); This behaves exactly the same as L, except that if the library is not found, it will call exit with an appropriate diagnostic. =head2 find_lib_or_die [version 0.06] my(@libs) = find_lib_or_die(%args); This behaves exactly the same as L, except that if the library is not found, it will die with an appropriate diagnostic. =head2 check_lib my $bool = check_lib(%args); This behaves exactly the same as L, except that it returns true (1) on finding the appropriate libraries or false (0) otherwise. =head2 which [version 0.17] my $path = where($name); Return the path to the first library that matches the given name. Not exported by default. =head2 where [version 0.17] my @paths = where($name); Return the paths to all the libraries that match the given name. Not exported by default. =head2 has_symbols [version 0.17] my $bool = has_symbols($path, @symbol_names); Returns true if I of the symbols can be found in the dynamic library located at the given path. Can be useful in conjunction with C with C above. Not exported by default. =head2 system_path [version 0.20] my $path = FFI::CheckLib::system_path; Returns the system path as a list reference. On some systems, this is C on others it might be C on still others it could be something completely different. So although you I add items to this list, you should probably do some careful consideration before you do so. This function is not exportable, even on request. =head1 FAQ =over 4 =item Why not just use C? Calling C on a library name and then C immediately can tell you if you have the exact name of a library available on a system. It does have a number of drawbacks as well. =over 4 =item No absolute or relative path It only tells you that the library is I on the system, not having the absolute or relative path makes it harder to generate useful diagnostics. =item POSIX only This doesn't work on non-POSIX systems like Microsoft Windows. If you are using a POSIX emulation layer on Windows that provides C, like Cygwin, there are a number of gotchas there as well. Having a layer written in Perl handles this means that developers on Unix can develop FFI that will more likely work on these platforms without special casing them. =item inconsistent implementations Even on POSIX systems you have inconsistent implementations. OpenBSD for example don't usually include symlinks for C<.so> files meaning you need to know the exact C<.so> version. =item non-system directories By default C only works for libraries in the system paths. Most platforms have a way of configuring the search for different non-system paths, but none of them are portable, and are usually discouraged anyway. L and friends need to do searches for dynamic libraries in non-system directories for C installs. =back =item My 64-bit Perl is misconfigured and has 32-bit libraries in its search path. Is that a bug in L? Nope. =item The way L is implemented it won't work on AIX, HP-UX, OpenVMS or Plan 9. I know for a fact that it doesn't work on AIX I because I used to develop on AIX in the early 2000s, and I am aware of some of the technical challenges. There are probably other systems that it won't work on. I would love to add support for these platforms. Realistically these platforms have a tiny market share, and absent patches from users or the companies that own these operating systems (patches welcome), or hardware / CPU time donations, these platforms are unsupportable anyway. =back =head1 SEE ALSO =over 4 =item L Call library functions dynamically without a compiler. =item L L plugin for this module. =back =head1 AUTHOR Author: Graham Ollis Eplicease@cpan.orgE Contributors: Bakkiaraj Murugesan (bakkiaraj) Dan Book (grinnz, DBOOK) Ilya Pavlov (Ilya, ILUX) Shawn Laffan (SLAFFAN) Petr Pisar (ppisar) =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014-2018 by Graham Ollis. 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 no_tabs.t100644001750001750 52214050305114 17256 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xt/authoruse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::NoTabs' unless eval q{ use Test::NoTabs; 1 }; }; use Test::NoTabs; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); all_perl_files_ok( grep { -e $_ } qw( bin lib t Makefile.PL )); version.t100644001750001750 147314050305114 17344 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xt/authoruse strict; use warnings; use Test::More; use FindBin (); BEGIN { plan skip_all => "test requires Test::Version 2.00" unless eval q{ use Test::Version 2.00 qw( version_all_ok ), { has_version => 1, filename_match => sub { $_[0] !~ m{/(ConfigData|Install/Files)\.pm$} }, }; 1 }; plan skip_all => 'test requires YAML' unless eval q{ use YAML; 1; }; } use YAML qw( LoadFile ); use FindBin; use File::Spec; my $config_filename = File::Spec->catfile( $FindBin::Bin, File::Spec->updir, File::Spec->updir, 'author.yml' ); my $config; $config = LoadFile($config_filename) if -r $config_filename; if($config->{version}->{dir}) { note "using dir " . $config->{version}->{dir} } version_all_ok($config->{version}->{dir} ? ($config->{version}->{dir}) : ()); done_testing; changes.t100644001750001750 111314050305114 17374 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xt/releaseuse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::CPAN::Changes' unless eval q{ use Test::CPAN::Changes; 1 }; }; use Test::CPAN::Changes; use FindBin; use File::Spec; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); do { my $old = \&Test::Builder::carp; my $new = sub { my($self, @messages) = @_; return if $messages[0] =~ /^Date ".*" is not in the recommend format/; $old->($self, @messages); }; no warnings 'redefine'; *Test::Builder::carp = $new; }; changes_file_ok; done_testing; ffi_checklib__exit.t100644001750001750 157514050305114 17750 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/tuse lib 't/lib'; use Test2::Require::Module 'Test2::Tools::Process'; use Test2::V0 -no_srand => 1; use Test2::Plugin::FauxOS 'linux'; use Test2::Tools::NoteStderr qw( note_stderr ); use Test2::Tools::Process; use FFI::CheckLib; @$FFI::CheckLib::system_path = ( 'corpus/unix/usr/lib', 'corpus/unix/lib', ); subtest 'check_lib_or_exit' => sub { subtest 'found' => sub { process { check_lib_or_exit( lib => 'foo' ) } []; }; subtest 'not found' => sub { process { note_stderr { check_lib_or_exit( lib => 'foobar') } } [ proc_event( exit => 0 ), ]; }; }; subtest 'find_lib_or_exit' => sub { subtest 'found' => sub { process { my $path = find_lib_or_exit( lib => 'foo' ) } []; }; subtest 'not found' => sub { process { note_stderr { my $path = find_lib_or_exit( lib => 'foobar') } } [ proc_event( exit => 0 ), ]; }; }; done_testing; maint000755001750001750 014050305114 14500 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28cip-before-install100755001750001750 112414050305114 20243 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/maint#!/bin/bash set -ex if echo $CIP_TAG | grep -q -- -alpine ; then echo alpine cip sudo apk add cmake cip sudo apk add libffi-dev cip sudo apk add yaml-dev elif echo $CIP_TAG | grep -q -- -centos ; then echo CentOS cip sudo yum install libffi-devel libyaml-devel -y elif echo $CIP_TAG | grep -q -- -fedora ; then echo Fedora cip sudo yum install cmake libffi-devel libyaml-devel -y else cip sudo apt-get update cip sudo apt-get -y install libffi-dev libyaml-dev fi cip exec cpanm -n FFI::Platypus if [ $CIP_TAG != "5.8" ]; then cip exec cpanm -n Test2::Tools::Process fi pod_coverage.t100644001750001750 400114050305114 20302 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xt/authoruse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires 5.010 or better' unless $] >= 5.010; plan skip_all => 'test requires Test::Pod::Coverage' unless eval q{ use Test::Pod::Coverage; 1 }; plan skip_all => 'test requires YAML' unless eval q{ use YAML; 1; }; plan skip_all => 'test does not always work in cip check' if defined $ENV{CIPSTATIC} && $ENV{CIPSTATIC} eq 'true'; }; use Test::Pod::Coverage; use YAML qw( LoadFile ); use FindBin; use File::Spec; my $config_filename = File::Spec->catfile( $FindBin::Bin, File::Spec->updir, File::Spec->updir, 'author.yml' ); my $config; $config = LoadFile($config_filename) if -r $config_filename; plan skip_all => 'disabled' if $config->{pod_coverage}->{skip}; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); my @private_classes; my %private_methods; push $config->{pod_coverage}->{private}->@*, 'Alien::.*::Install::Files#Inline'; foreach my $private ($config->{pod_coverage}->{private}->@*) { my($class,$method) = split /#/, $private; if(defined $class && $class ne '') { my $regex = eval 'qr{^' . $class . '$}'; if(defined $method && $method ne '') { push @private_classes, { regex => $regex, method => $method }; } else { push @private_classes, { regex => $regex, all => 1 }; } } elsif(defined $method && $method ne '') { $private_methods{$_} = 1 for split /,/, $method; } } my @classes = all_modules; plan tests => scalar @classes; foreach my $class (@classes) { SKIP: { my($is_private_class) = map { 1 } grep { $class =~ $_->{regex} && $_->{all} } @private_classes; skip "private class: $class", 1 if $is_private_class; my %methods = map {; $_ => 1 } map { split /,/, $_->{method} } grep { $class =~ $_->{regex} } @private_classes; $methods{$_} = 1 for keys %private_methods; my $also_private = eval 'qr{^' . join('|', keys %methods ) . '$}'; pod_coverage_ok $class, { also_private => [$also_private] }; }; } ffi_checklib__os_msys.t100644001750001750 254514050305114 20471 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/tuse lib 't/lib'; use Test2::V0 -no_srand => 1; use Test2::Plugin::FauxOS 'msys'; use FFI::CheckLib; sub p { my($path) = @_; $path =~ s{/}{\\}g if $^O eq 'MSWin32'; $path; } subtest '_cmp' => sub { my $process = sub { [ sort { FFI::CheckLib::_cmp($a,$b) } map { FFI::CheckLib::_matches($_, '/bin') } @_ ]; }; is( $process->(qw( msys-foo-1.dll msys-bar-2.dll msys-baz-0.dll )), [ [ 'bar', p('/bin/msys-bar-2.dll'), 2 ], [ 'baz', p('/bin/msys-baz-0.dll'), 0 ], [ 'foo', p('/bin/msys-foo-1.dll'), 1 ], ], 'name first 1', ); is( $process->(qw( msys-baz-0.dll msys-foo-1.dll msys-bar-2.dll )), [ [ 'bar', p('/bin/msys-bar-2.dll'), 2 ], [ 'baz', p('/bin/msys-baz-0.dll'), 0 ], [ 'foo', p('/bin/msys-foo-1.dll'), 1 ], ], 'name first 1', ); is( $process->(qw( msys-bar-2.dll msys-foo-1.dll msys-baz-0.dll )), [ [ 'bar', p('/bin/msys-bar-2.dll'), 2 ], [ 'baz', p('/bin/msys-baz-0.dll'), 0 ], [ 'foo', p('/bin/msys-foo-1.dll'), 1 ], ], 'name first 1', ); is( $process->(qw( msys-foo-2.dll msys-foo-0.dll msys-foo-1.dll )), [ [ 'foo', p('/bin/msys-foo-2.dll'), 2, ], [ 'foo', p('/bin/msys-foo-1.dll'), 1, ], [ 'foo', p('/bin/msys-foo-0.dll'), 0, ], ], 'newer version first', ); }; done_testing; ffi_checklib__os_unix.t100644001750001750 1446414050305114 20504 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/tuse lib 't/lib'; use Test2::V0 -no_srand => 1; use Test2::Plugin::FauxOS 'linux'; use Test2::Tools::FauxDynaLoader; use Test2::Tools::NoteStderr qw( note_stderr ); use FFI::CheckLib; use File::Basename qw( basename ); @$FFI::CheckLib::system_path = ( 'corpus/unix/usr/lib', 'corpus/unix/lib', ); my $mock1 = mock_dynaloader; subtest 'find_lib (good)' => sub { my($path) = find_lib( lib => 'foo' ); ok -r $path, "path = $path is readable"; my $path2 = find_lib( lib => 'foo' ); is $path, $path2, 'scalar context'; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest 'find_lib (fail)' => sub { my @path = find_lib( lib => 'foobar' ); ok @path == 0, 'libfoobar not found'; }; subtest 'find_lib list' => sub { my @path = find_lib( lib => [ 'foo', 'bar' ] ); ok -r $path[0], "path[0] = $path[0] is readable"; ok -r $path[1], "path[1] = $path[1] is readable"; subtest foo => sub { my($foo) = grep { $_->name eq 'foo' } map { TestDLL->new($_) } @path; is $foo->name, 'foo', 'dll.name = foo'; is $foo->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest bar => sub { my($bar) = grep { $_->name eq 'bar' } map { TestDLL->new($_) } @path; is $bar->name, 'bar', 'dll.name = bar'; is $bar->version, '1.2.3', 'dll.version = 1.2.3'; }; }; subtest 'find_lib libpath' => sub { my($path) = find_lib( lib => 'foo', libpath => 'corpus/unix/custom' ); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3a', 'dll.version = 1.2.3a'; }; subtest 'find_lib libpath (list)' => sub { my($path) = find_lib( lib => 'foo', libpath => ['corpus/unix/custom']); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3a', 'dll.version = 1.2.3a'; }; subtest 'find_lib symbol' => sub { my($path) = find_lib( lib => 'foo', symbol => 'foo_init' ); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest 'find_lib symbol (bad)' => sub { my @path = find_lib( lib => 'foo', symbol => 'foo_initx' ); ok @path == 0, 'no path found'; }; subtest 'find_lib symbol (list)' => sub { my($path) = find_lib( lib => 'foo', symbol => ['foo_init', 'foo_new', 'foo_delete'] ); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest 'find_lib symbol (list) (bad)' => sub { my @path = find_lib( lib => 'foo', symbol => ['foo_init', 'foo_new', 'foo_delete', 'bogus'] ); ok @path == 0, 'no path found'; }; subtest 'assert_lib' => sub { subtest 'found' => sub { eval { assert_lib( lib => 'foo' ) }; is $@, '', 'no exception'; }; subtest 'not found' => sub { eval { assert_lib( lib => 'foobar') }; isnt $@, '', 'exception'; }; }; subtest 'check_lib' => sub { is check_lib( lib => 'foo' ), 1, 'found'; is check_lib( lib => 'foobar'), 0, 'not found'; }; subtest 'verify bad' => sub { my @lib = find_lib( lib => 'foo', verify => sub { 0 }, ); ok @lib == 0, 'returned empty list'; @lib = find_lib( lib => 'foo', verify => [ sub { 0 } ], ); ok @lib == 0, 'returned empty list'; }; subtest 'verify' => sub { my($lib) = find_lib( lib => 'foo', verify => sub { my($name, $path) = @_; my $lib = TestDLL->new($path); $lib->version ne '1.2.3' }, ); ok -r $lib, "path = $lib is readable"; my $dll = TestDLL->new($lib); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '2.3.4', 'dll.version = 2.3.4'; }; subtest 'symlink' => sub { # TODO: this test only gets run out of git, since Dist::Zilla # converts the symlinks into real files :/ skip_all 'Test requires a system with proper symlinks' unless -l 'corpus/unix/usr/lib/libxor.so' && readlink('corpus/unix/usr/lib/libxor.so'); subtest 'multiple versions of the same lib' => sub { my($lib) = find_lib( lib => 'xor', ); is(basename($lib), 'libxor.so.1.2.4'); }; subtest 'broken symlink' => sub { my($lib) = find_lib( lib => 'ganon', ); is($lib, undef); }; subtest 'infinite recurse symlink' => sub { my($lib) = find_lib( lib => 'link', ); is($lib, undef); }; }; subtest 'prefer newer' => sub { my($lib) = find_lib( lib => 'crypto', ); is($lib, T()); is(basename($lib), 'libcrypto.so.1.0.0'); note "lib = $lib"; }; sub p { my($path) = @_; $path =~ s{/}{\\}g if $^O eq 'MSWin32'; $path; } subtest '_cmp' => sub { my $process = sub { [ sort { FFI::CheckLib::_cmp($a,$b) } map { FFI::CheckLib::_matches($_, '/lib') } @_ ]; }; is( $process->(qw( libfoo.so.1.2.3 libbar.so.3.4.5 libbaz.so.0.0.0 )), [ [ 'bar', p('/lib/libbar.so.3.4.5'), 3,4,5 ], [ 'baz', p('/lib/libbaz.so.0.0.0'), 0,0,0 ], [ 'foo', p('/lib/libfoo.so.1.2.3'), 1,2,3 ], ], 'name first 1', ); is( $process->(qw( libbaz.so.0.0.0 libfoo.so.1.2.3 libbar.so.3.4.5 )), [ [ 'bar', p('/lib/libbar.so.3.4.5'), 3,4,5 ], [ 'baz', p('/lib/libbaz.so.0.0.0'), 0,0,0 ], [ 'foo', p('/lib/libfoo.so.1.2.3'), 1,2,3 ], ], 'name first 2', ); is( $process->(qw( libbar.so.3.4.5 libbaz.so.0.0.0 libfoo.so.1.2.3 )), [ [ 'bar', p('/lib/libbar.so.3.4.5'), 3,4,5 ], [ 'baz', p('/lib/libbaz.so.0.0.0'), 0,0,0 ], [ 'foo', p('/lib/libfoo.so.1.2.3'), 1,2,3 ], ], 'name first 3', ); is( $process->(qw( libfoo.so.1.2.3 libfoo.so libfoo.so.1.2 libfoo.so.1 )), [ [ 'foo', p('/lib/libfoo.so'), ], [ 'foo', p('/lib/libfoo.so.1'), 1 ], [ 'foo', p('/lib/libfoo.so.1.2'), 1,2 ], [ 'foo', p('/lib/libfoo.so.1.2.3'), 1,2,3 ], ], 'no version before version', ); is( $process->(qw( libfoo.so.2.3.4 libfoo.so.1.2.3 libfoo.so.3.4.5 )), [ [ 'foo', p('/lib/libfoo.so.3.4.5'), 3,4,5 ], [ 'foo', p('/lib/libfoo.so.2.3.4'), 2,3,4 ], [ 'foo', p('/lib/libfoo.so.1.2.3'), 1,2,3 ], ], 'newer version first', ); }; done_testing; lib000755001750001750 014050305114 16434 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unixlibfoo.so100644001750001750 1214050305114 20342 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/libfoo 2.3.4 Alien000755001750001750 014050305114 16501 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/liblibbar.pm100644001750001750 16514050305114 20414 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/lib/Alienpackage Alien::libbar; use strict; use warnings; sub dynamic_libs { 'corpus/unix/usr/lib/libbar.so.1.2.3'; } 1; ffi_checklib__os_cygwin.t100644001750001750 1266514050305114 21022 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/tuse lib 't/lib'; use Test2::V0 -no_srand => 1; use Test2::Plugin::FauxOS 'cygwin'; use Test2::Tools::FauxDynaLoader; use Test2::Tools::NoteStderr qw( note_stderr ); use FFI::CheckLib; @$FFI::CheckLib::system_path = ( 'corpus/cygwin/bin', 'corpus/unix/usr/lib', 'corpus/unix/lib', ); my $mock = mock_dynaloader; subtest 'find_lib (good)' => sub { my($path) = find_lib( lib => 'dinosaur' ); ok -r $path, "path = $path is readable"; my $path2 = find_lib( lib => 'dinosaur' ); is $path, $path2, 'scalar context'; }; subtest 'find_lib (good) with lib and version' => sub { my($path) = find_lib( lib => 'apatosaurus' ); ok -r $path, "path = $path is readable"; my $path2 = find_lib( lib => 'apatosaurus' ); is $path, $path2, 'scalar context'; }; subtest 'find_lib (good)' => sub { my($path) = find_lib( lib => 'foo' ); ok -r $path, "path = $path is readable"; my $path2 = find_lib( lib => 'foo' ); is $path, $path2, 'scalar context'; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest 'find_lib (fail)' => sub { my @path = find_lib( lib => 'foobar' ); ok @path == 0, 'libfoobar not found'; }; subtest 'find_lib list' => sub { my @path = find_lib( lib => [ 'foo', 'bar' ] ); ok -r $path[0], "path[0] = $path[0] is readable"; ok -r $path[1], "path[1] = $path[1] is readable"; subtest foo => sub { my($foo) = grep { $_->name eq 'foo' } map { TestDLL->new($_) } @path; is $foo->name, 'foo', 'dll.name = foo'; is $foo->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest bar => sub { my($bar) = grep { $_->name eq 'bar' } map { TestDLL->new($_) } @path; is $bar->name, 'bar', 'dll.name = bar'; is $bar->version, '1.2.3', 'dll.version = 1.2.3'; }; }; subtest 'find_lib libpath' => sub { my($path) = find_lib( lib => 'foo', libpath => 'corpus/unix/custom' ); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3a', 'dll.version = 1.2.3a'; }; subtest 'find_lib libpath (list)' => sub { my($path) = find_lib( lib => 'foo', libpath => ['corpus/unix/custom']); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3a', 'dll.version = 1.2.3a'; }; subtest 'find_lib symbol' => sub { my($path) = find_lib( lib => 'foo', symbol => 'foo_init' ); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest 'find_lib symbol (bad)' => sub { my @path = find_lib( lib => 'foo', symbol => 'foo_initx' ); ok @path == 0, 'no path found'; }; subtest 'find_lib symbol (list)' => sub { my($path) = find_lib( lib => 'foo', symbol => ['foo_init', 'foo_new', 'foo_delete'] ); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest 'find_lib symbol (list) (bad)' => sub { my @path = find_lib( lib => 'foo', symbol => ['foo_init', 'foo_new', 'foo_delete', 'bogus'] ); ok @path == 0, 'no path found'; }; subtest 'assert_lib' => sub { subtest 'found' => sub { eval { assert_lib( lib => 'foo' ) }; is $@, '', 'no exception'; }; subtest 'not found' => sub { eval { assert_lib( lib => 'foobar') }; isnt $@, '', 'exception'; }; }; subtest 'check_lib' => sub { is check_lib( lib => 'foo' ), 1, 'found'; is check_lib( lib => 'foobar'), 0, 'not found'; }; subtest 'verify bad' => sub { my @lib = find_lib( lib => 'foo', verify => sub { 0 }, ); ok @lib == 0, 'returned empty list'; @lib = find_lib( lib => 'foo', verify => [ sub { 0 } ], ); ok @lib == 0, 'returned empty list'; }; subtest 'verify' => sub { my($lib) = find_lib( lib => 'foo', verify => sub { my($name, $path) = @_; my $lib = TestDLL->new($path); $lib->version ne '1.2.3' }, ); ok -r $lib, "path = $lib is readable"; my $dll = TestDLL->new($lib); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '2.3.4', 'dll.version = 2.3.4'; }; sub p { my($path) = @_; $path =~ s{/}{\\}g if $^O eq 'MSWin32'; $path; } subtest '_cmp' => sub { my $process = sub { [ sort { FFI::CheckLib::_cmp($a,$b) } map { FFI::CheckLib::_matches($_, '/bin') } @_ ]; }; is( $process->(qw( cygfoo-1.dll cygbar-2.dll cygbaz-0.dll )), [ [ 'bar', p('/bin/cygbar-2.dll'), 2 ], [ 'baz', p('/bin/cygbaz-0.dll'), 0 ], [ 'foo', p('/bin/cygfoo-1.dll'), 1 ], ], 'name first 1', ); is( $process->(qw( cygbaz-0.dll cygfoo-1.dll cygbar-2.dll )), [ [ 'bar', p('/bin/cygbar-2.dll'), 2 ], [ 'baz', p('/bin/cygbaz-0.dll'), 0 ], [ 'foo', p('/bin/cygfoo-1.dll'), 1 ], ], 'name first 1', ); is( $process->(qw( cygbar-2.dll cygfoo-1.dll cygbaz-0.dll )), [ [ 'bar', p('/bin/cygbar-2.dll'), 2 ], [ 'baz', p('/bin/cygbaz-0.dll'), 0 ], [ 'foo', p('/bin/cygfoo-1.dll'), 1 ], ], 'name first 1', ); is( $process->(qw( cygfoo-2.dll cygfoo-0.dll cygfoo-1.dll )), [ [ 'foo', p('/bin/cygfoo-2.dll'), 2, ], [ 'foo', p('/bin/cygfoo-1.dll'), 1, ], [ 'foo', p('/bin/cygfoo-0.dll'), 0, ], ], 'newer version first', ); }; done_testing; ffi_checklib__os_darwin.t100644001750001750 1301314050305114 20772 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/tuse lib 't/lib'; use Test2::V0 -no_srand => 1; use Test2::Plugin::FauxOS 'darwin'; use Test2::Tools::FauxDynaLoader; use Test2::Tools::NoteStderr qw( note_stderr ); use FFI::CheckLib; @$FFI::CheckLib::system_path = ( 'corpus/darwin/usr/lib', 'corpus/darwin/lib', ); my $mock = mock_dynaloader; subtest 'find_lib (good)' => sub { my($path) = find_lib( lib => 'foo' ); ok -r $path, "path = $path is readable"; my $path2 = find_lib( lib => 'foo' ); is $path, $path2, 'scalar context'; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest 'find_lib (fail)' => sub { my @path = find_lib( lib => 'foobar' ); ok @path == 0, 'libfoobar not found'; }; subtest 'find_lib list' => sub { my @path = find_lib( lib => [ 'foo', 'bar' ] ); ok -r $path[0], "path[0] = $path[0] is readable"; ok -r $path[1], "path[1] = $path[1] is readable"; subtest foo => sub { my($foo) = grep { $_->name eq 'foo' } map { TestDLL->new($_) } @path; is $foo->name, 'foo', 'dll.name = foo'; is $foo->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest bar => sub { my($bar) = grep { $_->name eq 'bar' } map { TestDLL->new($_) } @path; is $bar->name, 'bar', 'dll.name = bar'; is $bar->version, '1.2.3', 'dll.version = 1.2.3'; }; }; subtest 'find_lib libpath' => sub { my($path) = find_lib( lib => 'foo', libpath => 'corpus/darwin/custom' ); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3a', 'dll.version = 1.2.3a'; }; subtest 'find_lib libpath (list)' => sub { my($path) = find_lib( lib => 'foo', libpath => ['corpus/darwin/custom']); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3a', 'dll.version = 1.2.3a'; }; subtest 'find_lib symbol' => sub { my($path) = find_lib( lib => 'foo', symbol => 'foo_init' ); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest 'find_lib symbol (bad)' => sub { my @path = find_lib( lib => 'foo', symbol => 'foo_initx' ); ok @path == 0, 'no path found'; }; subtest 'find_lib symbol (list)' => sub { my($path) = find_lib( lib => 'foo', symbol => ['foo_init', 'foo_new', 'foo_delete'] ); ok -r $path, "path = $path is readable"; my $dll = TestDLL->new($path); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '1.2.3', 'dll.version = 1.2.3'; }; subtest 'find_lib symbol (list) (bad)' => sub { my @path = find_lib( lib => 'foo', symbol => ['foo_init', 'foo_new', 'foo_delete', 'bogus'] ); ok @path == 0, 'no path found'; }; subtest 'assert_lib' => sub { subtest 'found' => sub { eval { assert_lib( lib => 'foo' ) }; is $@, '', 'no exception'; }; subtest 'not found' => sub { eval { assert_lib( lib => 'foobar') }; isnt $@, '', 'exception'; }; }; subtest 'check_lib' => sub { is check_lib( lib => 'foo' ), 1, 'found'; is check_lib( lib => 'foobar'), 0, 'not found'; }; subtest 'verify bad' => sub { my @lib = find_lib( lib => 'foo', verify => sub { 0 }, ); ok @lib == 0, 'returned empty list'; @lib = find_lib( lib => 'foo', verify => [ sub { 0 } ], ); ok @lib == 0, 'returned empty list'; }; subtest 'verify' => sub { my($lib) = find_lib( lib => 'foo', verify => sub { my($name, $path) = @_; my $lib = TestDLL->new($path); $lib->version ne '1.2.3' }, ); ok -r $lib, "path = $lib is readable"; my $dll = TestDLL->new($lib); is $dll->name, 'foo', 'dll.name = foo'; is $dll->version, '2.3.4', 'dll.version = 2.3.4'; }; sub p { my($path) = @_; $path =~ s{/}{\\}g if $^O eq 'MSWin32'; $path; } subtest '_cmp' => sub { my $process = sub { [ sort { FFI::CheckLib::_cmp($a,$b) } map { FFI::CheckLib::_matches($_, '/lib') } @_ ]; }; is( $process->(qw( libfoo.1.2.3.dylib libbar.3.4.5.dylib libbaz.0.0.0.dylib )), [ [ 'bar', p('/lib/libbar.3.4.5.dylib'), 3,4,5 ], [ 'baz', p('/lib/libbaz.0.0.0.dylib'), 0,0,0 ], [ 'foo', p('/lib/libfoo.1.2.3.dylib'), 1,2,3 ], ], 'name first 1', ); is( $process->(qw( libbaz.0.0.0.dylib libfoo.1.2.3.dylib libbar.3.4.5.dylib )), [ [ 'bar', p('/lib/libbar.3.4.5.dylib'), 3,4,5 ], [ 'baz', p('/lib/libbaz.0.0.0.dylib'), 0,0,0 ], [ 'foo', p('/lib/libfoo.1.2.3.dylib'), 1,2,3 ], ], 'name first 2', ); is( $process->(qw( libbar.3.4.5.dylib libbaz.0.0.0.dylib libfoo.1.2.3.dylib )), [ [ 'bar', p('/lib/libbar.3.4.5.dylib'), 3,4,5 ], [ 'baz', p('/lib/libbaz.0.0.0.dylib'), 0,0,0 ], [ 'foo', p('/lib/libfoo.1.2.3.dylib'), 1,2,3 ], ], 'name first 3', ); is( $process->(qw( libfoo.1.2.3.dylib libfoo.dylib libfoo.1.2.dylib libfoo.1.dylib )), [ [ 'foo', p('/lib/libfoo.dylib'), ], [ 'foo', p('/lib/libfoo.1.dylib'), 1 ], [ 'foo', p('/lib/libfoo.1.2.dylib'), 1,2 ], [ 'foo', p('/lib/libfoo.1.2.3.dylib'), 1,2,3 ], ], 'no version before version', ); is( $process->(qw( libfoo.2.3.4.dylib libfoo.1.2.3.dylib libfoo.3.4.5.dylib )), [ [ 'foo', p('/lib/libfoo.3.4.5.dylib'), 3,4,5 ], [ 'foo', p('/lib/libfoo.2.3.4.dylib'), 2,3,4 ], [ 'foo', p('/lib/libfoo.1.2.3.dylib'), 1,2,3 ], ], 'newer version first', ); }; done_testing; libfoo.so.2100644001750001750 1214050305114 20502 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/libfoo 2.3.4 ffi_checklib__os_mswin32.t100644001750001750 632014050305114 20773 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/tuse lib 't/lib'; use Test2::V0 -no_srand => 1; use Test2::Plugin::FauxOS 'MSWin32'; use FFI::CheckLib; use Env qw( @PATH ); @$FFI::CheckLib::system_path = ( 'corpus/windows/bin', ); subtest 'find_lib (good)' => sub { my($path) = find_lib( lib => 'dinosaur' ); ok -r $path, "path = $path is readable"; my $path2 = find_lib( lib => 'dinosaur' ); is $path, $path2, 'scalar context'; }; subtest 'find_lib (fail)' => sub { my @path = find_lib( lib => 'foobar' ); ok @path == 0, 'libfoobar not found'; }; subtest 'find_lib (good) with lib and version' => sub { my($path) = find_lib( lib => 'apatosaurus' ); ok -r $path, "path = $path is readable"; my $path2 = find_lib( lib => 'apatosaurus' ); is $path, $path2, 'scalar context'; }; subtest 'in sync with $ENV{PATH}' => sub { local $ENV{PATH} = $ENV{PATH}; @PATH = qw( foo bar baz ); is( $FFI::CheckLib::system_path, [qw( foo bar baz )], ); }; subtest 'lib with name like libname-1-2-3.dll' => sub { my($path) = find_lib( lib => 'maiasaura' ); ok -r $path, "path = $path is readable"; my $path2 = find_lib( lib => 'maiasaura' ); is $path, $path2, 'scalar context'; }; subtest 'lib with name like name-1-2-3.dll' => sub { my($path) = find_lib( lib => 'dromornis_planei' ); ok -r $path, "path = $path is readable"; my $path2 = find_lib( lib => 'dromornis_planei' ); is $path, $path2, 'scalar context'; }; subtest 'lib with name like libname-1-2___.dll' => sub { my($path) = find_lib( lib => 'thylacaleo_carnifex' ); ok -r $path, "path = $path is readable"; my $path2 = find_lib( lib => 'thylacaleo_carnifex' ); is $path, $path2, 'scalar context'; }; sub p { my($path) = @_; $path =~ s{/}{\\}g if $^O eq 'MSWin32'; $path; } subtest '_cmp' => sub { my $process = sub { [ sort { FFI::CheckLib::_cmp($a,$b) } map { FFI::CheckLib::_matches($_, 'C:/bin') } @_ ]; }; is( $process->(qw( foo-1.dll bar-2.dll baz-0.dll )), [ [ 'bar', p('C:/bin/bar-2.dll'), 2 ], [ 'baz', p('C:/bin/baz-0.dll'), 0 ], [ 'foo', p('C:/bin/foo-1.dll'), 1 ], ], 'name first 1', ); is( $process->(qw( baz-0.dll foo-1.dll bar-2.dll )), [ [ 'bar', p('C:/bin/bar-2.dll'), 2 ], [ 'baz', p('C:/bin/baz-0.dll'), 0 ], [ 'foo', p('C:/bin/foo-1.dll'), 1 ], ], 'name first 1', ); is( $process->(qw( bar-2.dll foo-1.dll baz-0.dll )), [ [ 'bar', p('C:/bin/bar-2.dll'), 2 ], [ 'baz', p('C:/bin/baz-0.dll'), 0 ], [ 'foo', p('C:/bin/foo-1.dll'), 1 ], ], 'name first 1', ); is( $process->(qw( foo-2.dll foo-0.dll foo-1.dll )), [ [ 'foo', p('C:/bin/foo-2.dll'), 2, ], [ 'foo', p('C:/bin/foo-1.dll'), 1, ], [ 'foo', p('C:/bin/foo-0.dll'), 0, ], ], 'newer version first', ); }; subtest 'case insensitive' => sub { local $FFI::CheckLib::system_path = [ 'corpus/windows/bincase' ]; subtest 'no prefix' => sub { my($path) = find_lib( lib => 'foo' ); ok $path; note "path = @{[ defined $path ? $path : 'undef' ]}"; }; subtest 'with lib prefix' => sub { my($path) = find_lib( lib => 'bar' ); ok $path; note "path = @{[ defined $path ? $path : 'undef' ]}"; }; }; done_testing; Plugin000755001750001750 014050305114 16640 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/t/lib/Test2FauxOS.pm100644001750001750 62414050305114 20465 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/t/lib/Test2/Pluginpackage Test2::Plugin::FauxOS; use strict; use warnings; use Test2::API qw/test2_add_callback_exit/; sub import { my(undef, $os) = @_; die "you must use Test2::Plugin::FauxOS prior to FFI::CheckLib" if $INC{'FFI/CheckLib.pm'}; $FFI::CheckLib::os = $os; test2_add_callback_exit(sub { my ($ctx, $real, $new) = @_; $ctx->note("faux os: $os"); $ctx->note("real os: $^O"); }); } 1; custom000755001750001750 014050305114 17200 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unixlibfoo.so100644001750001750 1314050305114 21107 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/customfoo 1.2.3a lib000755001750001750 014050305114 17245 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usrlibfoo.a100644001750001750 414050305114 20733 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libbad libfoo.so.2.3100644001750001750 1214050305114 20643 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/libfoo 2.3.4 libfoo.so100644001750001750 4614050305114 21162 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libfoo 1.2.3 foo_init foo_new foo_delete libxor.so100644001750001750 1614050305114 21204 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libxor 1.2.3 ben libbar.so100644001750001750 1214050305114 21134 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libbar 1.2.3 lib000755001750001750 014050305114 16735 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwinlibfoo.dylib100644001750001750 1214050305114 21325 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/libfoo 2.3.4 lib000755001750001750 014050305114 17546 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/usrlibfoo.a100644001750001750 414050305114 21234 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/usr/libbad bincase000755001750001750 014050305114 20001 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/windowsfoo.DLL100644001750001750 014050305114 21167 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/windows/bincaseTools000755001750001750 014050305114 16502 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/t/lib/Test2NoteStderr.pm100644001750001750 104414050305114 21270 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/t/lib/Test2/Toolspackage Test2::Tools::NoteStderr; use strict; use warnings; use Test2::API qw( context ); use base qw( Exporter ); our @EXPORT_OK = qw( note_stderr ); BEGIN { eval q{ use Capture::Tiny qw( capture_stderr ); }; if($@) { eval q{ sub capture_stderr (&) { $_[0]->() }; }; } } sub note_stderr (&) { my($code) = @_; my($stderr, $exception) = capture_stderr { eval { $code->(); }; $@; }; my $ctx = context(); $ctx->note($stderr); $ctx->release; die $exception if $exception; return; } 1; libfoo.so.2.3.4100644001750001750 1214050305114 21005 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/libfoo 2.3.4 libfoo.so.1100644001750001750 4614050305114 21321 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libfoo 1.2.3 foo_init foo_new foo_delete libxor.so.1100644001750001750 1614050305114 21343 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libxor 1.2.3 ben libbar.so.1100644001750001750 1214050305114 21273 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libbar 1.2.3 bin000755001750001750 014050305114 17145 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/windowsdinosaur.dll100644001750001750 7214050305114 21565 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/windows/bindinosaur 1.2.3 dinosaur_init dinosaur_new dinosaur_delete pod_spelling_common.t100644001750001750 135014050305114 21700 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xt/authoruse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Pod::Spelling::CommonMistakes' unless eval q{ use Test::Pod::Spelling::CommonMistakes; 1 }; plan skip_all => 'test requires YAML' unless eval q{ use YAML qw( LoadFile ); 1 }; }; use Test::Pod::Spelling::CommonMistakes; use FindBin; use File::Spec; my $config_filename = File::Spec->catfile( $FindBin::Bin, File::Spec->updir, File::Spec->updir, 'author.yml' ); my $config; $config = LoadFile($config_filename) if -r $config_filename; plan skip_all => 'disabled' if $config->{pod_spelling_common}->{skip}; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); # TODO: test files in bin too. all_pod_files_ok; pod_spelling_system.t100644001750001750 236714050305114 21745 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/xt/authoruse strict; use warnings; use Test::More; BEGIN { plan skip_all => 'test requires Test::Spelling' unless eval q{ use Test::Spelling; 1 }; plan skip_all => 'test requires YAML' unless eval q{ use YAML; 1; }; }; use Test::Spelling; use YAML qw( LoadFile ); use FindBin; use File::Spec; my $config_filename = File::Spec->catfile( $FindBin::Bin, File::Spec->updir, File::Spec->updir, 'author.yml' ); my $config; $config = LoadFile($config_filename) if -r $config_filename; plan skip_all => 'disabled' if $config->{pod_spelling_system}->{skip}; chdir(File::Spec->catdir($FindBin::Bin, File::Spec->updir, File::Spec->updir)); add_stopwords($config->{pod_spelling_system}->{stopwords}->@*); add_stopwords(qw( Plicease stdout stderr stdin subref loopback username os Ollis Mojolicious plicease CPAN reinstall TODO filename filenames login callback callbacks standalone VMS hostname hostnames TCP UDP IP API MSWin32 OpenBSD FreeBSD NetBSD unencrypted WebSocket WebSockets timestamp timestamps poney BackPAN portably RedHat AIX BSD XS FFI perlish optimizations subdirectory RESTful SQLite JavaScript dir plugins munge jQuery namespace PDF PDFs usernames DBI pluggable APIs SSL JSON YAML uncommented Solaris OpenVMS URI URL CGI )); all_pod_files_spelling_ok; libfoo.dylib.2100644001750001750 1214050305114 21465 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/libfoo 2.3.4 bin000755001750001750 014050305114 16753 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/cygwincygdinosaur.dll100644001750001750 7214050305114 22076 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/cygwin/bindinosaur 1.2.3 dinosaur_init dinosaur_new dinosaur_delete libfoo.so.1.2100644001750001750 4614050305114 21461 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libfoo 1.2.3 foo_init foo_new foo_delete libxor.so.1.2100644001750001750 1614050305114 21503 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libxor 1.2.3 ben libbar.so.1.2100644001750001750 1214050305114 21433 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libbar 1.2.3 custom000755001750001750 014050305114 17501 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwinlibfoo.dylib100644001750001750 1314050305114 22072 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/customfoo 1.2.3a LIBbar.DLL100644001750001750 014050305114 21477 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/windows/bincaselibfoo.dylib.2.3100644001750001750 1214050305114 21626 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/libfoo 2.3.4 libbar.dylib100644001750001750 1214050305114 22117 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/usr/libbar 1.2.3 libfoo.dylib100644001750001750 4614050305114 22145 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/usr/libfoo 1.2.3 foo_init foo_new foo_delete FauxDynaLoader.pm100644001750001750 237514050305114 22055 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/t/lib/Test2/Toolspackage Test2::Tools::FauxDynaLoader; use strict; use warnings; use Test2::V0 qw( mock ); use DynaLoader; use base qw( Exporter ); our @EXPORT = qw( mock_dynaloader ); sub mock_dynaloader { my @libref = ('null'); my $mock = mock 'DynaLoader'; $mock->override(dl_load_file => sub { my($filename, $flags) = @_; return undef unless -e $filename; my $libref = scalar @libref; $libref[$libref] = TestDLL->new($filename); $libref; }); $mock->override(dl_unload_file => sub { my($libref) = @_; delete $libref[$libref]; }); $mock->override(dl_find_symbol => sub { my($libref, $symbol) = @_; my $lib = $libref[$libref]; $lib->has_symbol($symbol); }); $mock; } package TestDLL; sub new { my($class, $filename) = @_; my @list = do { my $fh; open $fh, '<', $filename; my @list = <$fh>; close $fh; @list; }; chomp @list; my $name = shift @list; my $version = shift @list; my %symbols = map { $_ => 1 } @list; bless { filename => $filename, name => $name, version => $version, symbols => \%symbols, }, $class; } sub filename { shift->{filename} } sub name { shift->{name} } sub version { shift->{version} } sub has_symbol { $_[0]->{symbols}->{$_[1]} } 1; libxor.so.1.2.3100644001750001750 2014050305114 21637 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libxor 1.2.3 roger libbar.so.1.2.3100644001750001750 1214050305114 21574 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libbar 1.2.3 libxor.so.1.2.4100644001750001750 1614050305114 21645 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libxor 1.2.3 ben libfoo.so.1.2.3100644001750001750 4614050305114 21622 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libfoo 1.2.3 foo_init foo_new foo_delete libfoo.dylib.2.3.4100644001750001750 1214050305114 21770 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/libfoo 2.3.4 libfoo.dylib.1100644001750001750 4614050305114 22304 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/usr/libfoo 1.2.3 foo_init foo_new foo_delete libbar.dylib.1100644001750001750 1214050305114 22256 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/usr/libbar 1.2.3 cygapatosaurus-0.dll100644001750001750 10614050305114 22774 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/cygwin/binapatosaurus 1.2.3 apatosaurus_init apatosaurus_new apatosaurus_delete libcrypto.so.0.9.8100644001750001750 3614050305114 22371 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libcrypto 0.9.8 _OpenSSL_VERSION libcrypto.so.1.0.0100644001750001750 3614050305114 22351 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/usr/libcrypto 1.0.0 PEM_read_bio_CMS libfoo.dylib.1.2100644001750001750 4614050305114 22444 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/usr/libfoo 1.2.3 foo_init foo_new foo_delete libbar.dylib.1.2100644001750001750 1214050305114 22416 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/usr/libbar 1.2.3 libs000755001750001750 014050305114 20545 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/foo-1.00/srclibfoo.so100644001750001750 014050305114 22430 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/foo-1.00/src/libslibbaz.so100644001750001750 014050305114 22421 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/foo-1.00/src/libslibbar.so100644001750001750 014050305114 22411 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/unix/foo-1.00/src/libslibapatosaurus-0.dll100644001750001750 10614050305114 23152 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/windows/binapatosaurus 1.2.3 apatosaurus_init apatosaurus_new apatosaurus_delete libbar.dylib.1.2.3100644001750001750 1214050305114 22557 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/usr/libbar 1.2.3 libfoo.dylib.1.2.3100644001750001750 4614050305114 22605 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/usr/libfoo 1.2.3 foo_init foo_new foo_delete libmaiasaura-3-7-0.dll100644001750001750 7214050305114 23034 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/windows/bindinosaur 1.2.3 dinosaur_init dinosaur_new dinosaur_delete libs000755001750001750 014050305114 21046 5ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/foo-1.00/srclibbaz.dylib100644001750001750 014050305114 23404 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/foo-1.00/src/libslibbar.dylib100644001750001750 014050305114 23374 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/foo-1.00/src/libslibfoo.dylib100644001750001750 014050305114 23413 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/darwin/foo-1.00/src/libsdromornis_planei-3.0-7-0.dll100644001750001750 7214050305114 24104 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/windows/bindinosaur 1.2.3 dinosaur_init dinosaur_new dinosaur_delete libthylacaleo_carnifex-3-7___.dll100644001750001750 7214050305114 25375 0ustar00ollisgollisg000000000000FFI-CheckLib-0.28/corpus/windows/bindinosaur 1.2.3 dinosaur_init dinosaur_new dinosaur_delete