Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Hopefully fixed the Bad File Descriptor message coming from pkg-confi…

…g. Still not quite sure why the problem was happening, but capture_merged seems to fix it. Also test now makes sure that a random library is chosen.
  • Loading branch information...
commit 5b46f2872abd6c5b9651dbf25025c921da8f3c34 1 parent ce2b597
Joel Berger jberger authored
Showing with 28 additions and 5 deletions.
  1. +8 −1 lib/Alien/Base.pm
  2. +20 −4 t/yy-system_installed.t
9 lib/Alien/Base.pm
View
@@ -13,6 +13,7 @@ use File::ShareDir ();
use Scalar::Util qw/blessed/;
use Perl::OSType qw/is_os_type/;
use Config;
+use Capture::Tiny qw/capture_merged/;
sub import {
my $class = shift;
@@ -62,8 +63,13 @@ sub _keyword {
my $type = $self->config('install_type');
if ($type eq 'system') {
my $name = $self->config('name');
- my $pcdata = `pkg-config --\L$keyword\E $name`;
+ my $command = "pkg-config --\L$keyword\E $name";
+
+ chomp ( my $pcdata = capture_merged { system( $command ) } );
croak "Could not call pkg-config: $!" if $!;
+
+ $pcdata =~ s/\s*$//;
+
return $pcdata;
}
@@ -99,6 +105,7 @@ sub config {
my $config = $class . '::ConfigData';
eval "require $config";
+ warn $@ if $@;
return $config->config(@_);
}
24 t/yy-system_installed.t
View
@@ -2,6 +2,7 @@ use strict;
use warnings;
use File::chdir;
+use List::Util qw/shuffle/;
use Test::More;
use Alien::Base::ModuleBuild;
@@ -18,11 +19,26 @@ if ( $? ) {
plan skip_all => "Cannot use pkg-config: $?";
}
-my @installed = map { /^(\S+)/ ? $1 : () } `pkg-config --list-all`;
-my $lib = $installed[0];
+my @installed = shuffle map { /^(\S+)/ ? $1 : () } `pkg-config --list-all`;
-my $cflags = `pkg-config --cflags $lib`;
-my $libs = `pkg-config --libs $lib`;
+my ($lib, $cflags, $libs);
+
+while (1) {
+ $lib = shift @installed;
+
+ chomp( $cflags = `pkg-config --cflags $lib` );
+ chomp( $libs = `pkg-config --libs $lib` );
+
+ $cflags =~ s/\s*$//;
+ $libs =~ s/\s*$//;
+
+ if ($cflags and $libs) {
+ last;
+ } else {
+ undef $cflags;
+ undef $libs;
+ }
+}
my $builder = Alien::Base::ModuleBuild->new(
module_name => 'MyTest',
Please sign in to comment.
Something went wrong with that request. Please try again.