Add TODO
[gitmo/Mouse.git] / Makefile.PL
CommitLineData
972340a6 1# COMPAT_TEST=1 genrates Moose compatible tests
e8c583d3 2# for developpers:
3BEGIN{
4 if(grep{ $_ eq '--author' } @ARGV){
01f38ab1 5 print "$^X -S cpanm < author/requires.cpanm\n";
e8c583d3 6 system "$^X -S cpanm < author/requires.cpanm";
7 }
8}
9
08f7a8db 10use strict;
11use warnings;
9c96124c 12BEGIN {
13 # author requires, or bundled modules
14 my @devmods = qw(
15 inc::Module::Install 1.00
16 Module::Install::TestTarget 0.13
17 Module::Install::AuthorTests 0.002
18 Module::Install::XSUtil 0.36
19 Test::Exception::LessClever 0.005
20 Test::Requires 0.06
21 );
22 my @not_available;
23 while(my($mod, $ver) = splice @devmods, 0, 2) {
24 eval qq{use $mod $ver (); 1} or push @not_available, $mod;
25 }
26 if(@not_available) {
27 print qq{# The following modules are not available.\n};
28 print qq{# `perl $0 | cpanm` will install them:\n};
29 print $_, "\n" for @not_available;
30 exit 1;
31 }
32}
33use inc::Module::Install;
884bf37f 34
c3398f5b 35all_from 'lib/Mouse.pm';
36
ec53d678 37# Scalar::Util < 1.14 has a bug.
38# > Fixed looks_like_number(undef) to return false for perl >= 5.009002
39requires 'Scalar::Util' => 1.14;
272a1930 40
9c96124c 41test_requires 'Test::More' => 0.88;
f7f4955d 42
43# to keep zero-dependencies
44include 'Test::Exception::LessClever';
45include 'Test::Requires';
179ac6cc 46
3310ddf2 47my %suggests = (
af1c2a64 48 'Any::Moose' => 0.10,
8e4a10a8 49
3310ddf2 50 'MouseX::AttributeHelpers' => 0.06,
32ec255c 51 'MouseX::NativeTraits' => 1.00,
3310ddf2 52);
3310ddf2 53while(my($mod, $least) = each %suggests){
6741954a 54 my $status = system $^X, '-e', <<"CHECK";
55if(eval q{ use $mod (); 1 }) {
56 if(eval q{ use $mod $least (); 1 }) {
c4f4f5e3 57 exit 0; # installd, and new enough
58 }
59 else {
60 exit 1; # installed, but too old
61 }
62}
63CHECK
64
65 if($status != 0){
66 my $ver = `$^X -e "use $mod (); print $mod->VERSION"`;
67 warn("\n",
68 "WARNING: $mod is installed, but its version ($ver) is too old (< $least).\n",
69 " Please update $mod after installation of Mouse.\n",
70 "\n"
71 );
3310ddf2 72 }
73}
74
ec7a9423 75# cc_want deals with the '--pp' and '--xs' options
76my $use_xs = ($] >= 5.008_001 && want_xs());
0e81c55d 77
78if($use_xs){
2af88019 79 print "Mouse configured with XS.\n";
bb543d7f 80
fdee07cc 81 use_ppport(3.19);
8e4a10a8 82 use_xshelper();
2af88019 83 cc_warnings();
0e81c55d 84 cc_src_paths('xs-src');
758664cd 85 if($use_xs){
38f4a557 86 test_target test_pp => (
87 env => { PERL_ONLY => 1 },
88 ($Module::Install::AUTHOR ? (alias => 'test') : ()),
89 );
758664cd 90 }
38f4a557 91}
0e81c55d 92else{
7b92a82b 93 print "Mouse configured with Pure Perl.\n";
0e81c55d 94}
95
125dc1a8 96tests 't/*.t t/*/*.t';
1e2f2888 97author_tests 'xt';
98
125dc1a8 99repository 'git://git.moose.perl.org/Mouse.git';
100
823419c5 101system($^X, 'tool/generate-mouse-tiny.pl', 'lib/Mouse/Tiny.pm') == 0
102 or warn "Cannot generate Mouse::Tiny: $!";
103makemaker_args PL_FILES => {
104 'tool/generate-mouse-tiny.pl' => 'lib/Mouse/Tiny.pm',
105};
106
af1c2a64 107if ($Module::Install::AUTHOR) {
108 require 'lib/Mouse/Spec.pm'; # for the version
121acb8a 109 my $require_version = Mouse::Spec->MooseVersion;
bf9f3f91 110
972340a6 111 if ($ENV{COMPAT_TEST}
112 && eval { require Moose; Moose->VERSION($require_version) }) {
92ff14d0 113 print "You have Moose ", Moose->VERSION, ".\n";
2af88019 114 do 'tool/create-moose-compatibility-tests.pl';
38f4a557 115 test_target test_moose => (
116 tests => ['xt/compat/t/*/*.t'],
117 alias => 'test',
118 );
314fe304 119 } else {
92ff14d0 120 print "You don't have Moose $require_version. skipping moose compatibility test\n";
314fe304 121 }
4358792d 122
f7f4955d 123
124 # Hack to disable Test::Exception, which might pull a perl internal bug.
125 # See also Test::Exception::LessClever.
126 open my $out, '>', 'inc/Test/Exception.pm' or die $!;
127 print $out <<'EOT';
128package Test::Exception; # wapper to T::E::LessClever
129require Test::Exception::LessClever;
130$INC{'Test/Exception.pm'} = __FILE__;
131sub import {
132 shift;
133 Test::Exception::LessClever->export_to_level(1, @_);
134}
1351;
136EOT
137 close $out or die $!;
314fe304 138}
139
af1c2a64 140clean_files q{
141 lib/Mouse/Tiny.pm $(O_FILES) test-mydeps-*.log
142 *.out
143 cover_db xs-src/*.gc{v,no,da}
144};
1e2f2888 145
eb88905f 146WriteAll check_nmake => 0;