line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gantry::Build; |
2
|
1
|
|
|
1
|
|
947
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use base 'Module::Build'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
905
|
|
5
|
1
|
|
|
1
|
|
114391
|
use File::Find; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
85
|
|
6
|
1
|
|
|
1
|
|
1042
|
use File::Copy::Recursive qw( dircopy ); |
|
1
|
|
|
|
|
3510
|
|
|
1
|
|
|
|
|
1124
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
10
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new( @_ ); |
11
|
0
|
|
|
|
|
|
my $p = $self->{ properties }; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
print( '*' x 80, "\n" ); |
14
|
0
|
|
|
|
|
|
print( "$self->{module_name}\n" ); |
15
|
0
|
|
|
|
|
|
print( '*' x 80, "\n" ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# collect web files |
18
|
0
|
|
|
|
|
|
my( %web_dirs, @web_files ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $wanted = sub { |
21
|
0
|
|
|
0
|
|
|
my $dir = $File::Find::dir; |
22
|
0
|
|
|
|
|
|
my $file = $_; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# XXX unix specific directory work |
25
|
0
|
|
|
|
|
|
$dir =~ s![^/]*/!!; # remove extraneous leading slashes |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
return if $dir =~ /\.svn/; |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
0
|
|
|
|
push( @web_files, "$File::Find::dir/$file" ) |
30
|
|
|
|
|
|
|
if -f $file and ( $file !~ /^\.\.?$/o ); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
++$web_dirs{ $dir }; |
33
|
0
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
find( $wanted, $p->{ build_web_directory } ); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
foreach my $k ( sort { $a cmp $b } keys %web_dirs ) { |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
print "[web dir] $k\n"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$p->{ web_files } = \@web_files; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# decide where to install web content |
44
|
0
|
|
|
|
|
|
print "\n"; |
45
|
0
|
|
|
|
|
|
print "-" x 80; |
46
|
0
|
|
|
|
|
|
print "Web Directory\n"; |
47
|
0
|
|
|
|
|
|
print "-" x 80; |
48
|
0
|
|
|
|
|
|
print "\n\n"; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
print "This application has accompanying web files (like templates).\n"; |
51
|
0
|
|
|
|
|
|
print "Please choose a web servable directory for them:\n"; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $prompt; |
54
|
0
|
|
|
|
|
|
my $count = 0; |
55
|
0
|
|
|
|
|
|
my ( %dir_hash, @choices ); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
foreach my $k ( sort{ $a cmp $b } |
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
keys %{ $p->{ install_web_directories } } ) { |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$prompt .= ( |
61
|
|
|
|
|
|
|
sprintf( "%-7s: ", $k ) |
62
|
0
|
|
|
|
|
|
. $p->{ install_web_directories }{ $k } . "\n" ); |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
push( @choices, $k ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$prompt .= "Web Directory [" . join( ',', @choices ) . "]?"; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $choice = $self->prompt( $prompt ); |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $tmpl_dir; |
72
|
0
|
|
|
|
|
|
my $SKIP_TEXT = '__skip__'; |
73
|
|
|
|
|
|
|
# XXX unix specific slash test |
74
|
0
|
0
|
|
|
|
|
if ( $choice =~ /\// ) { |
|
|
0
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$tmpl_dir = $choice; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
elsif ( ! defined $p->{ install_web_directories }{ $choice } ) { |
78
|
0
|
|
|
|
|
|
$tmpl_dir = $SKIP_TEXT; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
0
|
|
|
|
|
|
$tmpl_dir = $p->{ install_web_directories }{ $choice } |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# XXX unix specific slash cleanup |
85
|
0
|
|
|
|
|
|
$tmpl_dir =~ s/\/$//g; |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
if ( ! -d $tmpl_dir ) { |
88
|
0
|
|
|
|
|
|
my $create = $self->prompt( |
89
|
|
|
|
|
|
|
"Directory doesn't exist. Create it during install [yes]?" |
90
|
|
|
|
|
|
|
); |
91
|
0
|
|
|
|
|
|
$p->{ create_web_dir } = $create; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$p->{ web_dir } = $tmpl_dir; |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return bless $self, $class; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub ACTION_code { |
100
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
101
|
0
|
|
|
|
|
|
$self->SUPER::ACTION_code(); |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
$self->add_build_element( 'web' ); |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
$self->_process_web_files( 'web' ); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub ACTION_install { |
110
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
111
|
0
|
|
|
|
|
|
$self->SUPER::ACTION_install(); |
112
|
0
|
|
|
|
|
|
my $p = $self->{properties}; |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
my $tmpl_dir = $p->{web_dir}; |
115
|
|
|
|
|
|
|
|
116
|
0
|
0
|
0
|
|
|
|
if( $tmpl_dir && $tmpl_dir ne '__skip__' ) { |
117
|
|
|
|
|
|
|
|
118
|
0
|
0
|
0
|
|
|
|
if ( not -d $tmpl_dir and $p->{ create_web_dir } =~ /^n/i ) { |
119
|
0
|
|
|
|
|
|
exit; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
eval { |
123
|
0
|
|
|
|
|
|
File::Path::mkpath( $tmpl_dir ); |
124
|
|
|
|
|
|
|
}; |
125
|
0
|
0
|
|
|
|
|
if ( $@ ) { |
126
|
0
|
|
|
|
|
|
print "Error: unable to create directory $tmpl_dir\n"; |
127
|
0
|
|
|
|
|
|
$@ =~ s/ at .+?$//; |
128
|
0
|
|
|
|
|
|
die( "$@\n" ); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
my $blib_tmpl_dir = File::Spec->catdir( |
132
|
|
|
|
|
|
|
$self->blib, 'web', $p->{build_web_directory} |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
my $num; |
136
|
0
|
|
|
|
|
|
eval { |
137
|
0
|
|
|
|
|
|
$num = dircopy($blib_tmpl_dir, $tmpl_dir); |
138
|
|
|
|
|
|
|
}; |
139
|
0
|
0
|
|
|
|
|
if ( $@ ) { |
140
|
0
|
|
|
|
|
|
print "Error coping templates:\n"; |
141
|
0
|
|
|
|
|
|
print $@ . "\n"; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
else { |
144
|
0
|
|
|
|
|
|
print "Web content copied: $num\n"; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
else { |
148
|
0
|
|
|
|
|
|
print "SKIPPING WEB CONTENT INSTALL\n"; |
149
|
|
|
|
|
|
|
} |
150
|
0
|
|
|
|
|
|
print "-" x 80; |
151
|
0
|
|
|
|
|
|
print "\n"; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
} # end ACTION_install |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub _process_web_files { |
156
|
0
|
|
|
0
|
|
|
my $self = shift; |
157
|
0
|
|
|
|
|
|
my $p = $self->{properties}; |
158
|
0
|
|
|
|
|
|
my $files = $p->{web_files}; |
159
|
|
|
|
|
|
|
|
160
|
0
|
0
|
|
|
|
|
return unless @$files; |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
my $tmpl_dir = File::Spec->catdir($self->blib, 'web'); |
163
|
0
|
|
|
|
|
|
File::Path::mkpath( $tmpl_dir ); |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
foreach my $file (@$files) { |
166
|
0
|
|
|
|
|
|
my $result = $self->copy_if_modified("$file", $tmpl_dir); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 NAME |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Gantry::Build - a Module::Build subclass for Gantry apps |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 SYNOPSIS |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Sample Build.PL: |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
use strict; |
181
|
|
|
|
|
|
|
use Gantry::Build; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
my $build = Gantry::Build->new( |
184
|
|
|
|
|
|
|
build_web_directory => 'html', |
185
|
|
|
|
|
|
|
install_web_directories => { |
186
|
|
|
|
|
|
|
# XXX unix specific paths |
187
|
|
|
|
|
|
|
'dev' => '/home/httpd/html/Contact', |
188
|
|
|
|
|
|
|
'qual' => '/home/httpd/html/Contact', |
189
|
|
|
|
|
|
|
'prod' => '/home/httpd/html/Contact', |
190
|
|
|
|
|
|
|
}, |
191
|
|
|
|
|
|
|
create_makefile_pl => 'passthrough', |
192
|
|
|
|
|
|
|
license => 'perl', |
193
|
|
|
|
|
|
|
module_name => 'Contact', |
194
|
|
|
|
|
|
|
requires => { |
195
|
|
|
|
|
|
|
'perl' => '5', |
196
|
|
|
|
|
|
|
'Gantry' => '3.0', |
197
|
|
|
|
|
|
|
'HTML::Prototype' => '0', |
198
|
|
|
|
|
|
|
}, |
199
|
|
|
|
|
|
|
create_makefile_pl => 'passthrough', |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# XXX unix specific paths |
202
|
|
|
|
|
|
|
script_files => [ glob('bin/*') ], |
203
|
|
|
|
|
|
|
'recursive_test_files' => 1, |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# XXX unix specific paths |
206
|
|
|
|
|
|
|
install_path => { script => '/usr/local/bin' }, |
207
|
|
|
|
|
|
|
); |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
$build->create_build_script; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 DESCRIPTION |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Use this module instead of Module::Build (which it subclasses). Use |
214
|
|
|
|
|
|
|
any or all of the Module::Build constructor keys as needed. Include these |
215
|
|
|
|
|
|
|
keys to make the module sing: |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=over 4 |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=item build_web_directory |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Usually C. This is the top level directory of your web content. |
222
|
|
|
|
|
|
|
Put your content in subdirectories of this dir. Example: if you |
223
|
|
|
|
|
|
|
are in the build directory (the one where Build.PL lives), your templates |
224
|
|
|
|
|
|
|
should live in C. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item install_web_directories |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
This is a hash reference. The keys are what installing users will type, |
229
|
|
|
|
|
|
|
values are where the content from C subdirectories |
230
|
|
|
|
|
|
|
will go. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=back |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 METHODS |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Except new, these methods are all internal or for use by Module::Build. |
237
|
|
|
|
|
|
|
They are documented to keep POD tests happy. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=over 4 |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=item new |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Just like Module::Build->new, but takes the extra parameters shown in the |
244
|
|
|
|
|
|
|
DESCRIPTION above. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=item ACTION_code |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Standard Module::Build routine. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=item ACTION_install |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Standard Module::Build routine. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=back |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 AUTHOR |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Phil Crow Ephilcrow2000@yahoo.comE |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Tim Keefer Etkeefer@gmail.comE |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head1 COPYRIGHT and LICENSE |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
Copyright (C) 2005-6 by Phil Crow |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
267
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.6 or, |
268
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=cut |