Revert ab340f7f - it no longer makes sense given the excellent CI setup
[dbsrgits/DBIx-Class.git] / maint / Makefile.PL.inc / 12_authordeps.pl
CommitLineData
fc4b0448 1my ($optdep_msg, $opt_testdeps);
2
7b87b77c 3unless ($args->{with_optdeps}) {
fc4b0448 4 $optdep_msg = <<'EOW';
5
6******************************************************************************
7******************************************************************************
8*** ***
9*** IGNORING AUTHOR MODE: no optional test dependencies will be forced. ***
10*** ***
11*** If you are using this checkout with the intention of submitting a DBIC ***
7b87b77c 12*** patch you may want to aim at running more tests by re-configuring via: ***
13*** ***
14*** perl Makefile.PL --with-optdeps ***
15*** ***
16*** which will install all optional dependencies. This is not a mandatory ***
17*** step - the extensive CI setup will likely catch your mistakes anyway. ***
fc4b0448 18*** ***
19******************************************************************************
20******************************************************************************
21
22EOW
23}
24else {
25 $optdep_msg = <<'EOW';
26
27******************************************************************************
28******************************************************************************
29*** ***
7b87b77c 30*** --with-optdeps specified: converting all optional test dependencies to ***
31*** hard requires ( to disable re-run Makefile.PL without options ) ***
fc4b0448 32*** ***
33******************************************************************************
34******************************************************************************
35
36EOW
37
38 require DBIx::Class::Optional::Dependencies;
fc4b0448 39
40 # exclude the rdbms_* groups which are for DBIC users
4841171c 41 # and the moose-related stuff iff we are under 5.8.3
31c31b8d 42 $opt_testdeps = DBIx::Class::Optional::Dependencies->req_list_for([
43 grep {
4841171c 44 !/^rdbms_|^dist_/
45 and
750a4ad2 46 ( "$]" > 5.008002 or !/^ (?: test_ )? (?: admin | admin_script | replicated ) $/x )
31c31b8d 47 } keys %{DBIx::Class::Optional::Dependencies->req_group_list}
48 ]);
fc4b0448 49
7975645b 50 # this one is "special" - we need it both in optdeps and as a hard dep
51 delete $opt_testdeps->{'DBD::SQLite'};
52
fc4b0448 53 print "Including all optional deps\n";
54 $reqs->{test_requires} = {
55 %{$reqs->{test_requires}},
56 %$opt_testdeps
57 };
58}
59
60# nasty hook into both M::AI init and the prompter, so that the optdep message
61# comes at the right places (on top and then right above the prompt)
62{
63 require Module::AutoInstall;
64 no warnings 'redefine';
65 no strict 'refs';
66
67 for (qw/_prompt import/) {
68 my $meth = "Module::AutoInstall::$_";
69 my $orig = \&{$meth};
70 *{$meth} = sub {
71 print $optdep_msg;
72 goto $orig;
73 };
74 }
75}
76
77# this will run after the Makefile is written and the main Makefile.PL terminates
78#
79END {
745b54f5 80 # shit already hit the fan
81 return if $?;
82
fc4b0448 83 # Re-write META.yml at the end to _exclude_ all forced build-requires (we do not
84 # want to ship this) We are also not using M::I::AuthorRequires as this will be
85 # an extra dep, and deps in Makefile.PL still suck
86 # Also always test the result so we stop shipping borked dependency lists to CPAN
87
88 # FIXME test_requires is not yet part of META
89 my %original_build_requires = ( %$build_requires, %$test_requires );
90 my @all_build_requires = @{delete Meta->{values}{build_requires}||[]};
91 my %removed_build_requires;
92
93 for (@all_build_requires) {
94 if ($original_build_requires{$_->[0]}) {
95 push @{Meta->{values}{build_requires}}, $_;
96 }
97 else {
98 $removed_build_requires{$_->[0]} = $_->[1]
99 unless $_->[0] eq 'ExtUtils::MakeMaker';
100 }
101 }
102
103 if (keys %removed_build_requires) {
104 print "Regenerating META with author requires excluded\n";
3440100b 105 # M::I understands unicode in meta but does not write with the right
106 # layers - fhtagn!!!
107 local $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /Wide character in print/ };
fc4b0448 108 Meta->write;
109 }
110
204f57da 111 # strip possible crlf from META
112 if ($^O eq 'MSWin32' or $^O eq 'cygwin') {
113 local $ENV{PERLIO} = 'unix';
114 system( $^X, qw( -MExtUtils::Command -e dos2unix -- META.yml), );
115 }
116
fc4b0448 117 # test that we really took things away (just in case, happened twice somehow)
118 if (! -f 'META.yml') {
119 warn "No META.yml generated?! aborting...\n";
120 unlink 'Makefile';
121 exit 1;
122 }
123 my $meta = do { local @ARGV = 'META.yml'; local $/; <> };
124
90d4cbcc 125 $meta =~ /^\Qname: DBIx-Class\E$/m or do {
126 warn "Seemingly malformed META.yml...?\n";
127 unlink 'Makefile';
128 exit 1;
129 };
130
fc4b0448 131 # this is safe as there is a fatal check earlier in the main Makefile.PL
65a231a8 132 # to make sure there are no duplicates (i.e. $opt_testdeps does not contain
fc4b0448 133 # any real dependencies)
134 my @illegal_leftovers = grep
135 { $meta =~ /^ \s+ \Q$_\E \: \s+ /mx }
136 ( sort keys %$opt_testdeps )
137 ;
138
139 if (@illegal_leftovers) {
140 warn join ("\n",
141 "\n\nFATAL FAIL! It looks like some author dependencies made it to the META.yml:\n",
142 map { "\t$_" } @illegal_leftovers
143 ) . "\n\n";
144 unlink 'Makefile';
145 exit 1;
146 }
147}
148
149# keep the Makefile.PL eval happy
1501;