You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by do...@hyperreal.org on 1999/05/19 21:43:00 UTC
cvs commit: modperl/lib/Apache ExtUtils.pm
dougm 99/05/19 12:42:59
Modified: . Changes
lib/Apache ExtUtils.pm
Log:
new Apache::ExtUtils::pm function to generate Foo.pm/Makefile.PL
templates for modules with directive handlers
Revision Changes Path
1.295 +3 -0 modperl/Changes
Index: Changes
===================================================================
RCS file: /export/home/cvs/modperl/Changes,v
retrieving revision 1.294
retrieving revision 1.295
diff -u -r1.294 -r1.295
--- Changes 1999/05/19 19:33:36 1.294
+++ Changes 1999/05/19 19:42:57 1.295
@@ -8,6 +8,9 @@
=item 1.19_01-dev
+new Apache::ExtUtils::pm function to generate Foo.pm/Makefile.PL
+templates for modules with directive handlers
+
Makefile.PL will now do a handful of sanity checks looking for
possible broken configurations and offer suggestions for those it
finds
1.15 +83 -0 modperl/lib/Apache/ExtUtils.pm
Index: ExtUtils.pm
===================================================================
RCS file: /export/home/cvs/modperl/lib/Apache/ExtUtils.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ExtUtils.pm 1998/12/11 23:04:01 1.14
+++ ExtUtils.pm 1999/05/19 19:42:59 1.15
@@ -7,6 +7,8 @@
*import = \&Exporter::import;
@Apache::ExtUtils::EXPORT = qw(command_table);
+@Apache::ExtUtils::EXPORT_OK = qw(pm);
+
my $errsv = "";
sub command_table {
@@ -219,6 +221,87 @@
stash_mod_pointer("$class", &XS_${modname});
EOF
+}
+
+#perl -MApache::ExtUtils=pm -e pm -- Apache::Foo
+sub pm {
+ my($class) = @_ ? @_ : @ARGV;
+ (my $name = $class) =~ s/.*::(\w+)$/$1/;
+ write_pm($class, $name);
+ write_makepl($class, $name);
+}
+
+sub outfh {
+ my($file) = @_;
+
+ my $fh = local *FH;
+ if (-e $file) {
+ die "$file exists";
+ }
+ open $fh, ">$file" or die "open $file: $!";
+ print STDERR "writing $file\n";
+ return $fh;
+}
+
+sub write_pm {
+ my($class, $name) = @_;
+ my $fh = outfh("$name.pm");
+ print $fh <<EOF;
+package $class;
+
+use strict;
+use Apache::ModuleConfig ();
+use DynaLoader ();
+
+if(\$ENV{MOD_PERL}) {
+ no strict;
+ \$VERSION = '1.00';
+ \@ISA = qw(DynaLoader);
+ __PACKAGE__->bootstrap(\$VERSION);
+}
+
+sub DirectiveName (\$\$\$) {
+ my(\$cfg, \$parms, \$arg) = \@_;
+ my \$scfg = Apache::ModuleConfig->get(\$parms->server);
+
+}
+
+1;
+__END__
+EOF
+ close $fh or die $!;
+}
+
+sub write_makepl {
+ my($class, $name) = @_;
+
+ my $fh = outfh("Makefile.PL");
+ print $fh <<EOF;
+package $class;
+
+use ExtUtils::MakeMaker;
+
+use Apache::ExtUtils qw(command_table);
+use Apache::src ();
+
+my \@directives = (
+ {
+ name => 'DirectiveName',
+ errmsg => 'the syntax error message',
+ args_how => 'TAKE1',
+ req_override => 'OR_ALL',
+ }
+ );
+
+command_table(\\\@directives);
+
+WriteMakefile(
+ 'NAME' => __PACKAGE__,
+ 'VERSION_FROM' => '$name.pm',
+ 'INC' => Apache::src->new->inc,
+ );
+EOF
+ close $fh or die $!;
}
1;