14 @ISA = qw(Module::Build);
17 sub process_script_files {
19 my $files = $self->find_script_files();
20 return unless keys %$files;
22 my $script_dir = File::Spec->catdir($self->blib, 'script');
23 my $demo_dir = File::Spec->catdir($self->blib, 'demo');
24 File::Path::mkpath( $script_dir );
25 File::Path::mkpath( $demo_dir );
26 $self->add_to_cleanup($demo_dir);
28 foreach my $file (keys %$files) {
29 my $dest_dir = $file =~ /_demo$/ ? $demo_dir : $script_dir ;
30 my $result = $self->copy_if_modified($file, $dest_dir, 'flatten') or next;
31 $self->fix_shebang_line($result) if $self->is_unixish();
32 $self->make_executable($result);
33 my $demo_run_dir = File::Spec->catdir($self->base_dir(), 'demo');
34 if ( $result =~ /(?:run_stem$)|(?:_demo$)/ ) {
35 my $result2 = $self->copy_if_modified($result, $demo_run_dir, 'flatten') or next;
36 $self->add_to_cleanup($result2);
42 sub process_conf_files {
44 my $files = $self->_find_file_by_type('stem','conf');
45 return unless keys %$files;
47 my $conf_dir = File::Spec->catdir($self->blib, 'conf');
48 File::Path::mkpath( $conf_dir );
50 foreach my $file (keys %$files) {
51 my $result = $self->copy_if_modified($file, $conf_dir, 'flatten') or next;
52 $self->fix_shebang_line($result) if $self->is_unixish();
58 my ( $self, $prog ) = @_ ;
59 if ( $self->do_system( "which $prog >/dev/null" ) ) {
60 return `which $prog` ;
66 ###########################################################
67 # Various convenience routines.
69 # To use ACTION_foo, call ./Build foo
73 # ACTION: grep through MANIFEST
77 # do we need this action?
80 sub ACTION_grep_manifest {
84 my @manifest_sublist = $self->grep_manifest() ;
86 print join( "\n", @manifest_sublist ), "\n" ;
92 # grep through all matched files
94 # files=<regex> (default is all .pm files)
101 my $args = $self->{'args'} ;
103 my $file_regex = $args->{ files } || qr/\.pm$/ ;
104 my $grep_regex = $args->{ re } or die "need grep regex" ;
106 my @manifest_sublist = $self->grep_manifest( $file_regex ) ;
108 local( @ARGV ) = @manifest_sublist ;
112 next unless /$grep_regex/ ;
124 my ( @manifest_lines ) ;
126 # MANIFEST helper subs
130 my( $self, $file_regex ) = @_ ;
132 $file_regex ||= $self->{ args }{ files } || qr/.*/ ;
136 return grep( /$file_regex/, @manifest_lines ) ;
141 return if @manifest_lines ;
143 @manifest_lines = grep ! /^\s*$|^\s*#/, read_file( 'MANIFEST' ) ;
145 chomp @manifest_lines ;
152 my ( $file_name ) = @_ ;
156 open( FH, $file_name ) || die "Can't open $file_name $!";
158 return <FH> if wantarray;
160 read FH, my $buf, -s FH;