Use built in mechanism to generate scripts with docs rather than home-brew routine

This commit is contained in:
Duncan Ferguson 2014-05-29 11:24:24 +01:00
parent 671c231992
commit 5b71abdcce
10 changed files with 90 additions and 45 deletions

1
.gitignore vendored
View file

@ -6,6 +6,7 @@ MYMETA.json
MYMETA.yml
Makefile
_build/
bin
blib/
cover_db/
pm_to_blib

View file

@ -45,46 +45,46 @@ EOF
return $self;
}
sub ACTION_build {
my ($self, @args) = @_;
print "Building pod files",$/;
# my $common_file = File::Slurp::read_file('pod_data/common_file');
# die "Failed to read 'pod_data/common_file'" unless($common_file);
# Each file in bin/ should have a file within pod_data.
# If not, there is a problem.
my @files=glob('bin/*');
foreach my $binfile (@files) {
# ignore any dirs or such in the bin directory
next unless(-f $binfile && -x $binfile);
# (my $podfile = $binfile) =~ s!bin!pod_data!;
# warn "checking $podfile",$/;
#
# if(!-f $podfile) {
# warn "$podfile does not exist",$/;
# next;
# }
# my $pod = read_file( $podfile );
# warn "Unable to read '$podfile'" unless ($pod);
#
# $pod =~ s/%FILES%/$common_file/;
#
# my $options = qx{ $binfile -h 2>&1 };
# warn "Unable to run '$binfile -h'" unless ($options);
my $cmd="$binfile --generate-pod 2>&1";
warn "Running: $cmd",$/;
my $pod = qx { $cmd };
die "Failed to generate POD" if($?);
write_file("${binfile}.pod", $pod);
}
$self->SUPER::ACTION_build;
}
#%# sub ACTION_build {
#%# my ($self, @args) = @_;
#%#
#%# print "Building pod files",$/;
#%#
#%## my $common_file = File::Slurp::read_file('pod_data/common_file');
#%## die "Failed to read 'pod_data/common_file'" unless($common_file);
#%#
#%# # Each file in bin/ should have a file within pod_data.
#%# # If not, there is a problem.
#%# my @files=glob('bin/*');
#%# foreach my $binfile (@files) {
#%# # ignore any dirs or such in the bin directory
#%# next unless(-f $binfile && -x $binfile);
#%#
#%## (my $podfile = $binfile) =~ s!bin!pod_data!;
#%## warn "checking $podfile",$/;
#%##
#%## if(!-f $podfile) {
#%## warn "$podfile does not exist",$/;
#%## next;
#%## }
#%## my $pod = read_file( $podfile );
##%# warn "Unable to read '$podfile'" unless ($pod);
#%##
#%## $pod =~ s/%FILES%/$common_file/;
#%##
#%## my $options = qx{ $binfile -h 2>&1 };
#%## warn "Unable to run '$binfile -h'" unless ($options);
#%#
#%# my $cmd="$binfile --generate-pod 2>&1";
#%# warn "Running: $cmd",$/;
#%# my $pod = qx { $cmd };
#%# die "Failed to generate POD" if($?);
#%# write_file("${binfile}.pod", $pod);
#%#
#%# }
#%#
#%# $self->SUPER::ACTION_build;
#%# }
},
);
@ -128,6 +128,9 @@ my $build = $class->new(
create_makefile_pl => 'traditional',
script_files => 'bin',
get_options => { changes => { type => '=s' }, },
PL_files => {
'bin_PL/_build_docs' => [],
},
);
$build->create_build_script;

View file

@ -1,9 +1,9 @@
AUTHORS
bin/ccon
bin/crsh
bin/cscp.x
bin/cssh
bin/ctel
bin_PL/ccon
bin_PL/crsh
bin_PL/cscp.x
bin_PL/cssh
bin_PL/ctel
Build.PL
Changes
lib/App/ClusterSSH.pm

View file

@ -14,3 +14,4 @@ pm_to_blib
.*\.swp$
^TOAD$
^WIP_TASKS$
^bin/

40
bin_PL/_build_docs Executable file
View file

@ -0,0 +1,40 @@
#!/usr/bin/perl
use strict;
use warnings;
use FindBin qw($Bin $Script);
chdir $Bin || die "Unable to chdir into $Bin: $!";
my $bindir="$Bin/../bin";
if(! -d $bindir) {
mkdir $bindir || die "Could not mkdir $bindir: $!";
}
for my $source (glob("*")) {
my $dest="$bindir/$source";
next if($source =~ m/$Script/);
next if($source =~ m/\.x$/);
print "Generating: $source",$/;
if($dest) {
chmod(0777, $dest) || die "Could not chmod $dest for removing: $!";
}
open(my $sfh, '<', $source) || die "Could not open $source for reading: $!";
open(my $dfh, '>', $dest ) || die "Could not open $dest for writing: $!";
print $dfh $_ while(<$sfh>);
close($sfh);
print $dfh "\n\n__END__\n\n";
my $pod= qx{ ./$source --generate-pod };
print $dfh $pod;
close($dfh);
chmod(0555, $dest) || die "Could not chmod $dest: $!";
}