Force xt/ tests to run on anything involving a create_distdir
[dbsrgits/DBIx-Class.git] / Makefile.PL
1 use strict;
2 use warnings;
3
4 use 5.008001;
5 use inc::Module::Install 1.06;
6
7 ##
8 ## DO NOT USE THIS HACK IN YOUR DISTS!!! (it makes #toolchain sad)
9 ##
10 # get cpanX --installdeps . to behave in a checkout (most users do not expect
11 # the deps for a full test suite run, and if they do - there's MI::AutoInstall
12 # for that)
13 BEGIN {
14   $Module::Install::AUTHOR = 0 if (grep { $ENV{"PERL5_${_}_IS_RUNNING"} } (qw/CPANM CPANPLUS CPAN/) );
15 }
16
17 homepage 'http://www.dbix-class.org/';
18 resources 'IRC'         => 'irc://irc.perl.org/#dbix-class';
19 resources 'license'     => 'http://dev.perl.org/licenses/';
20 resources 'repository'  => 'https://github.com/dbsrgits/DBIx-Class';
21 resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
22 resources 'bugtracker'  => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class';
23
24 name     'DBIx-Class';
25 perl_version '5.008001';
26 all_from 'lib/DBIx/Class.pm';
27 Meta->{values}{x_authority} = 'cpan:RIBASUSHI';
28
29 tests_recursive (qw|
30     t
31 |);
32
33 install_script (qw|
34     script/dbicadmin
35 |);
36
37 ###
38 ### DO NOT ADD OPTIONAL DEPENDENCIES HERE, EVEN AS recommends()
39 ### All of them *MUST* go to DBIx::Class::Optional::Dependencies
40 ###
41 my $runtime_requires = {
42   # FIXME - temporary, needs throwing out for something more efficient
43   'Data::Compare'            => '1.22',
44
45   # DBI itself should be capable of installation and execution in pure-perl
46   # mode. However it has never been tested yet, so consider XS for the time
47   # being
48   'DBI'                      => '1.57',
49
50   # XS (or XS-dependent) libs
51   'Sub::Name'                => '0.04',
52
53   # pure-perl (FatPack-able) libs
54   'Class::Accessor::Grouped' => '0.10009',
55   'Class::C3::Componentised' => '1.0009',
56   'Class::Inspector'         => '1.24',
57   'Config::Any'              => '0.20',
58   'Context::Preserve'        => '0.01',
59   'Data::Dumper::Concise'    => '2.020',
60   'Data::Page'               => '2.00',
61   'Devel::GlobalDestruction' => '0.09',
62   'Hash::Merge'              => '0.12',
63   'Moo'                      => '1.000006',
64   'MRO::Compat'              => '0.12',
65   'Module::Find'             => '0.07',
66   'namespace::clean'         => '0.24',
67   'Path::Class'              => '0.18',
68   'Scope::Guard'             => '0.03',
69   'SQL::Abstract'            => '1.73',
70   'Try::Tiny'                => '0.07',
71 };
72
73 my $build_requires = {
74   # needed for testing only, not for operation
75   # we will move away from this dep eventually, perhaps to DBD::CSV or something
76   'DBD::SQLite'              => '1.29',
77 };
78
79 my $test_requires = {
80   'File::Temp'               => '0.22',
81   'Test::Exception'          => '0.31',
82   'Test::Warn'               => '0.21',
83   'Test::More'               => '0.94',
84   # not sure if this is necessary at all, ask schwern some day
85   'Test::Builder'            => '0.94',
86
87   # this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t
88   # remove and do a manual glob-collection if n::c is no longer a dep
89   'Package::Stash'           => '0.28',
90 };
91
92 # make strictures.pm happy (DO NOT LIKE, TOO MUCH XS!)
93 # (i.e. what if the .git/.svn is *not* because of DBIC?)
94 #
95 # Note - this is added as test_requires *directly*, so it gets properly
96 # excluded on META.yml cleansing
97 if (-e '.git' or -e '.svn') {
98   test_requires 'indirect'              => '0.25';
99   test_requires 'multidimensional'      => '0.008';
100   test_requires 'bareword::filehandles' => '0.003';
101 }
102
103 # if the user has this env var set and no SQLT installed, tests will fail
104 # same rationale for direct test_requires as the strictures stuff above
105 # (even though no dist will be created from this)
106 # we force this req regarless of author_deps, worst case scenario it will
107 # be specified twice
108 if ($ENV{DBICTEST_SQLT_DEPLOY}) {
109   local @INC = ('lib', @INC);
110   require DBIx::Class::Optional::Dependencies;
111   my $dep_req = DBIx::Class::Optional::Dependencies->req_list_for('deploy');
112   for (keys %$dep_req) {
113     test_requires ($_ => $dep_req->{$_})
114   }
115 }
116
117 # this is so we can order requires alphabetically
118 # copies are needed for potential author requires injection
119 my $reqs = {
120   build_requires => { %$build_requires },
121   requires => { %$runtime_requires },
122   test_requires => { %$test_requires },
123 };
124
125 # only do author-includes if not part of a `make` run
126 if ($Module::Install::AUTHOR  and ! $ENV{MAKELEVEL}) {
127   # get options here, make $args available to all snippets
128   require Getopt::Long;
129   my $getopt = Getopt::Long::Parser->new(
130     config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
131   );
132   my $args = {
133     skip_author_deps => undef,
134   };
135   $getopt->getoptions($args, qw/
136     skip_author_deps|skip-author-deps
137   /);
138   if (@ARGV) {
139     warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
140   }
141
142   require File::Spec;
143   # string-eval, not do(), because we need to provide the
144   # $reqs and $*_requires lexicals to the included file
145   # (some includes *do* modify $reqs above)
146   for my $inc (sort glob ( File::Spec->catfile('maint', 'Makefile.PL.inc', '*') ) ) {
147     my $src = do { local (@ARGV, $/) = $inc; <> } or die $!;
148     eval "use warnings; use strict; $src" or die sprintf
149       "Failed execution of %s: %s\n",
150       $inc,
151       ($@ || $! || 'Unknown error'),
152     ;
153   }
154 }
155 else {
156   # make sure this Makefile can not be used to make a dist
157   # (without the author includes there are no meta cleanup, no sanity checks, etc)
158   postamble <<EOP;
159 create_distdir: nonauthor_stop_distdir_creation
160 nonauthor_stop_distdir_creation:
161 \t\$(NOECHO) \$(ECHO) Creation of dists in non-author mode is not allowed
162 \t\$(NOECHO) \$(FALSE)
163 EOP
164 }
165
166 # compose final req list, for alphabetical ordering
167 my %final_req;
168 for my $rtype (keys %$reqs) {
169   for my $mod (keys %{$reqs->{$rtype}} ) {
170
171     # sanity check req duplications
172     if ($final_req{$mod}) {
173       die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
174     }
175
176     $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
177   }
178 }
179
180 # actual require
181 for my $mod (sort keys %final_req) {
182   my ($rtype, $ver) = @{$final_req{$mod}};
183   no strict 'refs';
184   $rtype->($mod, $ver);
185 }
186
187 # author-mode or not - this is where we show a list of missing deps
188 # IFF we are running interactively
189 auto_install();
190
191 WriteAll();