Permalink
Browse files

generate a _manual A::B::PC object from alien_provides_* rather than …

…packing that in the configdata
  • Loading branch information...
jberger committed Mar 17, 2012
1 parent b1b1277 commit 9299e04ab9b8c4e02332254604dffb605c97064e
Showing with 30 additions and 18 deletions.
  1. +10 −2 lib/Alien/Base.pm
  2. +14 −16 lib/Alien/Base/ModuleBuild.pm
  3. +6 −0 lib/Alien/Base/PkgConfig.pm
View
@@ -85,8 +85,16 @@ sub _keyword {
sub pkgconfig {
my $self = shift;
my %all = %{ $self->config('pkgconfig') };
- return values %all unless @_;
- return @all{@_};
+
+ return @all{@_} if @_;
+
+ my $manual = delete $all{_manual};
+
+ if (keys %all) {
+ return values %all;
+ } else {
+ return $manual;
+ }
}
# helper method to call Alien::MyLib::ConfigData->config(@_)
@@ -202,19 +202,6 @@ sub alien_init_temp_dir {
}
}
-sub alien_init_configdata {
- my $self = shift;
-
- my $cflags = $self->alien_provides_cflags;
- $self->config_data( Cflags => $cflags );
-
- my $libs = $self->alien_provides_libs;
- $self->config_data( Libs => $libs );
-
- my $name = $self->alien_name;
- $self->config_data( name => $name );
-}
-
####################
# ACTION methods #
####################
@@ -228,7 +215,7 @@ sub ACTION_code {
sub ACTION_alien {
my $self = shift;
- $self->alien_init_configdata;
+ $self->config_data( name => $self->alien_name );
my $version;
$version = $self->alien_check_installed_version
@@ -414,14 +401,25 @@ sub alien_load_pkgconfig {
my $dir = $self->config_data('build_share_dir');
my $pc_files = $self->rscan_dir( $dir, qr/\.pc$/ );
- return unless @$pc_files;
-
my %pc_objects = map {
my $pc = Alien::Base::PkgConfig->new($_);
$pc->make_abstract( alien_dist_dir => $dir );
($pc->{package}, $pc)
} @$pc_files;
+ my $manual_pc = Alien::Base::PkgConfig->new({
+ package => $self->alien_name,
+ vars => {
+ alien_dist_dir => $dir,
+ },
+ keywords => {
+ Cflags => $self->alien_provides_cflags || '',
+ Libs => '-L${alien_dist_dir} ' . ($self->alien_provides_libs() || ''),
+ },
+ });
+
+ $pc_objects{_manual} = $manual_pc;
+
$self->config_data( pkgconfig => \%pc_objects );
return \%pc_objects;
}
@@ -11,6 +11,12 @@ use File::Basename qw/fileparse/;
sub new {
my $class = shift;
+
+ # allow creation of an object from a full spec.
+ if (ref $_[0] eq 'HASH') {
+ return bless $_[0], $class;
+ }
+
my ($path) = @_;
croak "Must specify a file" unless defined $path;

0 comments on commit 9299e04

Please sign in to comment.