File Coverage

blib/lib/Alien/Box2D.pm
Criterion Covered Total %
statement 33 33 100.0
branch 4 8 50.0
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 47 51 92.1


line stmt bran cond sub pod time code
1             package Alien::Box2D;
2 3     3   160225 use strict;
  3         19  
  3         67  
3 3     3   11 use warnings;
  3         4  
  3         56  
4 3     3   1615 use Alien::Box2D::ConfigData;
  3         6  
  3         83  
5 3     3   1171 use File::ShareDir qw(dist_dir);
  3         15684  
  3         134  
6 3     3   24 use File::Spec;
  3         6  
  3         72  
7 3     3   12 use File::Find;
  3         10  
  3         167  
8 3     3   1117 use File::Spec::Functions qw(catdir catfile rel2abs);
  3         1840  
  3         785  
9              
10             =head1 NAME
11              
12             Alien::Box2D - Build and make available Box2D library - L
13              
14             =head1 VERSION
15              
16             Version 0.106
17              
18             =cut
19              
20             our $VERSION = '0.106';
21             $VERSION = eval $VERSION;
22              
23             =head1 SYNOPSIS
24              
25             You can use Alien::Box2D in your module that needs to link with I
26             library like this:
27              
28             # Sample Build.pl
29             use Module::Build;
30             use Alien::Box2D;
31              
32             my $build = Module::Build->new(
33             module_name => 'Any::Box2D::Module',
34             # + other params
35             build_requires => {
36             'Alien::Box2D' => 0,
37             # + others modules
38             },
39             configure_requires => {
40             'Alien::Box2D' => 0,
41             # + others modules
42             },
43             extra_compiler_flags => Alien::Box2D->config('cflags'),
44             extra_linker_flags => Alien::Box2D->config('libs'),
45             )->create_build_script;
46              
47             NOTE: Alien::Box2D is required only for building not for using 'Any::Box2D::Module'.
48              
49             =head1 DESCRIPTION
50              
51             Alien::Box2D during its installation downloads Box2D library source codes,
52             builds I binaries from source codes and installs necessary dev files
53             (headers: *.h, static library: *.a) into I directory of Alien::Box2D
54             distribution.
55              
56             =head1 METHODS
57              
58             =head2 config()
59              
60             This function is the main public interface to this module:
61              
62             Alien::Box2D->config('prefix');
63             Alien::Box2D->config('version');
64             Alien::Box2D->config('libs');
65             Alien::Box2D->config('cflags');
66              
67             =head1 BUGS
68              
69             Please post issues and bugs at L
70              
71             =head1 AUTHOR
72              
73             FROGGS, Efroggs at cpan.orgE
74              
75             KMX, Ekmx at cpan.orgE
76              
77             =head1 COPYRIGHT
78              
79             Please notice that the source code of Box2D library has a different license than module itself.
80              
81             =head2 Alien::Box2D perl module
82              
83             This program is free software; you can redistribute
84             it and/or modify it under the same terms as Perl itself.
85              
86             The full text of the license can be found in the
87             LICENSE file included with this module.
88              
89             =head2 Source code of Box2D library
90              
91             Copyright (c) 2006-2010 Erin Catto http://www.gphysics.com
92              
93             This software is provided 'as-is', without any express or implied
94             warranty. In no event will the authors be held liable for any damages
95             arising from the use of this software.
96              
97             Permission is granted to anyone to use this software for any purpose,
98             including commercial applications, and to alter it and redistribute it
99             freely, subject to the following restrictions:
100              
101             1. The origin of this software must not be misrepresented; you must not
102             claim that you wrote the original software. If you use this software
103             in a product, an acknowledgment in the product documentation would be
104             appreciated but is not required.
105             2. Altered source versions must be plainly marked as such, and must not be
106             misrepresented as being the original software.
107             3. This notice may not be removed or altered from any source distribution.
108              
109             =cut
110              
111             ### get config params
112             sub config
113             {
114 10     10 1 20812 my ($package, $param) = @_;
115 10 50       63 return _box2d_config_via_config_data($param) if(Alien::Box2D::ConfigData->config('config'));
116             }
117              
118             ### internal functions
119             sub _box2d_config_via_config_data
120             {
121 10     10   24 my ($param) = @_;
122 10         56 my $share_dir = dist_dir('Alien-Box2D');
123 10         830 my $subdir = Alien::Box2D::ConfigData->config('share_subdir');
124 10 50       26 return unless $subdir;
125 10         42 my $real_prefix = catdir($share_dir, $subdir);
126 10 50       50 return unless ($param =~ /[a-z0-9_]*/i);
127 10         20 my $val = Alien::Box2D::ConfigData->config('config')->{$param};
128 10 50       18 return unless $val;
129             # handle @PrEfIx@ replacement
130 10         34 $val =~ s/\@PrEfIx\@/$real_prefix/g;
131 10         64 return $val;
132             }
133              
134             1;