minor replication changes - use a real hash merge, clarify master_read_weight, really...
[dbsrgits/DBIx-Class.git] / Makefile.PL
CommitLineData
0ee285f3 1use inc::Module::Install 0.79;
fe650234 2use strict;
3use warnings;
76607ac8 4use POSIX ();
fe650234 5
6use 5.006001; # delete this line if you want to send patches for earlier.
ce4c07df 7
8name 'DBIx-Class';
ce4c07df 9perl_version '5.006001';
8e0f16f1 10all_from 'lib/DBIx/Class.pm';
ce4c07df 11
0ee285f3 12# configure_requires so _check_sqlite() below can run
13# remove once test deprecated
14configure_requires 'DBD::SQLite';
15
f9dc732b 16requires 'DBD::SQLite' => 1.23;
82fae370 17requires 'Data::Page' => 2.00;
18requires 'Scalar::Util' => 0;
e90b8592 19requires 'SQL::Abstract' => 1.54;
82fae370 20requires 'SQL::Abstract::Limit' => 0.13;
624764ae 21requires 'Class::C3::Componentised' => 1.0005;
82fae370 22requires 'Storable' => 0;
23requires 'Carp::Clan' => 0;
24requires 'DBI' => 1.40;
25requires 'Module::Find' => 0;
26requires 'Class::Inspector' => 0;
2d60be4d 27requires 'Class::Accessor::Grouped' => 0.08003;
82fae370 28requires 'JSON::Any' => 1.17;
29requires 'Scope::Guard' => 0.03;
30requires 'Path::Class' => 0;
31requires 'List::Util' => 1.19;
32requires 'Sub::Name' => 0.04;
0fdb7298 33requires 'MRO::Compat' => 0.09;
ce4c07df 34
35# Perl 5.8.0 doesn't have utf8::is_utf8()
82fae370 36requires 'Encode' => 0 if ($] <= 5.008000);
ce4c07df 37
f947585b 38test_requires 'Test::Builder' => 0.33;
97aca715 39test_requires 'Test::Warn' => 0.11;
f947585b 40test_requires 'Test::Exception' => 0;
ce3b4eb9 41test_requires 'Test::Deep' => 0;
ce4c07df 42
82fae370 43recommends 'SQL::Translator' => 0.09004;
44
0ee285f3 45install_script (qw|
46 script/dbicadmin
47|);
ce4c07df 48
0ee285f3 49tests_recursive (qw|
50 t
51|);
ce4c07df 52
c96454c3 53# re-build README and require extra modules for testing if we're in a checkout
fe650234 54
82fae370 55my %force_requires_if_author = (
c96454c3 56 'Test::Pod::Coverage' => 1.04,
9ac2c0f8 57 'SQL::Translator' => 0.09004,
58
59 # CDBI-compat related
82fae370 60 'DBIx::ContextualFetch' => 0,
602fd807 61 'Class::DBI::Plugin::DeepAbstractSearch' => 0,
82fae370 62 'Class::Trigger' => 0,
97d61088 63 'Time::Piece::MySQL' => 0,
82fae370 64 'Clone' => 0,
97d61088 65 'Date::Simple' => 0,
9ac2c0f8 66
67 # t/52cycle.t
82fae370 68 'Test::Memory::Cycle' => 0,
9ac2c0f8 69
c96454c3 70 # t/60core.t
71 'DateTime::Format::MySQL' => 0,
72
9d2b098e 73 # t/72pg.t
74 $ENV{DBICTEST_PG_DSN}
75 ? ('Sys::SigAction'=> 0)
76 : ()
77 ,
78
9ac2c0f8 79 # t/93storage_replication.t
ee356d00 80 'Moose', => 0.77,
0ee285f3 81 'MooseX::AttributeHelpers' => 0.12,
9901aad7 82 'MooseX::Types', => 0.10,
83 'namespace::clean' => 0.11,
b88b85e7 84 'Hash::Merge', => 0.11,
c96454c3 85
86 # t/96_is_deteministic_value.t
87 'DateTime::Format::Strptime' => 0,
fe650234 88);
89
90if ($Module::Install::AUTHOR) {
91
82fae370 92 foreach my $module (keys %force_requires_if_author) {
6882de2b 93 build_requires ($module => $force_requires_if_author{$module});
fe650234 94 }
09d46657 95
1543db24 96 system('pod2text lib/DBIx/Class.pm > README');
ff132c6f 97}
98
99auto_provides;
100
d7fda552 101if ($Module::Install::AUTHOR) {
102 warn <<'EOW';
103******************************************************************************
104******************************************************************************
105*** ***
106*** AUTHOR MODE: all optional test dependencies converted to hard requires ***
107*** ***
108******************************************************************************
109******************************************************************************
110
111EOW
112}
3e110410 113auto_install;
114
e0b438fb 115# Have all prerequisites, check DBD::SQLite sanity
713cc98e 116_check_sqlite() if (! $ENV{DBICTEST_NO_SQLITE_CHECK} );
269228af 117
713cc98e 118WriteAll();
269228af 119
713cc98e 120if ($Module::Install::AUTHOR) {
121 # Need to do this _after_ WriteAll else it loses track of them
122 Meta->{values}{build_requires} = [ grep {
123 my $ok = 1;
124 foreach my $module (keys %force_requires_if_author) {
125 if ($_->[0] =~ /$module/) {
126 $ok = 0;
127 last;
128 }
129 }
130 $ok;
131 } @{Meta->{values}{build_requires}} ];
269228af 132
713cc98e 133 Meta->{values}{resources} = [
134 [ 'MailingList', 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class' ],
135 [ 'IRC', 'irc://irc.perl.org/#dbix-class' ],
136 [ 'license', 'http://dev.perl.org/licenses/' ],
137 [ 'repository', 'http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/' ],
138 ];
139 Meta->write;
140}
269228af 141
269228af 142
713cc98e 143# This is legacy code. Latest DBD::SQLite developments fixed all known bugs
144# in this area. Remove before some arbitrary next version
145sub _check_sqlite {
e0b438fb 146
713cc98e 147 # Win32 does not have real fork()s so a segfault will bring
148 # everything down. Warn about it below, and don't try fork()
149 if ($^O ne 'MSWin32') {
150
151 my $pid = fork();
152 if (not defined $pid) {
153 die "Unable to fork(): $!";
154 }
155 elsif (! $pid) {
156 _torture_sqlite();
d1b53160 157 exit 0;
713cc98e 158 }
159 else {
76607ac8 160 eval {
161 local $SIG{ALRM} = sub { die "timeout\n" };
162 alarm 5;
163 wait();
164 alarm 0;
165 };
7a0e56cb 166 my $exception = $@;
167
e0b438fb 168 my $sig = $? & 127;
7a0e56cb 169
713cc98e 170 # make sure process actually dies
7a0e56cb 171 $exception && kill POSIX::SIGKILL(), $pid;
172
173 if ($exception || $sig == POSIX::SIGSEGV() || $sig == POSIX::SIGABRT()
3c086319 174 || $sig == 7) { # 7 == SIGBUS, haven't seen it but just in case
e0b438fb 175 warn (<<EOE);
176
3951a291 177############################### WARNING #################################
178# #
179# You are running a buggy version of DBD::SQLite known to randomly #
180# segfault on errors. Even if you have the latest CPAN module version, #
181# the sqlite3 dynamic library on this system might have been compiled #
182# against an older buggy sqlite3 dev library (oddly DBD::SQLite will #
183# prefer the system library against the one bundled with it). You are #
184# strongly advised to resolve this issue before proceeding. #
185# #
186#########################################################################
e0b438fb 187
188EOE
189 my $ans = prompt (
190 "The test suite of this module is almost certain to fail.\n"
191 . 'Do you really want to continue?',
192 'no',
193 );
a86fdee9 194
e0b438fb 195 exit 0 unless ($ans =~ /^y(es)?$/i);
196 }
713cc98e 197 }
e0b438fb 198 }
e0b438fb 199
713cc98e 200 else { # the win32 version
e0b438fb 201
713cc98e 202 print <<'EOW';
203######################################################################
204# #
205# A short stress-testing of DBD::SQLite will follow. If you have a #
206# buggy library this might very well be the last text you will see #
207# before the installation silently terminates. If this happens it #
208# would mean that you are running a buggy version of DBD::SQLite #
209# known to randomly segfault on errors. Even if you have the latest #
210# CPAN module version, the system sqlite3 dynamic library might have #
211# been compiled against an older buggy sqlite3 dev library (oddly #
212# DBD::SQLite will prefer the system library against the one bundled #
213# with it). You are strongly advised to resolve this issue before #
214# proceeding. #
215# #
216# If this happens to you (this text is the last thing you see), and #
217# you just want to install this module without worrying about the #
218# tests (which will almost certainly fail) - set the environment #
219# variable DBICTEST_NO_SQLITE_CHECK to a true value and try again. #
220# #
221######################################################################
09d46657 222
713cc98e 223EOW
09d46657 224
713cc98e 225 _torture_sqlite();
09d46657 226 }
09d46657 227}
9a3219ee 228
713cc98e 229sub _torture_sqlite {
230 require DBI;
231
232 for (1 .. 100) {
233 my $dbh = DBI->connect ('dbi:SQLite::memory:', undef, undef, {
234 AutoCommit => 1,
235 RaiseError => 0,
236 PrintError => 0,
237 }) or die "Unable to connect to database: $@";
238
239 $dbh->do ('CREATE TABLE name_with_no_columns'); # a subtle syntax error
240 $dbh->do ('COMMIT'); # followed by commit
241 $dbh->disconnect;
242 }
713cc98e 243}