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 st...@apache.org on 2004/04/05 06:03:38 UTC
cvs commit: modperl-2.0/lib/Apache Build.pm
stas 2004/04/04 21:03:38
Modified: lib/Apache Build.pm
Log:
abstract the code looking for apxs to its own function and call it only
once, and not on every apxs query
Revision Changes Path
1.157 +31 -17 modperl-2.0/lib/Apache/Build.pm
Index: Build.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -u -r1.156 -r1.157
--- Build.pm 4 Mar 2004 06:01:05 -0000 1.156
+++ Build.pm 5 Apr 2004 04:03:38 -0000 1.157
@@ -98,22 +98,14 @@
defined $prefix && -d $prefix && -e "$prefix/CHANGES";
}
-sub apxs {
+# try to find the apxs utility, set $apxs to the path if found,
+# otherwise to ''
+my $apxs; # undef so we know we haven't tried to set it yet
+sub find_apxs_util {
my $self = shift;
- my $is_query = (@_ == 2) && ($_[0] eq '-q');
-
- $self = $self->build_config unless ref $self;
+ $apxs = ''; # not found
- my $query_key;
- if ($is_query) {
- $query_key = 'APXS_' . uc $_[1];
- if ($self->{$query_key}) {
- return $self->{$query_key};
- }
- }
-
- my $apxs;
my @trys = ($Apache::Build::APXS,
$self->{MP_APXS},
$ENV{MP_APXS},
@@ -136,13 +128,35 @@
'/usr/local/apache/bin/apxs';
}
+ my $apxs_try;
for (@trys) {
- next unless ($apxs = $_);
- chomp $apxs;
- last if -x $apxs;
+ next unless ($apxs_try = $_);
+ chomp $apxs_try;
+ if (-x $apxs_try) {
+ $apxs = $apxs_try;
+ last;
+ }
+ }
+}
+
+sub apxs {
+ my $self = shift;
+
+ $self->find_apxs_util() unless defined $apxs;
+
+ my $is_query = (@_ == 2) && ($_[0] eq '-q');
+
+ $self = $self->build_config unless ref $self;
+
+ my $query_key;
+ if ($is_query) {
+ $query_key = 'APXS_' . uc $_[1];
+ if ($self->{$query_key}) {
+ return $self->{$query_key};
+ }
}
- unless ($apxs and -x $apxs) {
+ unless ($apxs) {
my $prefix = $self->{MP_AP_PREFIX} || "";
return '' unless -d $prefix and $is_query;
my $val = $apxs_query{$_[1]};