You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Randy Kobes <ra...@theoryx5.uwinnipeg.ca> on 2003/12/15 17:33:40 UTC

[mp2] finding apxs on Win32

In lib/Apache/Build.pm, some tries are made to find
apxs and apr-config, and success is tested using -x $try.
For this test to succeed on Win32 a .bat extension is
needed. The following diff:
=======================================================
Index: lib/Apache/Build.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v
retrieving revision 1.151
diff -u -r1.151 Build.pm
--- lib/Apache/Build.pm	15 Dec 2003 05:29:35 -0000	1.151
+++ lib/Apache/Build.pm	15 Dec 2003 16:32:53 -0000
@@ -102,7 +102,8 @@
     my $apxs;
     my @trys = ($Apache::Build::APXS,
                 $self->{MP_APXS},
-                $ENV{MP_APXS});
+                $ENV{MP_APXS},
+                catfile $self->{MP_AP_PREFIX}, 'bin', 'apxs');

     unless (IS_MOD_PERL_BUILD) {
         #if we are building mod_perl via apxs, apxs should already be known
@@ -114,8 +115,10 @@
         '/usr/local/apache/bin/apxs';
     }

-    for (@trys) {
-        next unless ($apxs = $_);
+    my $ext = WIN32 ? '.bat' : '';
+    for my $try (@trys) {
+        $try .= $ext if ($try and defined $ext and $try !~ /$ext$/);
+        next unless ($apxs = $try);
         chomp $apxs;
         last if -x $apxs;
     }
@@ -831,8 +834,10 @@
                 if exists $self->{MP_AP_PREFIX} and -d $self->{MP_AP_PREFIX};
         }

+        my $ext = WIN32 ? '.bat' : '';
         for (@tries) {
             my $try = catfile $_, "apr-config";
+            $try .= $ext if ($try and defined $ext and $try !~ /$ext$/);
             next unless -x $try;
             $self->{apr_config_path} = $try;
         }
====================================================================
adds this extension for Win32, if it's not already present.
It also, in trying to find apxs, searches for
MP_AP_PREFIX/bin/apxs.

-- 
best regards,
randy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] finding apxs on Win32

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Mon, 15 Dec 2003, Stas Bekman wrote:

> Randy Kobes wrote:
> > In lib/Apache/Build.pm, some tries are made to find
> > apxs and apr-config, and success is tested using -x $try.
> > For this test to succeed on Win32 a .bat extension is
> > needed. The following diff:
> > =======================================================
> > Index: lib/Apache/Build.pm
> > ===================================================================
> > RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v
> > retrieving revision 1.151
> > diff -u -r1.151 Build.pm
> > --- lib/Apache/Build.pm	15 Dec 2003 05:29:35 -0000	1.151
> > +++ lib/Apache/Build.pm	15 Dec 2003 16:32:53 -0000
> > @@ -102,7 +102,8 @@
> >      my $apxs;
> >      my @trys = ($Apache::Build::APXS,
> >                  $self->{MP_APXS},
> > -                $ENV{MP_APXS});
> > +                $ENV{MP_APXS},
> > +                catfile $self->{MP_AP_PREFIX}, 'bin', 'apxs');
>
> could this be committed separately? Since it's a different change...

OK, I'll do that ....

