Assert that complex bindtytyping passage works for the search() bind attribute
[dbsrgits/DBIx-Class.git] / Makefile.PL
CommitLineData
47a4aa51 1use inc::Module::Install 1.00;
fe650234 2use strict;
3use warnings;
4
55087b99 5use 5.008001;
ce4c07df 6
8057ed01 7use FindBin;
8use lib "$FindBin::Bin/lib";
2f5a6e87 9use DBIx::Class::Optional::Dependencies;
93c50889 10
d1dc7a98 11# get cpanX --installdeps . to behave in a checkout (most users do not need
12# the deps for a full test suite run, and if they do - there's MI::AutoInstall
13# for that)
14##
15## DO NOT USE THIS HACK IN YOUR DISTS!!! (it makes #toolchain sad)
16##
17$Module::Install::AUTHOR = 0 if (grep { $ENV{"PERL5_${_}_IS_RUNNING"} } (qw/CPANM CPANPLUS CPAN/) );
18
4b5544ad 19###
20### DO NOT ADD OPTIONAL DEPENDENCIES HERE, EVEN AS recommends()
21### All of them should go to DBIx::Class::Optional::Dependencies
22###
23
ce4c07df 24name 'DBIx-Class';
b50d0dd3 25perl_version '5.008001';
8e0f16f1 26all_from 'lib/DBIx/Class.pm';
ce4c07df 27
8057ed01 28my $build_requires = {
79680fc0 29 # needed for testing only, not for operation
b9df8e39 30 'DBD::SQLite' => '1.29',
8057ed01 31};
32
33my $test_requires = {
30da8374 34 'File::Temp' => '0.22',
0007aedf 35 'Test::Exception' => '0.31',
30da8374 36 'Test::Warn' => '0.21',
c7bc500e 37 'Test::More' => '0.94',
38 # not sure if this is necessary at all, ask schwern some day
39 'Test::Builder' => '0.94',
90cfe42b 40
41 # this is already a dep of n::c, but just in case - used by t/55namespaces_cleaned.t
42 # remove and do a manual glob-collection if n::c is no longer a dep
43 'Package::Stash' => '0.28',
8057ed01 44};
45
46my $runtime_requires = {
b8d22f13 47 'Class::Accessor::Grouped' => '0.10002',
9c1700e3 48 'Class::C3::Componentised' => '1.0009',
8057ed01 49 'Class::Inspector' => '1.24',
79680fc0 50 'Config::Any' => '0.20',
51 'Context::Preserve' => '0.01',
2b8cc2f2 52 'Data::Dumper::Concise' => '2.020',
8057ed01 53 'Data::Page' => '2.00',
b8d22f13 54 'Hash::Merge' => '0.12',
8057ed01 55 'MRO::Compat' => '0.09',
56 'Module::Find' => '0.06',
cd122820 57 'namespace::clean' => '0.20',
f4d7449c 58 'Path::Class' => '0.18',
b7b18f32 59 'Scope::Guard' => '0.03',
bf51641f 60 'SQL::Abstract' => '1.72',
20674fcd 61 'Try::Tiny' => '0.04',
79680fc0 62
63 # XS (or XS-dependent) libs
997a3638 64 'DBI' => '1.57',
79680fc0 65 'Sub::Name' => '0.04',
79680fc0 66
c7d50a7d 67 # dual-life corelibs needing a specific bugfixed version
79680fc0 68 'File::Path' => '2.07',
cd122820 69
70 # FIXME - temporary, needs throwing out for something more efficient
71 'Data::Compare' => '1.22',
8057ed01 72};
73
bb7950c0 74
75# Bail out on parallel testing
76if (
77 ($ENV{HARNESS_OPTIONS}||'') =~ / (?: ^ | \: ) j(\d+) /x
78 and
79 $1 > 1
80) { die <<EOP }
81
82******************************************************************************
83******************************************************************************
84*** ***
85*** PARALLEL TESTING DETECTED ( \$ENV{HARNESS_OPTIONS} = 'j$1' ) ***
86*** ***
87*** DBIC tests will fail. It is harder to make them parallel-friendly than ***
88*** it should be (though work is underway). In the meantime you will have ***
89*** to adjust your environment and re-run the installation. Sorry! ***
90*** ***
91******************************************************************************
92******************************************************************************
93
94EOP
95
96require Getopt::Long;
97my $getopt = Getopt::Long::Parser->new(
98 config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
99);
100my $args = {
101 skip_author_deps => undef,
102};
103$getopt->getoptions($args, 'skip_author_deps');
104if (@ARGV) {
105 warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
106}
107
8057ed01 108# this is so we can order requires alphabetically
109# copies are needed for author requires injection
110my $reqs = {
111 build_requires => { %$build_requires },
112 requires => { %$runtime_requires },
113 test_requires => { %$test_requires },
114};
3a4251e2 115
be68095d 116my %reqs_for_group = %{DBIx::Class::Optional::Dependencies->req_group_list};
117
118# exclude the rdbms_* groups which are for DBIC users
2f5a6e87 119my $opt_testdeps = {
be68095d 120 map { %{$reqs_for_group{$_}} } grep { !/^rdbms_/ } keys %reqs_for_group
2f5a6e87 121};
8057ed01 122
92f8f62a 123# require extra modules for testing if we're in a checkout
0424d17a 124my $optdep_msg;
92f8f62a 125if ($Module::Install::AUTHOR) {
0424d17a 126 if ($args->{skip_author_deps}) {
127 $optdep_msg = <<'EOW';
128
129******************************************************************************
130******************************************************************************
131*** ***
132*** IGNORING AUTHOR MODE: no optional test dependencies will be forced. ***
133*** ***
134*** If you are using this checkout with the intention of submitting a DBIC ***
135*** patch, you are *STRONGLY ENCOURAGED* to install all dependencies, so ***
136*** that every possible unit-test will run. ***
137*** ***
138******************************************************************************
139******************************************************************************
140
141EOW
142 }
143 else {
144 $optdep_msg = <<'EOW';
145
8057ed01 146******************************************************************************
147******************************************************************************
148*** ***
149*** AUTHOR MODE: all optional test dependencies converted to hard requires ***
7adae31a 150*** ( to disable re-run Makefile.PL with --skip_author_deps ) ***
8057ed01 151*** ***
152******************************************************************************
153******************************************************************************
154
155EOW
156
0424d17a 157 $reqs->{test_requires} = {
158 %{$reqs->{test_requires}},
2f5a6e87 159 %$opt_testdeps
0424d17a 160 };
161 }
8057ed01 162}
163
164# compose final req list, for alphabetical ordering
165my %final_req;
166for my $rtype (keys %$reqs) {
167 for my $mod (keys %{$reqs->{$rtype}} ) {
168
169 # sanity check req duplications
170 if ($final_req{$mod}) {
b718fd0a 171 die "$mod specified as both a '$rtype' and a '$final_req{$mod}[0]'\n";
8057ed01 172 }
173
174 $final_req{$mod} = [ $rtype, $reqs->{$rtype}{$mod}||0 ],
175 }
176}
177
178# actual require
179for my $mod (sort keys %final_req) {
180 my ($rtype, $ver) = @{$final_req{$mod}};
181 no strict 'refs';
182 $rtype->($mod, $ver);
183}
a410299d 184
0424d17a 185# output twice since the deplist is > 70 lines
f90896ae 186warn $optdep_msg if $Module::Install::AUTHOR;
92f8f62a 187auto_install();
f90896ae 188warn $optdep_msg if $Module::Install::AUTHOR;
92f8f62a 189
4557be61 190
92f8f62a 191# re-create various autogenerated documentation bits
192if ($Module::Install::AUTHOR) {
193
bb7950c0 194 # adjust ENV for $AUTHOR system() calls
195 require Config;
196 $ENV{PERL5LIB} = join ($Config::Config{path_sep}, @INC);
197
92f8f62a 198 print "Regenerating README\n";
199 system('pod2text lib/DBIx/Class.pm > README');
200
201 if (-f 'MANIFEST') {
202 print "Removing MANIFEST\n";
203 unlink 'MANIFEST';
204 }
205
92f8f62a 206 print "Regenerating Optional/Dependencies.pod\n";
207 require DBIx::Class::Optional::Dependencies;
ccebe1f1 208 DBIx::Class::Optional::Dependencies->_gen_pod (Meta->version);
92f8f62a 209
210 # FIXME Disabled due to unsolved issues, ask theorbtwo
211 # require Module::Install::Pod::Inherit;
212 # PodInherit();
213}
214
f90896ae 215
7eaae8db 216tests_recursive (qw|
217 t
218|);
219
f90896ae 220# temporary(?) until I get around to fix M::I wrt xt/
221# needs Module::Install::AuthorTests
c1fdb460 222eval {
c5e9d46d 223 # this should not be necessary since the autoloader is supposed
224 # to work, but there were reports of it failing
225 require Module::Install::AuthorTests;
7f2c37b8 226 recursive_author_tests (qw/xt/);
227 1;
228} || do {
d1dc7a98 229 if ($Module::Install::AUTHOR && ! $args->{skip_author_deps}) {
22a2062e 230 my $err = $@;
c5e9d46d 231
232 # better error message in case of missing dep
22a2062e 233 eval { require Module::Install::AuthorTests }
eeaf8701 234 || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode (or supply --skip_author_deps):\n\n$@\n";
c5e9d46d 235
236 die $err;
22a2062e 237 }
7f2c37b8 238};
f90896ae 239
240
a410299d 241install_script (qw|
242 script/dbicadmin
243|);
244
7eaae8db 245
246### Mangle makefile - read the comments for more info
247#
248postamble <<"EOP";
249
250# This will add an extra dep-spec for the distdir target,
251# which `make` will fold together in a first-come first-serve
252# fashion. What we do here is essentially adding extra
253# commands to execute once the distdir is assembled (via
254# create_distdir), but before control is returned to a higher
255# calling rule.
256distdir : dbicadmin_pod_inject
257
258# The pod self-injection code is in fact a hidden option in
259# dbicadmin itself
260dbicadmin_pod_inject :
261\tcd \$(DISTVNAME) && \$(ABSPERL) -Ilib script/dbicadmin --selfinject-pod
262
263# Regenerate manifest before running create_distdir.
264create_distdir : manifest
265
266EOP
267
f90896ae 268homepage 'http://www.dbix-class.org/';
a410299d 269resources 'IRC' => 'irc://irc.perl.org/#dbix-class';
270resources 'license' => 'http://dev.perl.org/licenses/';
aeb669b8 271resources 'repository' => 'git://git.shadowcat.co.uk/dbsrgits/DBIx-Class.git';
a410299d 272resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
70fbb0b8 273resources 'bugtracker' => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class';
a410299d 274
974fe5e8 275# Deprecated/internal modules need no exposure
276no_index directory => $_ for (qw|
bc6f129c 277 lib/DBIx/Class/Admin
281738a4 278 lib/DBIx/Class/PK/Auto
bc6f129c 279 lib/DBIx/Class/CDBICompat
974fe5e8 280|);
281no_index package => $_ for (qw/
d5dedbd6 282 DBIx::Class::Storage::DBIHacks
70c28808 283 DBIx::Class::Carp
cd122820 284 DBIx::Class::ResultSet::Pager
974fe5e8 285/);
a410299d 286
713cc98e 287WriteAll();
09d46657 288
2f5a6e87 289# Re-write META.yml to _exclude_ all forced build-requires (we do not want to ship
290# this) We are also not using M::I::AuthorRequires as this will be an extra dep,
291# and deps in Makefile.PL still suck
292# Also always test the result so we stop shipping borked dependency lists to CPAN
713cc98e 293
2f5a6e87 294# FIXME test_requires is not yet part of META
295my %original_build_requires = ( %$build_requires, %$test_requires );
296my @all_build_requires = @{delete Meta->{values}{build_requires}};
297my %removed_build_requires;
8057ed01 298
2f5a6e87 299for (@all_build_requires) {
300 if ($original_build_requires{$_->[0]}) {
301 push @{Meta->{values}{build_requires}}, $_;
302 }
303 else {
304 $removed_build_requires{$_->[0]} = $_->[1]
305 unless $_->[0] eq 'ExtUtils::MakeMaker';
1278e5f0 306 }
2f5a6e87 307}
713cc98e 308
2f5a6e87 309# Rewrite only in author mode, the original META should not contain anything anyway
310# if we executed as non-author
311if ($Module::Install::AUTHOR && keys %removed_build_requires) {
1278e5f0 312 print "Regenerating META with author requires excluded\n";
713cc98e 313 Meta->write;
2f5a6e87 314}
1278e5f0 315
2f5a6e87 316# test that we really took things away (just in case, happened twice somehow)
b8d22f13 317if (! -f 'META.yml') {
318 warn "No META.yml generated?! aborting...\n";
319 exit 1;
320}
2f5a6e87 321my $meta = do { local @ARGV = 'META.yml'; local $/; <> };
322
323# this is safe as there is a fatal check earlier to make sure $opt_testdeps does
324# not contain any real dependencies
325my @illegal_leftovers = grep
326 { $meta =~ /^ \s+ \Q$_\E \: \s+ /mx }
327 ( sort keys %$opt_testdeps )
328;
329
330if (@illegal_leftovers) {
331 die join ("\n",
332 "\n\nFATAL FAIL! It looks like some author dependencies made it to the META.yml:\n",
333 map { "\t$_" } @illegal_leftovers
334 ) . "\n\n";
09d46657 335}