Tweaks
[gitmo/Mouse.git] / Makefile.PL
1 # COMPAT_TEST=1 genrates Moose compatible tests
2 # for developpers:
3 BEGIN{
4     if(grep{ $_ eq '--author' } @ARGV){
5         print "$^X -S cpanm < author/requires.cpanm\n";
6         system "$^X -S cpanm < author/requires.cpanm";
7     }
8 }
9
10 use strict;
11 use warnings;
12 use inc::Module::Install 1.00;
13
14 # for co-developpers
15 use Module::Install::XSUtil 0.30;
16 use Module::Install::AuthorTests;
17
18 name     'Mouse';
19 all_from 'lib/Mouse.pm';
20
21 # Scalar::Util < 1.14 has a bug.
22 # > Fixed looks_like_number(undef) to return false for perl >= 5.009002
23 requires 'Scalar::Util' => 1.14;
24
25 test_requires 'Test::More'                  => 0.88;
26 test_requires 'Test::Requires'              => 0.06; # works on 5.6.0
27 test_requires 'Test::Exception::LessClever' => 0.005;
28
29 # to keep zero-dependencies
30 include 'Test::Exception::LessClever';
31 include 'Test::Requires';
32
33 my %suggests = (
34     'Any::Moose'                     => 0.10,
35
36     'MouseX::AttributeHelpers'       => 0.06,
37     'MouseX::NativeTraits'           => 1.00,
38 );
39 while(my($mod, $least) = each %suggests){
40     my $status = system $^X, '-e', <<"CHECK";
41 if(eval q{ use $mod (); 1 }) {
42     if(eval q{ use $mod $least (); 1 }) {
43         exit 0; # installd, and new enough
44     }
45     else {
46         exit 1; # installed, but too old
47     }
48 }
49 CHECK
50
51     if($status != 0){
52         my $ver = `$^X -e "use $mod (); print $mod->VERSION"`;
53         warn("\n",
54             "WARNING: $mod is installed, but its version ($ver) is too old (< $least).\n",
55             "         Please update $mod after installation of Mouse.\n",
56             "\n"
57         );
58     }
59 }
60
61 # cc_want deals with the '--pp' and '--xs' options
62 my $use_xs = ($] >= 5.008_001 && want_xs());
63
64 if($use_xs){
65     print "Mouse configured with XS.\n";
66
67     use_ppport(3.19);
68     use_xshelper();
69     cc_warnings();
70     cc_src_paths('xs-src');
71 }
72 else{
73     print "Mouse configured with Pure Perl.\n";
74 }
75
76 tests 't/*.t t/*/*.t';
77 author_tests 'xt';
78
79 repository 'git://git.moose.perl.org/Mouse.git';
80
81 system($^X, 'tool/generate-mouse-tiny.pl', 'lib/Mouse/Tiny.pm') == 0
82     or warn "Cannot generate Mouse::Tiny: $!";
83 makemaker_args PL_FILES => {
84     'tool/generate-mouse-tiny.pl' => 'lib/Mouse/Tiny.pm',
85 };
86
87 if ($Module::Install::AUTHOR) {
88     require 'lib/Mouse/Spec.pm'; # for the version
89     my $require_version = Mouse::Spec->MooseVersion;
90
91     if ($ENV{COMPAT_TEST}
92             && eval { require Moose; Moose->VERSION($require_version) }) {
93         print "You have Moose ", Moose->VERSION, ".\n";
94         do 'tool/create-moose-compatibility-tests.pl';
95         # repeat testing
96         # see also ExtUtils::MM_Any::test_via_harness()
97         my $t_moose =  q{$(FULLPERLRUN) -MExtUtils::Command::MM -e}
98                       .q{ "test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')"}
99                       .q{ xt/compat/t/*/*.t } . "\n";
100
101         postamble qq{test :: test_moose\n\n}
102                 . qq{test_moose :: pure_all\n}
103                 . qq{\t} . $t_moose;
104     } else {
105         print "You don't have Moose $require_version. skipping moose compatibility test\n";
106     }
107
108     if($use_xs){
109         # repeat testing
110         # see also ExtUtils::MM_Any::test_via_harness()
111         my $t_pp =  q{$(FULLPERLRUN) -MExtUtils::Command::MM -e}
112                    .q{ "do 'tool/force-pp.pl'; test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')"}
113                    .q{ $(TEST_FILES)} . "\n";
114
115         postamble qq{test :: test_pp\n\n}
116                 . qq{test_pp :: pure_all\n}
117                 . qq{\t} . $t_pp;
118     }
119
120     # Hack to disable Test::Exception, which might pull a perl internal bug.
121     # See also Test::Exception::LessClever.
122     open my $out, '>', 'inc/Test/Exception.pm' or die $!;
123     print $out <<'EOT';
124 package Test::Exception; # wapper to T::E::LessClever
125 require Test::Exception::LessClever;
126 $INC{'Test/Exception.pm'} = __FILE__;
127 sub import {
128     shift;
129     Test::Exception::LessClever->export_to_level(1, @_);
130 }
131 1;
132 EOT
133     close $out or die $!;
134 }
135
136 clean_files q{
137     lib/Mouse/Tiny.pm $(O_FILES) test-mydeps-*.log
138     *.out
139     cover_db xs-src/*.gc{v,no,da}
140 };
141
142 WriteAll check_nmake => 0;