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