> >      unless (IS_MOD_PERL_BUILD) {
> >          #if we are building mod_perl via apxs, apxs should already be known
> > @@ -114,8 +115,10 @@
> >          '/usr/local/apache/bin/apxs';
> >      }
> >
> > -    for (@trys) {
> > -        next unless ($apxs = $_);
> > +    my $ext = WIN32 ? '.bat' : '';
> > +    for my $try (@trys) {
> > +        $try .= $ext if ($try and defined $ext and $try !~ /$ext$/);
> > +        next unless ($apxs = $try);
>
> $ext is well defined ('.bat' : ''), why would you check if it's defined? I'd say:
>
>     $try .= $ext if $try and $try !~ /$ext$/;
>
> >          chomp $apxs;
> >          last if -x $apxs;
> >      }
> > @@ -831,8 +834,10 @@
> >                  if exists $self->{MP_AP_PREFIX} and -d $self->{MP_AP_PREFIX};
> >          }
> >
> > +        my $ext = WIN32 ? '.bat' : '';
> >          for (@tries) {
> >              my $try = catfile $_, "apr-config";
> > +            $try .= $ext if ($try and defined $ext and $try !~ /$ext$/);
>
> here $try is also well defined (catfile), so all you need is:
>
>    $try .= $ext if $try !~ /$ext$/;
>
> >              next unless -x $try;
> >              $self->{apr_config_path} = $try;
>
> now, in both cases why not adjust the code that fills @tries in? which should
> be as simple as:
>
> if (WIN32) {
>      my $ext = ".bat";
>      @tries = map { $_ . $ext unless $_ =~ /$ext$/} @tries;
> }
>
> This is untested.
>
> But you don't have to change the code that does the actual
> testing, which keeps it simple and it's easy to see that
> WIN32 has a special case, instead of messing with the end
> code.

That's a better approach - thanks! I'll look into doing
that tonight.

-- 
best regards,
randy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] finding apxs on Win32

Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
> In lib/Apache/Build.pm, some tries are made to find
> apxs and apr-config, and success is tested using -x $try.
> For this test to succeed on Win32 a .bat extension is
> needed. The following diff:
> =======================================================
> Index: lib/Apache/Build.pm
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v
> retrieving revision 1.151
> diff -u -r1.151 Build.pm
> --- lib/Apache/Build.pm	15 Dec 2003 05:29:35 -0000	1.151
> +++ lib/Apache/Build.pm	15 Dec 2003 16:32:53 -0000
> @@ -102,7 +102,8 @@
>      my $apxs;
>      my @trys = ($Apache::Build::APXS,
>                  $self->{MP_APXS},
> -                $ENV{MP_APXS});
> +                $ENV{MP_APXS},
> +                catfile $self->{MP_AP_PREFIX}, 'bin', 'apxs');

could this be committed separately? Since it's a different change...

>      unless (IS_MOD_PERL_BUILD) {
>          #if we are building mod_perl via apxs, apxs should already be known
> @@ -114,8 +115,10 @@
>          '/usr/local/apache/bin/apxs';
>      }
> 
> -    for (@trys) {
> -        next unless ($apxs = $_);
> +    my $ext = WIN32 ? '.bat' : '';
> +    for my $try (@trys) {
> +        $try .= $ext if ($try and defined $ext and $try !~ /$ext$/);
> +        next unless ($apxs = $try);

$ext is well defined ('.bat' : ''), why would you check if it's defined? I'd say:

    $try .= $ext if $try and $try !~ /$ext$/;

>          chomp $apxs;
>          last if -x $apxs;
>      }
> @@ -831,8 +834,10 @@
>                  if exists $self->{MP_AP_PREFIX} and -d $self->{MP_AP_PREFIX};
>          }
> 
> +        my $ext = WIN32 ? '.bat' : '';
>          for (@tries) {
>              my $try = catfile $_, "apr-config";
> +            $try .= $ext if ($try and defined $ext and $try !~ /$ext$/);

here $try is also well defined (catfile), so all you need is:

   $try .= $ext if $try !~ /$ext$/;

>              next unless -x $try;
>              $self->{apr_config_path} = $try;

now, in both cases why not adjust the code that fills @tries in? which should 
be as simple as:

if (WIN32) {
     my $ext = ".bat";
     @tries = map { $_ . $ext unless $_ =~ /$ext$/} @tries;
}

This is untested.

But you don't have to change the code that does the actual testing, which 
keeps it simple and it's easy to see that WIN32 has a special case, instead of 
messing with the end code.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] finding apxs on Win32

Posted by Steve Hay <st...@uk.radan.com>.
Randy Kobes wrote:

>In lib/Apache/Build.pm, some tries are made to find
>apxs and apr-config, and success is tested using -x $try.
>For this test to succeed on Win32 a .bat extension is
>needed. The following diff:
>
Works for me -- I now have the apr-ext/uuid being run for the first 
time.  (And it passes.)

Thanks, Randy!
- Steve



------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only.  If you have received this message in error or there are any problems, please notify the sender immediately.  The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden.  Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd.  The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org