[Reproducible-commits] [libextutils-depends-perl] 155/187: Doc, test, implement load() using *::I::F->Inline() et al.
Maria Valentina Marin Rodrigues
akira-guest at moszumanska.debian.org
Wed Jan 21 21:16:59 UTC 2015
This is an automated email from the git hooks/post-receive script.
akira-guest pushed a commit to branch pu/reproducible_builds
in repository libextutils-depends-perl.
commit 957bdb29232e5ea6a853332facb47efa54f4a0b4
Author: Ed J <mohawk2 at users.noreply.github.com>
Date: Sun Aug 3 23:02:01 2014 +0100
Doc, test, implement load() using *::I::F->Inline() et al.
---
lib/ExtUtils/Depends.pm | 45 +++++++++++++++++++++++++++++++--------------
t/02_save_load.t | 28 ++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 14 deletions(-)
diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm
index 00c6763..ed7e972 100644
--- a/lib/ExtUtils/Depends.pm
+++ b/lib/ExtUtils/Depends.pm
@@ -198,20 +198,32 @@ sub load {
$instpath = File::Spec->rel2abs ($instpath);
}
- my @typemaps = map {
- File::Spec->rel2abs ($_, $instpath)
- } @{"$depinstallfiles\::typemaps"};
+ my (@typemaps, $inc, $libs, @deps);
+
+ @deps = eval { $depinstallfiles->deps };
+ @deps = @{"$depinstallfiles\::deps"}
+ if $@ and exists ${"$depinstallfiles\::"}{deps};
+
+ my $inline = eval { $depinstallfiles->Inline('C') };
+ if (!$@) {
+ $inc = $inline->{INC} // '';
+ $libs = $inline->{LIBS} // '';
+ @typemaps = @{ $inline->{TYPEMAPS} || [] };
+ } else {
+ $inc = ${"$depinstallfiles\::inc"} // '';
+ $libs = ${"$depinstallfiles\::libs"} // '';
+ @typemaps = @{"$depinstallfiles\::typemaps"};
+ }
+ @typemaps = map { File::Spec->rel2abs ($_, $instpath) } @typemaps;
{
instpath => $instpath,
typemaps => \@typemaps,
- inc => "-I$instpath ".${"$depinstallfiles\::inc"},
- libs => ${"$depinstallfiles\::libs"},
+ inc => "-I$instpath $inc",
+ libs => $libs,
# this will not exist when loading files from old versions
# of ExtUtils::Depends.
- (exists ${"$depinstallfiles\::"}{deps}
- ? (deps => \@{"$depinstallfiles\::deps"})
- : ()),
+ deps => \@deps,
}
}
@@ -601,12 +613,17 @@ loading files created by old versions of ExtUtils::Depends.
=back
If you want to make module I<name> support this, you must provide
-a module I<name>::Install::Files, which on loading will provide the
-following package variables: C<@typemaps>, C<$inc>, C<$libs>, C<$deps>,
-with the same contents as above (not coincidentally). The C<load>
-function will supply the C<instpath>. An easy way to achieve this is
-to use the method L</"$depends-E<gt>save_config ($filename)">, but your
-package may have different facilities already.
+a module I<name>::Install::Files, which on loading will implement the
+following class methods:
+
+ $hashref = name::Install::Files->Inline('C');
+ # hash to contain any necessary TYPEMAPS (array-ref), LIBS, INC
+ @deps = name::Install::Files->deps;
+ # any modules on which "name" depends
+
+An easy way to achieve this is to use the method
+L</"$depends-E<gt>save_config ($filename)">, but your package may have
+different facilities already.
=item $depends->load_deps
diff --git a/t/02_save_load.t b/t/02_save_load.t
index a313432..3e52c7d 100644
--- a/t/02_save_load.t
+++ b/t/02_save_load.t
@@ -40,6 +40,34 @@ my @installed_files = qw(dep.h
dep-private.h);
$dep_info->install (@installed_files);
+my $INC_FRAG = '-Ddistinctive';
+map { make_fake($_) } qw(Fakenew Fakeold);
+sub Fakenew::Install::Files::Inline { +{ INC => $INC_FRAG } }
+sub Fakenew::Install::Files::deps { qw(Fakeold) }
+{
+ no warnings 'once';
+ @Fakeold::Install::Files::deps = qw(Fakenew);
+ $Fakeold::Install::Files::inc = $INC_FRAG;
+ $Fakeold::Install::Files::libs = '';
+}
+sub make_fake {
+ my $class = shift . '::Install::Files';
+ my @pieces = split '::', $class;
+ require File::Spec;
+ my $pm = join('/', @pieces) . '.pm';
+ $INC{$pm} = File::Spec->catdir(qw(build fake), split '/', $pm);
+}
+sub test_load {
+ my ($info, $msg) = @_;
+ my $install_part = qr|Fake.*Install|;
+ like ($info->{inc}, $install_part, "$msg inc generic");
+ like ($info->{inc}, qr/$INC_FRAG/, "$msg inc specific");
+ ok (scalar(grep { /Fake/ } @{$info->{deps}}), $msg);
+ ok (exists $info->{libs}, $msg);
+}
+test_load (ExtUtils::Depends::load('Fakenew'), 'load new scheme');
+test_load (ExtUtils::Depends::load('Fakeold'), 'load old scheme');
+
use Data::Dumper;
$Data::Dumper::Terse = 1;
$dep_info->save_config (catfile $tmp_inc, qw(DepTest Install Files.pm));
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/libextutils-depends-perl.git
More information about the Reproducible-commits
mailing list