[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl-dev
Subject:    Re: [mp2] finding apxs on Win32
From:       Randy Kobes <randy () theoryx5 ! uwinnipeg ! ca>
Date:       2003-12-15 20:16:56
[Download RAW message or body]

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic