Skip to content
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.

fix A::B::PkgConfig::read #165

Merged
merged 1 commit into from Jun 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Alien/Base/PkgConfig.pm
Expand Up @@ -51,9 +51,9 @@ sub read {
or croak "Cannot open .pc file $path: $!";

while (<$fh>) {
if (/(.*?)=([^\n\r]*)/) {
if (/^([^=:]+?)=([^\n\r]*)/) {
$self->{vars}{$1} = $2;
} elsif (/^(.*?):\s*([^\n\r]*)/) {
} elsif (/^([^=:]+?):\s*([^\n\r]*)/) {
$self->{keywords}{$1} = $2;
}
}
Expand Down
9 changes: 5 additions & 4 deletions t/pkgconfig.t
Expand Up @@ -32,7 +32,8 @@ is_deeply(
{
'Version' => '1.01',
'Libs' => '-L/home/test/path/lib -lsomelib ${INTERNAL_VARIABLE} -lm -lm',
'Cflags' => '-I/home/test/path/deeper/include',
'Cflags' => '-Dfoo=bar -I/home/test/path/deeper/include',
'Requires' => 'lib1 >= 1.0.0 lib2 >= 1.2.3',
'Description' => 'My TEST Library',
'Name' => 'TEST',
},
Expand All @@ -52,17 +53,17 @@ is( $pc->{vars}{deeper}, '${prefix}/deeper', "abstract vars in terms of each oth
is( (split qr/\s+/, $pc->{keywords}{Libs})[0], '-L${prefix}/lib', "abstract simple" );

$pc->make_abstract('deeper');
is( $pc->{keywords}{Cflags}, '-I${deeper}/include', "abstract abstract 'nested'" );
is( $pc->{keywords}{Cflags}, '-Dfoo=bar -I${deeper}/include', "abstract abstract 'nested'" );

# interpolate vars into keywords
is( $pc->keyword('Version'), '1.01', "Simple keyword getter" );
is( (split qr/\s+/, $pc->keyword('Libs'))[0], '-L/home/test/path/lib', "single interpolation keyword" );
is( $pc->keyword('Cflags'), '-I/home/test/path/deeper/include', "multiple interpolation keyword" );
is( $pc->keyword('Cflags'), '-Dfoo=bar -I/home/test/path/deeper/include', "multiple interpolation keyword" );

# interpolate with overrides
is(
$pc->keyword( 'Cflags', {prefix => '/some/other/path'}),
'-I/some/other/path/deeper/include',
'-Dfoo=bar -I/some/other/path/deeper/include',
"multiple interpolation keyword with override"
);

Expand Down
3 changes: 2 additions & 1 deletion t/pkgconfig/test.pc
Expand Up @@ -5,4 +5,5 @@ Name: TEST
Description: My TEST Library
Version: 1.01
Libs: -L/home/test/path/lib -lsomelib ${INTERNAL_VARIABLE} -lm -lm
Cflags: -I/home/test/path/deeper/include
Cflags: -Dfoo=bar -I/home/test/path/deeper/include
Requires: lib1 >= 1.0.0 lib2 >= 1.2.3