Geoffrey Young wrote:
>>+1 for either documenting the format
>>of $ENV{MOD_PERL} so folks can parse it, or (preferably)
>>creating a new env variable that contains either the
>>version number or the API generation.
>
>
> yeah, I'm in favor of a new variable too. I'll probably get around to
> implementing it on monday then I'll post it for review. thoughts in the
> meanwhile still appreciated :)
ok, attached is a patch that creates $ENV{MOD_PERL_API_VERSION} based on
some information in mod_perl2.pm.
feedback welcome.
--Geoff
Index: src/modules/perl/modperl_env.c
===================================================================
--- src/modules/perl/modperl_env.c (revision 157559)
+++ src/modules/perl/modperl_env.c (working copy)
@@ -73,6 +73,7 @@
static modperl_env_ent_t MP_env_const_vars[] = {
MP_ENV_ENT("MOD_PERL", MP_VERSION_STRING),
+ MP_ENV_ENT("MOD_PERL_API_VERSION", MP_API_VERSION),
{ NULL }
};
Index: Makefile.PL
===================================================================
--- Makefile.PL (revision 157559)
+++ Makefile.PL (working copy)
@@ -456,7 +456,10 @@
}
close $fh;
- $build->{VERSION} = $VERSION;
+ $build->{VERSION} = $VERSION;
+ $build->{API_VERSION_MAJOR} = $mod_perl2::API_VERSION_MAJOR;
+ $build->{API_VERSION_MINOR} = $mod_perl2::API_VERSION_MINOR;
+ $build->{API_VERSION} = $mod_perl2::API_VERSION;
}
# needs to be run after configure() when apxs is setup
Index: t/conf/modperl_extra.pl
===================================================================
--- t/conf/modperl_extra.pl (revision 157559)
+++ t/conf/modperl_extra.pl (working copy)
@@ -19,6 +19,7 @@
use warnings FATAL => 'all';
die '$ENV{MOD_PERL} not set!' unless $ENV{MOD_PERL};
+die '$ENV{MOD_PERL_API_VERSION} not set!' unless $ENV{MOD_PERL_API_VERSION};
use File::Spec::Functions qw(canonpath catdir);
Index: t/response/TestModperl/env.pm
===================================================================
--- t/response/TestModperl/env.pm (revision 157559)
+++ t/response/TestModperl/env.pm (working copy)
@@ -20,6 +20,7 @@
ok $ENV{MODPERL_EXTRA_PL}; #set in t/conf/modperl_extra.pl
ok $ENV{MOD_PERL};
+ ok $ENV{MOD_PERL_API_VERSION};
ok $ENV{SERVER_SOFTWARE};
ok $env->get('SERVER_SOFTWARE');
Index: t/response/TestModules/cgi2.pm
===================================================================
--- t/response/TestModules/cgi2.pm (revision 157559)
+++ t/response/TestModules/cgi2.pm (working copy)
@@ -18,6 +18,10 @@
die "\$ENV{MOD_PERL} is not set";
}
+ unless ($ENV{MOD_PERL_API_VERSION}) {
+ die "\$ENV{MOD_PERL_API_VERSION} is not set";
+ }
+
if ($CGI::Q) {
die "CGI.pm globals were not reset";
}
Index: t/response/TestModules/cgi.pm
===================================================================
--- t/response/TestModules/cgi.pm (revision 157559)
+++ t/response/TestModules/cgi.pm (working copy)
@@ -15,6 +15,10 @@
die "\$ENV{MOD_PERL} is not set";
}
+ unless ($ENV{MOD_PERL_API_VERSION}) {
+ die "\$ENV{MOD_PERL_API_VERSION} is not set";
+ }
+
if ($CGI::Q) {
die "CGI.pm globals were not reset";
}
Index: lib/ModPerl/Code.pm
===================================================================
--- lib/ModPerl/Code.pm (revision 157559)
+++ lib/ModPerl/Code.pm (working copy)
@@ -505,6 +505,16 @@
print $h_fh qq(#define MP_VERSION_STRING "mod_perl/$v"\n);
+ my $major = $self->{build}->{API_VERSION_MAJOR};
+ my $minor = $self->{build}->{API_VERSION_MINOR};
+ my $string = $self->{build}->{API_VERSION};
+
+ print $h_fh <<EOF;
+#define MP_API_VERSION_MAJOR $major
+#define MP_API_VERSION_MINOR $minor
+#define MP_API_VERSION "$string"
+EOF
+
my $i = 1;
my @trace = sort keys %trace;
my $opts = join '', @trace;
Index: lib/mod_perl2.pm
===================================================================
--- lib/mod_perl2.pm (revision 157559)
+++ lib/mod_perl2.pm (working copy)
@@ -34,6 +34,16 @@
# $VERSION : "1.099020"
# int $VERSION : 1.09902
# $VERSION_TRIPLET: 1.99.20
+
+ # mod_perl equivalent of httpd module magic number
+ # basically
+ # - bump the major version for binary-incompatible
+ # - bump the minor version for API changes
+ # - if you bump the major version, reset the minor to 0
+ our $API_VERSION_MAJOR = 20050315;
+ our $API_VERSION_MINOR = 0;
+ our $API_VERSION = join '.', $API_VERSION_MAJOR,
+ $API_VERSION_MINOR/100;
}
$mod_perl::VERSION = $mod_perl2::VERSION;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]