Commit | Line | Data |
95252a8c |
1 | use File::Path(); |
2 | use File::Glob(); |
3 | |
a14c7707 |
4 | # leftovers in old checkouts |
5 | unlink 'lib/DBIx/Class/Optional/Dependencies.pod' |
6 | if -f 'lib/DBIx/Class/Optional/Dependencies.pod'; |
95252a8c |
7 | File::Path::rmtree( File::Glob::bsd_glob('.generated_pod'), { verbose => 0 } ) |
8 | if -d '.generated_pod'; |
a14c7707 |
9 | |
95252a8c |
10 | my $pod_dir = 'maint/.Generated_Pod'; |
a14c7707 |
11 | my $ver = Meta->version; |
12 | |
13 | # cleanup the generated pod dir (again - kill leftovers from old checkouts) |
95252a8c |
14 | if (-d $pod_dir) { |
15 | File::Path::rmtree( File::Glob::bsd_glob("$pod_dir/*"), { verbose => 0 } ); |
16 | } |
17 | else { |
18 | mkdir $pod_dir or die "Unable to create $pod_dir: $!"; |
19 | } |
a14c7707 |
20 | |
21 | # generate the OptDeps pod both in the clone-dir and during the makefile distdir |
22 | { |
23 | print "Regenerating Optional/Dependencies.pod\n"; |
4a51243f |
24 | |
25 | # this should always succeed - hence no error checking |
26 | # if someone breaks OptDeps - travis should catch it |
a14c7707 |
27 | require DBIx::Class::Optional::Dependencies; |
3e2a5d5d |
28 | DBIx::Class::Optional::Dependencies->_gen_pod ($ver, "$pod_dir/lib"); |
a14c7707 |
29 | |
30 | postamble <<"EOP"; |
31 | |
a0c96f24 |
32 | clonedir_generate_files : dbic_clonedir_gen_optdeps_pod |
a14c7707 |
33 | |
34 | dbic_clonedir_gen_optdeps_pod : |
3ba58fe4 |
35 | \t@{[ |
3e2a5d5d |
36 | $mm_proto->oneliner("DBIx::Class::Optional::Dependencies->_gen_pod(q($ver), q($pod_dir/lib))", [qw/-Ilib -MDBIx::Class::Optional::Dependencies/]) |
3ba58fe4 |
37 | ]} |
a14c7707 |
38 | |
39 | EOP |
40 | } |
41 | |
a0c96f24 |
42 | |
e2633789 |
43 | # generate the script/dbicadmin pod |
44 | { |
45 | print "Regenerating script/dbicadmin.pod\n"; |
46 | |
47 | # generating it in the root of $pod_dir |
48 | # it will *not* be copied over due to not being listed at the top |
49 | # of MANIFEST.SKIP - this is a *good* thing |
50 | # we only want to ship a script/dbicadmin, with the POD appended |
51 | # (see inject_dbicadmin_pod.pl), but still want to spellcheck and |
52 | # whatnot the intermediate step |
53 | my $pod_fn = "$pod_dir/dbicadmin.pod"; |
54 | |
55 | # if the author doesn't have the prereqs, don't fail the initial "perl Makefile.pl" step |
4a51243f |
56 | my $great_success; |
57 | { |
58 | local @ARGV = ('--documentation-as-pod', $pod_fn); |
59 | local *CORE::GLOBAL::exit = sub { $great_success++; die; }; |
60 | do 'script/dbicadmin'; |
61 | } |
62 | if (!$great_success and ($@ || $!) ) { |
63 | printf ("FAILED!!! Subsequent `make dist` will fail. %s\n", |
64 | $ENV{DBICDIST_DEBUG} |
65 | ? 'Full error: ' . ($@ || $!) |
66 | : 'Re-run with $ENV{DBICDIST_DEBUG} set for more info' |
67 | ); |
68 | } |
e2633789 |
69 | |
70 | postamble <<"EOP"; |
71 | |
72 | clonedir_generate_files : dbic_clonedir_gen_dbicadmin_pod |
73 | |
74 | dbic_clonedir_gen_dbicadmin_pod : |
75 | \t\$(ABSPERLRUN) -Ilib -- script/dbicadmin --documentation-as-pod @{[ $mm_proto->quote_literal($pod_fn) ]} |
76 | |
77 | EOP |
78 | } |
79 | |
80 | |
4a51243f |
81 | # generate the inherit pods only during distbuilding phase |
82 | # it is too slow to do at regular Makefile.PL |
a14c7707 |
83 | { |
a14c7707 |
84 | postamble <<"EOP"; |
85 | |
a0c96f24 |
86 | clonedir_generate_files : dbic_clonedir_gen_inherit_pods |
a14c7707 |
87 | |
88 | dbic_clonedir_gen_inherit_pods : |
a0c96f24 |
89 | \t\$(ABSPERLRUN) -Ilib maint/gen_pod_inherit |
90 | |
91 | EOP |
92 | } |
93 | |
94 | |
204f57da |
95 | # on some OSes generated files may have an incorrect \n - fix it |
96 | # so that the xt tests pass on a fresh checkout (also shipping a |
97 | # dist with CRLFs is beyond obnoxious) |
204f57da |
98 | if ($^O eq 'MSWin32' or $^O eq 'cygwin') { |
204f57da |
99 | { |
100 | local $ENV{PERLIO} = 'unix'; |
101 | system( $^X, qw( -MExtUtils::Command -e dos2unix -- ), $pod_dir ); |
102 | } |
103 | |
104 | postamble <<"EOP"; |
105 | |
ffce4b65 |
106 | clonedir_post_generate_files : pod_crlf_fixup |
204f57da |
107 | |
ffce4b65 |
108 | pod_crlf_fixup : |
109 | @{[ $crlf_fixup->($pod_dir) ]} |
204f57da |
110 | |
111 | EOP |
112 | } |
113 | |
a0c96f24 |
114 | { |
115 | postamble <<"EOP"; |
116 | |
117 | clonedir_post_generate_files : dbic_clonedir_copy_generated_pod |
118 | |
119 | dbic_clonedir_copy_generated_pod : |
95252a8c |
120 | \t\$(RM_F) $pod_dir.packlist |
3ba58fe4 |
121 | \t@{[ |
3e2a5d5d |
122 | $mm_proto->oneliner("install([ from_to => {q($pod_dir) => File::Spec->curdir(), write => q($pod_dir.packlist)}, verbose => 0, uninstall_shadows => 0, skip => [] ])", ['-MExtUtils::Install']) |
3ba58fe4 |
123 | ]} |
ffce4b65 |
124 | |
a0c96f24 |
125 | EOP |
126 | } |
127 | |
128 | |
3e2a5d5d |
129 | # everything that came from $pod_dir, needs to be removed from the workdir |
a0c96f24 |
130 | { |
131 | postamble <<"EOP"; |
132 | |
133 | clonedir_cleanup_generated_files : dbic_clonedir_cleanup_generated_pod_copies |
134 | |
135 | dbic_clonedir_cleanup_generated_pod_copies : |
ad944588 |
136 | \t@{[ $mm_proto->oneliner('chomp && unlink || die', ['-n']) ]} $pod_dir.packlist |
137 | \t\$(RM_F) $pod_dir.packlist |
a14c7707 |
138 | |
139 | EOP |
140 | } |
141 | |
142 | # keep the Makefile.PL eval happy |
143 | 1; |