Apparently -i and -jN do not work on win32, what the hell
[dbsrgits/DBIx-Class.git] / maint / Makefile.PL.inc / 53_autogen_pod.pl
CommitLineData
95252a8c 1use File::Path();
2use File::Glob();
3
a14c7707 4# leftovers in old checkouts
5unlink 'lib/DBIx/Class/Optional/Dependencies.pod'
6 if -f 'lib/DBIx/Class/Optional/Dependencies.pod';
aff5e9c1 7File::Path::rmtree([ '.generated_pod' ])
95252a8c 8 if -d '.generated_pod';
a14c7707 9
95252a8c 10my $pod_dir = 'maint/.Generated_Pod';
a14c7707 11my $ver = Meta->version;
12
13# cleanup the generated pod dir (again - kill leftovers from old checkouts)
95252a8c 14if (-d $pod_dir) {
aff5e9c1 15 File::Path::rmtree([ File::Glob::bsd_glob("$pod_dir/*") ]);
95252a8c 16}
17else {
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 32clonedir_generate_files : dbic_clonedir_gen_optdeps_pod
a14c7707 33
34dbic_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
39EOP
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);
b8a27054 59 local $0 = 'dbicadmin';
4a51243f 60 local *CORE::GLOBAL::exit = sub { $great_success++; die; };
61 do 'script/dbicadmin';
62 }
63 if (!$great_success and ($@ || $!) ) {
64 printf ("FAILED!!! Subsequent `make dist` will fail. %s\n",
65 $ENV{DBICDIST_DEBUG}
66 ? 'Full error: ' . ($@ || $!)
67 : 'Re-run with $ENV{DBICDIST_DEBUG} set for more info'
68 );
69 }
e2633789 70
71 postamble <<"EOP";
72
73clonedir_generate_files : dbic_clonedir_gen_dbicadmin_pod
74
75dbic_clonedir_gen_dbicadmin_pod :
76\t\$(ABSPERLRUN) -Ilib -- script/dbicadmin --documentation-as-pod @{[ $mm_proto->quote_literal($pod_fn) ]}
77
78EOP
79}
80
81
4a51243f 82# generate the inherit pods only during distbuilding phase
83# it is too slow to do at regular Makefile.PL
a14c7707 84{
a14c7707 85 postamble <<"EOP";
86
a0c96f24 87clonedir_generate_files : dbic_clonedir_gen_inherit_pods
a14c7707 88
89dbic_clonedir_gen_inherit_pods :
a0c96f24 90\t\$(ABSPERLRUN) -Ilib maint/gen_pod_inherit
91
92EOP
93}
94
95
3440100b 96# generate the DBIx/Class.pod only during distdir
97{
aff5e9c1 98 my $dist_pod_fn = "$pod_dir/lib/DBIx/Class.pod";
3440100b 99
100 postamble <<"EOP";
101
102clonedir_generate_files : dbic_distdir_gen_dbic_pod
103
104dbic_distdir_gen_dbic_pod :
105
106\tperldoc -u lib/DBIx/Class.pm > $dist_pod_fn
107\t@{[ $mm_proto->oneliner(
1fb834df 108 "s!^.*?this line is replaced with the author list.*! qq{List of the awesome contributors who made DBIC v$ver possible\\n\\n} . qx(\$^X -Ilib maint/gen_pod_authors)!me",
109 [qw( -0777 -p -i.arghwin32 )]
3440100b 110) ]} $dist_pod_fn
1fb834df 111\t\$(RM_F) $dist_pod_fn.arghwin32
3440100b 112
113create_distdir : dbic_distdir_defang_authors
114
115# Remove the maintainer-only warning (be nice ;)
116dbic_distdir_defang_authors :
1fb834df 117\t@{[ $mm_proto->oneliner('s/ ^ \s* \# \s* \*\*\* .+ \n ( ^ \s* \# \s*? \n )? //xmg', [qw( -0777 -p -i.arghwin32 )] ) ]} \$(DISTVNAME)/AUTHORS
118@{[ $crlf_fixup->( '$(DISTVNAME)/AUTHORS' ) ]}
119\t\$(RM_F) \$(DISTVNAME)/AUTHORS.arghwin32
3440100b 120
121EOP
122}
123
124
204f57da 125# on some OSes generated files may have an incorrect \n - fix it
126# so that the xt tests pass on a fresh checkout (also shipping a
127# dist with CRLFs is beyond obnoxious)
204f57da 128if ($^O eq 'MSWin32' or $^O eq 'cygwin') {
204f57da 129 {
130 local $ENV{PERLIO} = 'unix';
131 system( $^X, qw( -MExtUtils::Command -e dos2unix -- ), $pod_dir );
132 }
133
134 postamble <<"EOP";
135
ffce4b65 136clonedir_post_generate_files : pod_crlf_fixup
204f57da 137
ffce4b65 138pod_crlf_fixup :
139@{[ $crlf_fixup->($pod_dir) ]}
204f57da 140
141EOP
142}
143
a0c96f24 144{
145 postamble <<"EOP";
146
147clonedir_post_generate_files : dbic_clonedir_copy_generated_pod
148
149dbic_clonedir_copy_generated_pod :
95252a8c 150\t\$(RM_F) $pod_dir.packlist
3ba58fe4 151\t@{[
aff5e9c1 152 $mm_proto->oneliner("install([ from_to => {q($pod_dir) => './', write => q($pod_dir.packlist)}, verbose => 0, uninstall_shadows => 0, skip => [] ])", ['-MExtUtils::Install'])
3ba58fe4 153]}
ffce4b65 154
a0c96f24 155EOP
156}
157
158
3e2a5d5d 159# everything that came from $pod_dir, needs to be removed from the workdir
a0c96f24 160{
161 postamble <<"EOP";
162
163clonedir_cleanup_generated_files : dbic_clonedir_cleanup_generated_pod_copies
164
165dbic_clonedir_cleanup_generated_pod_copies :
ad944588 166\t@{[ $mm_proto->oneliner('chomp && unlink || die', ['-n']) ]} $pod_dir.packlist
167\t\$(RM_F) $pod_dir.packlist
a14c7707 168
169EOP
170}
171
172# keep the Makefile.PL eval happy
1731;