-
Notifications
You must be signed in to change notification settings - Fork 1
/
Build.PL
108 lines (96 loc) · 3.86 KB
/
Build.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#
# Copyright (C) 2018-19 Matthew Leingang <[email protected]>
#
# This file is part of AMC-ItemAnalysis
#
# AMC-ItemAnalysis is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# AMC-ItemAnalysis is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with AMC-ItemAnalysis. If not, see <https://www.gnu.org/licenses/>.
use 5.008;
use strict;
use warnings;
use Module::Build;
use Software::License;
use FindBin qw($RealBin);
use lib $RealBin . "/lib";
use AMC::Plugin::Build;
my $class = AMC::Plugin::Build->subclass(code => q(
# Subclass Module::Build to add a `librst` command that will generate
# reStructuredText files from the project's POD documentation.
use strict;
use warnings;
use File::Basename qw(fileparse);
use File::Find;
use File::Spec;
use File::Path qw(make_path);
use Pod::POM;
use Pod::POM::View::Restructured;
our $parser = Pod::POM->new();
our $docroot = 'doc'; # TODO: get from project configuration
sub make_rst {
# Callback for find() to convert any POD in a file to an .rst file.
# The POD can be a regular Perl file or a separate .pod file, but
# not both (e.g. if Foo.pod exists, Foo.pm should not contain any
# POD).
return if -d $_;
my $pom = $parser->parse_file($_);
return if not @{$pom->content()};
my $rst = $pom->present(new Pod::POM::View::Restructured->new());
my $rst_path = File::Spec->catfile($docroot,$_);
# $rst_path =~ s/$File::Find::dir/$docroot/; # path
$rst_path =~ s/\.[^\.]*$/.rst/; # file extension
my ($basename, $directories) = fileparse $rst_path;
if (! -d $directories) { make_path $directories or die "Failed to create path: $directories";}
open (my $stream, '>:utf8', $rst_path) or die "Failed to open stream: $rst_path";
print $stream $rst;
close $stream;
print "Documentation written to $rst_path\n";
}
sub ACTION_librst {
find({wanted => \&make_rst, no_chdir => 1}, 'lib/');
}
));
my $prefix = $ENV{HOME} . "/.AMC.d/plugins/ItemAnalysis";
my $builder = $class->new(
module_name => 'AMC::ItemAnalysis',
license => 'GPL_3',
dist_author => q(Matthew Leingang <[email protected]>),
dist_version_from => 'lib/AMC/ItemAnalysis.pm',
release_status => 'unstable',
configure_requires => {
'Pod::POM' => 0,
'Pod::POM::View::Restructured' => 0, # required for `librst` action
# need subclass() method and license declaration by Software::License subclass
'Module::Build' => 0.36_14,
},
# nifty one-liner to search test files for modules used:
# egrep -h "^use " t/*.t xt/*.t | cut -f 2 -d' ' | sort | uniq
test_requires => {
'perl' => '!= 5.6.0, != 5.6.1, != 5.6.2', # Text::CSV::header does not work in perl-5.6.x (says POD)
'File::Spec' => 0,
'File::Temp' => 0,
'FindBin' => 0,
'Test::More' => 0,
'Text::CSV' => 0,
'Data::Dumper' => 0,
'Archive::Tar' => 0,
'List::Util' => 0 # Needs max
},
requires => {
'List::Util' => 0 # Needs sum
},
add_to_cleanup => ['_build/', 'blib/', 'MYMETA.*', 'AMC-ItemAnalysis-*'],
create_makefile_pl => 'small',
create_packlist => 0,
install_base => $prefix,
install_path => { lib => $prefix . '/perl' });
$builder->create_build_script();