Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.

Commit

Permalink
Remove the code making GENERATED/*
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Aug 30, 2015
1 parent a46d2e0 commit 8726158
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 65 deletions.
62 changes: 1 addition & 61 deletions Basic/Core/Dev.pm
Expand Up @@ -20,9 +20,6 @@ PDLA development and is often used from within Makefile.PL's.

package PDLA::Core::Dev;

use File::Path;
use File::Basename;
use ExtUtils::Manifest;
use English; require Exporter;

@ISA = qw( Exporter );
Expand All @@ -34,7 +31,7 @@ use English; require Exporter;
pdlpp_postamble_int pdlpp_stdargs_int
pdlpp_postamble pdlpp_stdargs write_dummy_make
unsupported getcyglib trylink
pdlpp_mkgen
pdlpp_genpm
);

# Installation locations
Expand Down Expand Up @@ -472,67 +469,10 @@ sub pdlpp_stdargs {
'INC' => &PDLA_INST_INCLUDE()." $inc",
'LIBS' => $libs ? ["$libs "] : [],
'clean' => {'FILES' => "$pref.xs $pref.pm $pref\$(OBJ_EXT) $pref.c"},
'dist' => {'PREOP' => '$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" -MPDLA::Core::Dev -e pdlpp_mkgen $(DISTVNAME)' },
(eval ($ExtUtils::MakeMaker::VERSION) >= 6.57_02 ? ('NO_MYMETA' => 1) : ()),
);
}

# pdlpp_mkgen($dir)
# - scans $dir/MANIFEST for all *.pd files and creates corresponding *.pm files
# in $dir/GENERATED/ subdir; needed for proper doc rendering at metacpan.org
# - it is used in Makefile.PL like:
# dist => { PREOP=>'$(PERL) -MPDLA::Core::Dev -e pdlpp_mkgen $(DISTVNAME)' }
# so all the magic *.pm generation happens during "make dist"
# - it is intended to be called as a one-liner:
# perl -MPDLA::Core::Dev -e pdlpp_mkgen DirName
#
sub pdlpp_mkgen {
my $dir = @_ > 0 ? $_[0] : $ARGV[0];
die "pdlpp_mkgen: unspecified directory" unless defined $dir && -d $dir;
my $file = "$dir/MANIFEST";
die "pdlpp_mkgen: non-existing '$dir/MANIFEST'" unless -f $file;

my @pairs = ();
my $manifest = ExtUtils::Manifest::maniread($file);
for (keys %$manifest) {
next if $_ !~ m/\.pd$/; # skip non-pd files
next if $_ =~ m/^(t|xt)\//; # skip *.pd files in test subdirs
next unless -f $_;
my $content = do { local $/; open my $in, '<', $_; <$in> };
if ($content =~ /=head1\s+NAME\s+(\S+)\s+/sg) {
push @pairs, [$_, $1];
}
else {
warn "pdlpp_mkgen: unknown module name for '$_' (use proper '=head1 NAME' section)\n";
}
}

my %added = ();
for (@pairs) {
my ($pd, $mod) = @$_;
(my $prefix = $mod) =~ s|::|/|g;
my $manifestpm = "GENERATED/$prefix.pm";
$prefix = "$dir/GENERATED/$prefix";
File::Path::mkpath(dirname($prefix));
#there is no way to use PDLA::PP from perl code, thus calling via system()
my @in = map { "-I$_" } @INC, 'inc';
my $rv = system($^X, @in, "-MPDLA::PP qw[$mod $mod $prefix]", $pd);
if ($rv == 0 && -f "$prefix.pm") {
$added{$manifestpm} = "mod=$mod pd=$pd (added by pdlpp_mkgen)";
unlink "$prefix.xs"; #we need only .pm
}
else {
warn "pdlpp_mkgen: cannot convert '$pd'\n";
}
}

if (scalar(keys %added) > 0) {
#maniadd works only with this global variable
local $ExtUtils::Manifest::MANIFEST = $file;
ExtUtils::Manifest::maniadd(\%added);
}
}

sub unsupported {
my ($package,$os) = @_;
"No support for $package on $os platform yet. Will skip build process";
Expand Down
5 changes: 1 addition & 4 deletions Makefile.PL
Expand Up @@ -435,9 +435,6 @@ if($Config{archname}=~m/x86_64/) {
$ccflags .= " -fPIC";
}

# create GENERATED subdir with *.pm files during 'make dist' (to make metacpan.org happy)
my $preop = '$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -MPDLA::Core::Dev -e pdlpp_mkgen $(DISTVNAME)';

my %makefile_hash = (
'PREREQ_PM' => { @prereq },
'CONFIGURE_REQUIRES' => {
Expand Down Expand Up @@ -476,7 +473,7 @@ my %makefile_hash = (
'CCFLAGS' => $ccflags,
'dist' => { COMPRESS => 'gzip',
SUFFIX => 'gz',
PREOP => $preop },
},
'clean' => {
'FILES' => join ' ', @cleanup, qw(
tbyte.tif tmp0 tmp0.hdr tushort.tif
Expand Down

0 comments on commit 8726158

Please sign in to comment.