-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.PL
executable file
·126 lines (109 loc) · 3.34 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/env perl
use 5.006;
use strict;
use warnings;
use Module::Build;
use File::Spec::Functions qw( catfile );
Module::Build->VERSION( '0.4004' );
my $class = Module::Build->subclass(
code => q{
use Perl::OSType qw(os_type);
use Cwd qw( cwd );
#---------------------------------
# Build
#---------------------------------
sub ACTION_build {
my ($s) = @_;
$s->_readme();
$s->SUPER::ACTION_build;
}
# Only for the maintainer on "Build build".
sub _readme {
my ($s) = @_;
return if cwd() !~ m{ / git / perlmy / [^/]+ $ }x;
my ($installed) =
grep { -x "$_/pod2markdown" }
split /:/, $ENV{PATH};
return if !$installed;
print "Building README\n";
my $lib = $s->{properties}{dist_version_from};
system "pod2markdown $lib > README.md";
}
#---------------------------------
# Install
#---------------------------------
sub ACTION_install {
my ($s) = @_;
$s->_clear_cache;
$s->_check_for_source_command if os_type eq "Unix";
$s->SUPER::ACTION_install;
}
sub ACTION_clean {
my ($s) = @_;
$s->_clear_cache;
$s->SUPER::ACTION_clean;
}
sub ACTION_test {
my ($s) = @_;
$s->_clear_cache;
$s->SUPER::ACTION_test;
}
sub _clear_cache {
my $home = $ENV{HOME} // $ENV{USERPROFILE} // $ENV{LOGDIR};
for ( glob qq("$home/.cache/my_pod*.cache") ) {
print "Removing: $_\n";
unlink or warn $!;
}
}
sub _check_for_source_command {
my $file = "bash_completion_pod";
my $path = qx(which $file);
chomp $path;
if ( not $ENV{MY_POD_CACHE} and $path ) {
print <<ECHO
Add this to your bashrc file (or compatible):
[ "\$(which $file)" != "" ] && source $file
Or this one (if $file is not in your PATH):
[ -f "$path" ] && source $path
ECHO
}
}
},
);
my $builder = $class->new(
module_name => 'App::Pod',
license => 'artistic_2',
dist_author => q{Tim Potapov <tim.potapov[AT]gmail.com>},
dist_version_from => 'lib/App/Pod.pm',
release_status => 'stable',
configure_requires => {
'Module::Build' => '0.4004',
},
test_requires => {
'Test::More' => '0',
},
requires => {
'perl' => '5.024',
'Module::Functions' => '2.1.3',
'File::HomeDir' => '1.006',
'Mojo::File' => '0',
'Mojo::JSON' => '0',
'Pod::Query' => '0.32',
},
add_to_cleanup => [
'App-Pod-*',
'MANIFEST*.bak',
'pod2htmd.tmp',
'blib/',
sprintf( "%s/.cache/my_pod*.cache",
$ENV{HOME} // $ENV{USEPROFILE}
// catfile( $ENV{HOMEDRIVE}, $ENV{HOMEPATH}, '' ) ),
],
meta_merge => {
resources => {
bugtracker => 'https://github.com/poti1/app-pod/issues',
repository => 'https://github.com/poti1/app-pod',
},
},
);
$builder->create_build_script();