Commit | Line | Data |
fc4b0448 |
1 | my ($optdep_msg, $opt_testdeps); |
2 | |
3 | if ($args->{skip_author_deps}) { |
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 *** |
12 | *** patch, you are *STRONGLY ENCOURAGED* to install all dependencies, so *** |
13 | *** that every possible unit-test will run. *** |
14 | *** *** |
15 | ****************************************************************************** |
16 | ****************************************************************************** |
17 | |
18 | EOW |
19 | } |
20 | else { |
21 | $optdep_msg = <<'EOW'; |
22 | |
23 | ****************************************************************************** |
24 | ****************************************************************************** |
25 | *** *** |
26 | *** AUTHOR MODE: all optional test dependencies converted to hard requires *** |
df65d4da |
27 | *** ( to disable re-run Makefile.PL with --skip-author-deps ) *** |
fc4b0448 |
28 | *** *** |
29 | ****************************************************************************** |
30 | ****************************************************************************** |
31 | |
32 | EOW |
33 | |
34 | require DBIx::Class::Optional::Dependencies; |
35 | my %reqs_for_group = %{DBIx::Class::Optional::Dependencies->req_group_list}; |
36 | |
37 | # exclude the rdbms_* groups which are for DBIC users |
38 | $opt_testdeps = { |
344f1f52 |
39 | map { %{$reqs_for_group{$_}} } grep { !/^rdbms_|^dist_/ } keys %reqs_for_group |
fc4b0448 |
40 | }; |
41 | |
42 | print "Including all optional deps\n"; |
43 | $reqs->{test_requires} = { |
44 | %{$reqs->{test_requires}}, |
45 | %$opt_testdeps |
46 | }; |
47 | } |
48 | |
49 | # nasty hook into both M::AI init and the prompter, so that the optdep message |
50 | # comes at the right places (on top and then right above the prompt) |
51 | { |
52 | require Module::AutoInstall; |
53 | no warnings 'redefine'; |
54 | no strict 'refs'; |
55 | |
56 | for (qw/_prompt import/) { |
57 | my $meth = "Module::AutoInstall::$_"; |
58 | my $orig = \&{$meth}; |
59 | *{$meth} = sub { |
60 | print $optdep_msg; |
61 | goto $orig; |
62 | }; |
63 | } |
64 | } |
65 | |
66 | # this will run after the Makefile is written and the main Makefile.PL terminates |
67 | # |
68 | END { |
745b54f5 |
69 | # shit already hit the fan |
70 | return if $?; |
71 | |
fc4b0448 |
72 | # Re-write META.yml at the end to _exclude_ all forced build-requires (we do not |
73 | # want to ship this) We are also not using M::I::AuthorRequires as this will be |
74 | # an extra dep, and deps in Makefile.PL still suck |
75 | # Also always test the result so we stop shipping borked dependency lists to CPAN |
76 | |
77 | # FIXME test_requires is not yet part of META |
78 | my %original_build_requires = ( %$build_requires, %$test_requires ); |
79 | my @all_build_requires = @{delete Meta->{values}{build_requires}||[]}; |
80 | my %removed_build_requires; |
81 | |
82 | for (@all_build_requires) { |
83 | if ($original_build_requires{$_->[0]}) { |
84 | push @{Meta->{values}{build_requires}}, $_; |
85 | } |
86 | else { |
87 | $removed_build_requires{$_->[0]} = $_->[1] |
88 | unless $_->[0] eq 'ExtUtils::MakeMaker'; |
89 | } |
90 | } |
91 | |
92 | if (keys %removed_build_requires) { |
93 | print "Regenerating META with author requires excluded\n"; |
94 | Meta->write; |
95 | } |
96 | |
204f57da |
97 | # strip possible crlf from META |
98 | if ($^O eq 'MSWin32' or $^O eq 'cygwin') { |
99 | local $ENV{PERLIO} = 'unix'; |
100 | system( $^X, qw( -MExtUtils::Command -e dos2unix -- META.yml), ); |
101 | } |
102 | |
fc4b0448 |
103 | # test that we really took things away (just in case, happened twice somehow) |
104 | if (! -f 'META.yml') { |
105 | warn "No META.yml generated?! aborting...\n"; |
106 | unlink 'Makefile'; |
107 | exit 1; |
108 | } |
109 | my $meta = do { local @ARGV = 'META.yml'; local $/; <> }; |
110 | |
111 | # this is safe as there is a fatal check earlier in the main Makefile.PL |
65a231a8 |
112 | # to make sure there are no duplicates (i.e. $opt_testdeps does not contain |
fc4b0448 |
113 | # any real dependencies) |
114 | my @illegal_leftovers = grep |
115 | { $meta =~ /^ \s+ \Q$_\E \: \s+ /mx } |
116 | ( sort keys %$opt_testdeps ) |
117 | ; |
118 | |
119 | if (@illegal_leftovers) { |
120 | warn join ("\n", |
121 | "\n\nFATAL FAIL! It looks like some author dependencies made it to the META.yml:\n", |
122 | map { "\t$_" } @illegal_leftovers |
123 | ) . "\n\n"; |
124 | unlink 'Makefile'; |
125 | exit 1; |
126 | } |
127 | } |
128 | |
129 | # keep the Makefile.PL eval happy |
130 | 1; |