[Reproducible-commits] [libextutils-depends-perl] 46/187: [svn-inject] Installing original source of libextutils-depends-perl
Maria Valentina Marin Rodrigues
akira-guest at moszumanska.debian.org
Wed Jan 21 21:16:47 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 866a2384c0708a040c3bf28f31d344c094811d9d
Author: Ryan Niebur <ryan at debian.org>
Date: Sun Dec 28 07:24:13 2008 +0000
[svn-inject] Installing original source of libextutils-depends-perl
---
.cvsignore | 4 +
Changes | 64 +++++
MANIFEST | 15 ++
META.yml | 12 +
Makefile.PL | 59 +++++
README | 178 ++++++++++++++
lib/ExtUtils/Depends.pm | 551 ++++++++++++++++++++++++++++++++++++++++++
perl-ExtUtils-Depends.spec.in | 54 +++++
t/01_load.t | 6 +
t/02_save_load.t | 85 +++++++
t/03_deps.t | 31 +++
t/04_extra_libs.t | 26 ++
t/inc/DepTest/DepTest.lib | 0
t/inc/DepTest/Install/.keep | 0
14 files changed, 1085 insertions(+)
diff --git a/.cvsignore b/.cvsignore
new file mode 100644
index 0000000..18ddcc1
--- /dev/null
+++ b/.cvsignore
@@ -0,0 +1,4 @@
+Makefile
+blib
+pm_to_blib
+perl-ExtUtils-Depends.spec
diff --git a/Changes b/Changes
new file mode 100644
index 0000000..e4c4f72
--- /dev/null
+++ b/Changes
@@ -0,0 +1,64 @@
+Revision history for Perl extension ExtUtils::Depends.
+
+0.300 Sun Mar 30 17:35:35 CEST 2008
+ - On MSWin32 and cygwin, find the link libraries of dependencies and
+ put them into LIBS.
+ - Add tests.
+ - Correct typos in the documentation.
+ - In get_makefile_vars, comment out the code that put the installed
+ libraries into @OBJECT, which caused them to get deleted on
+ realclean.
+ - In Makefile.PL, don't use the bogus package "MAIN".
+ - Remove debug spew.
+
+0.205 Sun Jan 23 13:20:14 EST 2005
+ - Disable the RPM-related postamble on Win32. The 'date' command
+ on windows is interactive, and caused Makefile.PL to hang.
+
+0.204 Sun Sep 19 23:26:23 CEST 2004
+ - Use capitals at the start of everything that is printed out, to unify
+ Makefile.PL output.
+
+0.203 Fri Mar 12 16:09:35 EST 2004
+ - don't output a PM pair from get_makefile_vars unless we actually
+ have data in the pm key.
+
+0.202 Fri Mar 5 00:26:18 EST 2004
+ - add long-overdue version-checking import implementation.
+ - fixed a bad initial value bug that caused crashes if your setup
+ did not need a call to set_libs. [Ross]
+ - distribute the spec file. [Ross]
+
+0.201 Thu Feb 12 15:33:47 EST 2004
+ - add_headers() is now deprecated. it's functionality is provided
+ by install(), and it is already a no-op in 0.200.
+ - remove code referring to @headers, since we don't actually keep a
+ separate list of headers anymore. (should we?)
+ - load() no longer returns the "header" key -- it should've been
+ "headers", but i've simply removed all that code.
+
+0.200 Tue Feb 10 01:21:57 EST 2004
+ - completely rewritten. attempted to retain backward compatibility,
+ but some esoteric functionality is probably missing. now stores
+ dependency lists, so that module chaining is more useful.
+ - document just about everything.
+ - really, really, really needs a regression test suite.
+
+0.104 Fri Nov 21 01:34:57 EST 2003
+ - remove debian packaging files
+ - add licensing terms to pod. Depends was originally part of
+ gtk-perl, which itself bore this copyright notice.
+
+0.103 Fri Aug 15 09:59:42 EDT 2003
+ - add files for maintaining debian packages.
+
+0.102 Tue Jul 8 14:10:29 EDT 2003
+ - use File::Spec->file_name_is_absolute instead of non-portable m{^/}.
+ still uses direct string manipulation on paths, but this fix lets
+ the module function correctly under native Win32 perl.
+
+0.101 Fri Jun 20 23:37:19 CEST 2003
+ - added primitive load-only testsuite.
+
+0.1 Thu Jun 19 01:29:25 CEST 2003
+ - original version; created by extracting it from glib.
diff --git a/MANIFEST b/MANIFEST
new file mode 100644
index 0000000..47a4bf7
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,15 @@
+.cvsignore
+Changes
+lib/ExtUtils/Depends.pm
+Makefile.PL
+MANIFEST
+META.yml
+perl-ExtUtils-Depends.spec.in
+README
+t/01_load.t
+t/02_save_load.t
+t/03_deps.t
+t/04_extra_libs.t
+t/inc/DepTest/DepTest.lib
+t/inc/DepTest/Install/.keep
+t/inc/DepTest/libDepTest.dll.a
diff --git a/META.yml b/META.yml
new file mode 100644
index 0000000..13ac912
--- /dev/null
+++ b/META.yml
@@ -0,0 +1,12 @@
+--- #YAML:1.0
+name: ExtUtils-Depends
+version: 0.300
+abstract: ~
+license: ~
+author: ~
+generated_by: ExtUtils::MakeMaker version 6.44
+distribution_type: module
+requires:
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.3.html
+ version: 1.3
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644
index 0000000..6770e10
--- /dev/null
+++ b/Makefile.PL
@@ -0,0 +1,59 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ 'dist' => {
+ PREOP => 'pod2text lib/ExtUtils/Depends.pm | tee README >$(DISTVNAME)/README; chmod -R u=rwX,go=rX . ;',
+ COMPRESS => 'gzip -9v',
+ SUFFIX => '.gz',
+ },
+ 'NAME' => 'ExtUtils::Depends',
+ 'VERSION_FROM' => 'lib/ExtUtils/Depends.pm',
+);
+
+use Cwd;
+
+sub MY::postamble
+{
+ # none of this rpm stuff is useful on win32, and actually it can cause
+ # nmake to barf.
+ return @_ if $^O eq 'MSWin32';
+
+ my @dirs = qw{$(RPMS_DIR) $(RPMS_DIR)/BUILD $(RPMS_DIR)/RPMS
+ $(RPMS_DIR)/SOURCES $(RPMS_DIR)/SPECS $(RPMS_DIR)/SRPMS};
+ my $cwd = getcwd();
+
+ chomp (my $date = `date +"%a %b %d %Y"`);
+
+ my %subs = (
+ 'VERSION' => '$(VERSION)',
+ 'SOURCE' => '$(DISTNAME)-$(VERSION).tar.gz',
+ 'DATE' => $date,
+ );
+
+ my $substitute = '$(PERL) -npe \''.join('; ', map {
+ "s/\\\@$_\\\@/$subs{$_}/g";
+ } keys %subs).'\'';
+
+"
+realclean ::
+ -\$(RM_F) perl-\$(DISTNAME).spec
+
+RPMS_DIR=\$(HOME)/rpms
+
+\$(RPMS_DIR)/:
+ -mkdir @dirs
+
+SUBSTITUTE=$substitute
+
+perl-\$(DISTNAME).spec :: perl-\$(DISTNAME).spec.in \$(VERSION_FROM) Makefile
+ \$(SUBSTITUTE) \$< > \$@
+
+dist-rpms :: Makefile dist perl-\$(DISTNAME).spec \$(RPMS_DIR)/
+ cp \$(DISTNAME)-\$(VERSION).tar.gz \$(RPMS_DIR)/SOURCES/
+ rpmbuild -ba --define \"_topdir \$(RPMS_DIR)\" perl-\$(DISTNAME).spec
+
+dist-srpms :: Makefile dist perl-\$(DISTNAME).spec \$(RPMS_DIR)/
+ cp \$(DISTNAME)-\$(VERSION).tar.gz \$(RPMS_DIR)/SOURCES/
+ rpmbuild -bs --define \"_topdir \$(RPMS_DIR)\" perl-\$(DISTNAME).spec
+"
+}
diff --git a/README b/README
new file mode 100644
index 0000000..ca3f59e
--- /dev/null
+++ b/README
@@ -0,0 +1,178 @@
+NAME
+ ExtUtils::Depends - Easily build XS extensions that depend on XS
+ extensions
+
+SYNOPSIS
+ use ExtUtils::Depends;
+ $package = new ExtUtils::Depends ('pkg::name', 'base::package')
+ # set the flags and libraries to compile and link the module
+ $package->set_inc("-I/opt/blahblah");
+ $package->set_libs("-lmylib");
+ # add a .c and an .xs file to compile
+ $package->add_c('code.c');
+ $package->add_xs('module-code.xs');
+ # add the typemaps to use
+ $package->add_typemaps("typemap");
+ # install some extra data files and headers
+ $package->install (qw/foo.h data.txt/);
+ # save the info
+ $package->save_config('Files.pm');
+
+ WriteMakefile(
+ 'NAME' => 'Mymodule',
+ $package->get_makefile_vars()
+ );
+
+DESCRIPTION
+ This module tries to make it easy to build Perl extensions that use
+ functions and typemaps provided by other perl extensions. This means
+ that a perl extension is treated like a shared library that provides
+ also a C and an XS interface besides the perl one.
+
+ This works as long as the base extension is loaded with the RTLD_GLOBAL
+ flag (usually done with a
+
+ sub dl_load_flags {0x01}
+
+ in the main .pm file) if you need to use functions defined in the
+ module.
+
+ The basic scheme of operation is to collect information about a module
+ in the instance, and then store that data in the Perl library where it
+ may be retrieved later. The object can also reformat this information
+ into the data structures required by ExtUtils::MakeMaker's WriteMakefile
+ function.
+
+ When creating a new Depends object, you give it a name, which is the
+ name of the module you are building. You can also specify the names of
+ modules on which this module depends. These dependencies will be loaded
+ automatically, and their typemaps, header files, etc merged with your
+ new object's stuff. When you store the data for your object, the list of
+ dependencies are stored with it, so that another module depending on
+ your needn't know on exactly which modules yours depends.
+
+ For example:
+
+ Gtk2 depends on Glib
+
+ Gnome2::Canvas depends on Gtk2
+
+ ExtUtils::Depends->new ('Gnome2::Canvas', 'Gtk2');
+ this command automatically brings in all the stuff needed
+ for Glib, since Gtk2 depends on it.
+
+METHODS
+ $object = ExtUtils::Depends->new($name, @deps)
+ Create a new depends object named *$name*. Any modules listed in
+ *@deps* (which may be empty) are added as dependencies and their
+ dependency information is loaded. An exception is raised if any
+ dependency information cannot be loaded.
+
+ $depends->add_deps (@deps)
+ Add modules listed in *@deps* as dependencies.
+
+ (hashes) = $depends->get_deps
+ Fetch information on the dependencies of *$depends* as a hash of
+ hashes, which are dependency information indexed by module name. See
+ "load".
+
+ $depends->set_inc (@newinc)
+ Add strings to the includes or cflags variables.
+
+ $depends->set_libs (@newlibs)
+ Add strings to the libs (linker flags) variable.
+
+ $depends->add_pm (%pm_files)
+ Add files to the hash to be passed through ExtUtils::WriteMakefile's
+ PM key.
+
+ $depends->add_xs (@xs_files)
+ Add xs files to be compiled.
+
+ $depends->add_c (@c_files)
+ Add C files to be compiled.
+
+ $depends->add_typemaps (@typemaps)
+ Add typemap files to be used and installed.
+
+ $depends->add_headers (list)
+ No-op, for backward compatibility.
+
+ $depends->install (@files)
+ Install *@files* to the data directory for *$depends*.
+
+ This actually works by adding them to the hash of pm files that gets
+ passed through WriteMakefile's PM key.
+
+ $depends->save_config ($filename)
+ Save the important information from *$depends* to *$filename*, and
+ set it up to be installed as *name*::Install::Files.
+
+ Note: the actual value of *$filename* seems to be irrelevant, but
+ its usage is kept for backward compatibility.
+
+ hash = $depends->get_makefile_vars
+ Return the information in *$depends* in a format digestible by
+ WriteMakefile.
+
+ This sets at least the following keys:
+
+ INC
+ LIBS
+ TYPEMAPS
+ PM
+
+ And these if there is data to fill them:
+
+ clean
+ OBJECT
+ XS
+
+ hashref = ExtUtils::Depends::load (name)
+ Load and return dependency information for *name*. Croaks if no such
+ information can be found. The information is returned as an
+ anonymous hash containing these keys:
+
+ instpath
+ The absolute path to the data install directory for this module.
+
+ typemaps
+ List of absolute pathnames for this module's typemap files.
+
+ inc CFLAGS string for this module.
+
+ libs
+ LIBS string for this module.
+
+ deps
+ List of modules on which this one depends. This key will not
+ exist when loading files created by old versions of
+ ExtUtils::Depends.
+
+ $depends->load_deps
+ Load *$depends* dependencies, by calling "load" on each dependency
+ module. This is usually done for you, and should only be needed if
+ you want to call "get_deps" after calling "add_deps" manually.
+
+BUGS
+ Version 0.2 discards some of the more esoteric features provided by the
+ older versions. As they were completely undocumented, and this module
+ has yet to reach 1.0, this may not exactly be a bug.
+
+ This module is tightly coupled to the ExtUtils::MakeMaker architecture.
+
+SEE ALSO
+ ExtUtils::MakeMaker.
+
+AUTHOR
+ Paolo Molaro <lupus at debian dot org> wrote the original version for
+ Gtk-Perl. muppet <scott at asofyet dot org> rewrote the innards for
+ version 0.2, borrowing liberally from Paolo's code.
+
+MAINTAINER
+ The Gtk2 project, http://gtk2-perl.sf.net/
+
+LICENSE
+ This library is free software; you may redistribute it and/or modify it
+ under the same terms as Perl itself.
+
diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm
new file mode 100644
index 0000000..a2cea31
--- /dev/null
+++ b/lib/ExtUtils/Depends.pm
@@ -0,0 +1,551 @@
+#
+# $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/ExtUtils-Depends/lib/ExtUtils/Depends.pm,v 1.18 2008/03/30 15:36:23 kaffeetisch Exp $
+#
+
+package ExtUtils::Depends;
+
+use strict;
+use warnings;
+use Carp;
+use File::Find;
+use File::Spec;
+use Data::Dumper;
+
+our $VERSION = '0.300';
+
+sub import {
+ my $class = shift;
+ return unless @_;
+ die "$class version $_[0] is required--this is only version $VERSION"
+ if $VERSION < $_[0];
+}
+
+sub new {
+ my ($class, $name, @deps) = @_;
+ my $self = bless {
+ name => $name,
+ deps => {},
+ inc => [],
+ libs => '',
+
+ pm => {},
+ typemaps => [],
+ xs => [],
+ c => [],
+ }, $class;
+
+ $self->add_deps (@deps);
+
+ # attempt to load these now, so we'll find out as soon as possible
+ # whether the dependencies are valid. we'll load them again in
+ # get_makefile_vars to catch any added between now and then.
+ $self->load_deps;
+
+ return $self;
+}
+
+sub add_deps {
+ my $self = shift;
+ foreach my $d (@_) {
+ $self->{deps}{$d} = undef
+ unless $self->{deps}{$d};
+ }
+}
+
+sub get_deps {
+ my $self = shift;
+ $self->load_deps; # just in case
+
+ return %{$self->{deps}};
+}
+
+sub set_inc {
+ my $self = shift;
+ push @{ $self->{inc} }, @_;
+}
+
+sub set_libs {
+ my ($self, $newlibs) = @_;
+ $self->{libs} = $newlibs;
+}
+
+sub add_pm {
+ my ($self, %pm) = @_;
+ while (my ($key, $value) = each %pm) {
+ $self->{pm}{$key} = $value;
+ }
+}
+
+sub _listkey_add_list {
+ my ($self, $key, @list) = @_;
+ $self->{$key} = [] unless $self->{$key};
+ push @{ $self->{$key} }, @list;
+}
+
+sub add_xs { shift->_listkey_add_list ('xs', @_) }
+sub add_c { shift->_listkey_add_list ('c', @_) }
+sub add_typemaps {
+ my $self = shift;
+ $self->_listkey_add_list ('typemaps', @_);
+ $self->install (@_);
+}
+
+# no-op, only used for source back-compat
+sub add_headers { carp "add_headers() is a no-op" }
+
+####### PRIVATE
+sub basename { (File::Spec->splitdir ($_[0]))[-1] }
+# get the name in Makefile syntax.
+sub installed_filename {
+ my $self = shift;
+ return '$(INST_ARCHLIB)/$(FULLEXT)/Install/'.basename ($_[0]);
+}
+
+sub install {
+ # install things by adding them to the hash of pm files that gets
+ # passed through WriteMakefile's PM key.
+ my $self = shift;
+ foreach my $f (@_) {
+ $self->add_pm ($f, $self->installed_filename ($f));
+ }
+}
+
+sub save_config {
+ use Data::Dumper;
+ use IO::File;
+
+ my ($self, $filename) = @_;
+
+ my $file = IO::File->new (">".$filename)
+ or croak "can't open '$filename' for writing: $!\n";
+
+ print $file "package $self->{name}\::Install::Files;\n\n";
+ # for modern stuff
+ print $file "".Data::Dumper->Dump([{
+ inc => join (" ", @{ $self->{inc} }),
+ libs => $self->{libs},
+ typemaps => [ map { basename $_ } @{ $self->{typemaps} } ],
+ deps => [keys %{ $self->{deps} }],
+ }], ['self']);
+ # for ancient stuff
+ print $file "\n\n# this is for backwards compatiblity\n";
+ print $file "\@deps = \@{ \$self->{deps} };\n";
+ print $file "\@typemaps = \@{ \$self->{typemaps} };\n";
+ print $file "\$libs = \$self->{libs};\n";
+ print $file "\$inc = \$self->{inc};\n";
+ # this is riduculous, but old versions of ExtUtils::Depends take
+ # first $loadedmodule::CORE and then $INC{$file} --- the fallback
+ # includes the Filename.pm, which is not useful. so we must add
+ # this crappy code. we don't worry about portable pathnames,
+ # as the old code didn't either.
+ (my $mdir = $self->{name}) =~ s{::}{/}g;
+ print $file <<"EOT";
+
+ \$CORE = undef;
+ foreach (\@INC) {
+ if ( -f \$_ . "/$mdir/Install/Files.pm") {
+ \$CORE = \$_ . "/$mdir/Install/";
+ last;
+ }
+ }
+EOT
+
+ print $file "\n1;\n";
+
+ close $file;
+
+ # we need to ensure that the file we just created gets put into
+ # the install dir with everything else.
+ #$self->install ($filename);
+ $self->add_pm ($filename, $self->installed_filename ('Files.pm'));
+}
+
+sub load {
+ my $dep = shift;
+ my @pieces = split /::/, $dep;
+ my @suffix = qw/ Install Files /;
+ my $relpath = File::Spec->catfile (@pieces, @suffix) . '.pm';
+ my $depinstallfiles = join "::", @pieces, @suffix;
+ eval {
+ require $relpath
+ } or die " *** Can't load dependency information for $dep:\n $@\n";
+ #
+ #print Dumper(\%INC);
+
+ # effectively $instpath = dirname($INC{$relpath})
+ @pieces = File::Spec->splitdir ($INC{$relpath});
+ pop @pieces;
+ my $instpath = File::Spec->catdir (@pieces);
+
+ no strict;
+
+ croak "No dependency information found for $dep"
+ unless $instpath;
+
+ if (not File::Spec->file_name_is_absolute ($instpath)) {
+ $instpath = File::Spec->rel2abs ($instpath);
+ }
+
+ my @typemaps = map {
+ File::Spec->rel2abs ($_, $instpath)
+ } @{"$depinstallfiles\::typemaps"};
+
+ {
+ instpath => $instpath,
+ typemaps => \@typemaps,
+ inc => "-I$instpath ".${"$depinstallfiles\::inc"},
+ libs => ${"$depinstallfiles\::libs"},
+ # this will not exist when loading files from old versions
+ # of ExtUtils::Depends.
+ (exists ${"$depinstallfiles\::"}{deps}
+ ? (deps => \@{"$depinstallfiles\::deps"})
+ : ()),
+ }
+}
+
+sub load_deps {
+ my $self = shift;
+ my @load = grep { not $self->{deps}{$_} } keys %{ $self->{deps} };
+ foreach my $d (@load) {
+ my $dep = load ($d);
+ $self->{deps}{$d} = $dep;
+ if ($dep->{deps}) {
+ foreach my $childdep (@{ $dep->{deps} }) {
+ push @load, $childdep
+ unless
+ $self->{deps}{$childdep}
+ or
+ grep {$_ eq $childdep} @load;
+ }
+ }
+ }
+}
+
+sub uniquify {
+ my %seen;
+ # we use a seen hash, but also keep indices to preserve
+ # first-seen order.
+ my $i = 0;
+ foreach (@_) {
+ $seen{$_} = ++$i
+ unless exists $seen{$_};
+ }
+ #warn "stripped ".(@_ - (keys %seen))." redundant elements\n";
+ sort { $seen{$a} <=> $seen{$b} } keys %seen;
+}
+
+
+sub get_makefile_vars {
+ my $self = shift;
+
+ # collect and uniquify things from the dependencies.
+ # first, ensure they are completely loaded.
+ $self->load_deps;
+
+ ##my @defbits = map { split } @{ $self->{defines} };
+ my @incbits = map { split } @{ $self->{inc} };
+ my @libsbits = split /\s+/, $self->{libs};
+ my @typemaps = @{ $self->{typemaps} };
+ foreach my $d (keys %{ $self->{deps} }) {
+ my $dep = $self->{deps}{$d};
+ #push @defbits, @{ $dep->{defines} };
+ push @incbits, @{ $dep->{defines} } if $dep->{defines};
+ push @incbits, split /\s+/, $dep->{inc} if $dep->{inc};
+ push @libsbits, split /\s+/, $dep->{libs} if $dep->{libs};
+ push @typemaps, @{ $dep->{typemaps} } if $dep->{typemaps};
+ }
+
+ # we have a fair bit of work to do for the xs files...
+ my @clean = ();
+ my @OBJECT = ();
+ my %XS = ();
+ foreach my $xs (@{ $self->{xs} }) {
+ (my $c = $xs) =~ s/\.xs$/\.c/i;
+ (my $o = $xs) =~ s/\.xs$/\$(OBJ_EXT)/i;
+ $XS{$xs} = $c;
+ push @OBJECT, $o;
+ # according to the MakeMaker manpage, the C files listed in
+ # XS will be added automatically to the list of cleanfiles.
+ push @clean, $o;
+ }
+
+ # we may have C files, as well:
+ foreach my $c (@{ $self->{c} }) {
+ (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i;
+ push @OBJECT, $o;
+ push @clean, $o;
+ }
+
+ my %vars = (
+ INC => join (' ', uniquify @incbits),
+ LIBS => join (' ', uniquify $self->find_extra_libs, @libsbits),
+ TYPEMAPS => [@typemaps],
+ );
+
+ # we don't want to provide these if there is no data in them;
+ # that way, the caller can still get default behavior out of
+ # MakeMaker when INC, LIBS and TYPEMAPS are all that are required.
+ $vars{PM} = $self->{pm}
+ if %{ $self->{pm} };
+ $vars{clean} = { FILES => join (" ", @clean), }
+ if @clean;
+ $vars{OBJECT} = join (" ", @OBJECT)
+ if @OBJECT;
+ $vars{XS} = \%XS
+ if %XS;
+
+ %vars;
+}
+
+sub find_extra_libs {
+ my $self = shift;
+
+ my %mappers = (
+ MSWin32 => sub { $_[0] . '.lib' },
+ cygwin => sub { 'lib' . $_[0] . '.dll.a'},
+ );
+ my $mapper = $mappers{$^O};
+ return () unless defined $mapper;
+
+ my @found_libs = ();
+ foreach my $name (keys %{ $self->{deps} }) {
+ (my $stem = $name) =~ s/^.*:://;
+ my $lib = $mapper->($stem);
+ my $pattern = qr/$lib$/;
+
+ my $matching_file;
+ find (sub {
+ if ((not $matching_file) && /$pattern/) {;
+ $matching_file = $File::Find::name;
+ }
+ }, map { -d $_ ? ($_) : () } @INC); # only extant dirs
+
+ if ($matching_file && -f $matching_file) {
+ push @found_libs, $matching_file;
+ next;
+ }
+ }
+
+ return @found_libs;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+ExtUtils::Depends - Easily build XS extensions that depend on XS extensions
+
+=head1 SYNOPSIS
+
+ use ExtUtils::Depends;
+ $package = new ExtUtils::Depends ('pkg::name', 'base::package')
+ # set the flags and libraries to compile and link the module
+ $package->set_inc("-I/opt/blahblah");
+ $package->set_libs("-lmylib");
+ # add a .c and an .xs file to compile
+ $package->add_c('code.c');
+ $package->add_xs('module-code.xs');
+ # add the typemaps to use
+ $package->add_typemaps("typemap");
+ # install some extra data files and headers
+ $package->install (qw/foo.h data.txt/);
+ # save the info
+ $package->save_config('Files.pm');
+
+ WriteMakefile(
+ 'NAME' => 'Mymodule',
+ $package->get_makefile_vars()
+ );
+
+=head1 DESCRIPTION
+
+This module tries to make it easy to build Perl extensions that use
+functions and typemaps provided by other perl extensions. This means
+that a perl extension is treated like a shared library that provides
+also a C and an XS interface besides the perl one.
+
+This works as long as the base extension is loaded with the RTLD_GLOBAL
+flag (usually done with a
+
+ sub dl_load_flags {0x01}
+
+in the main .pm file) if you need to use functions defined in the module.
+
+The basic scheme of operation is to collect information about a module
+in the instance, and then store that data in the Perl library where it
+may be retrieved later. The object can also reformat this information
+into the data structures required by ExtUtils::MakeMaker's WriteMakefile
+function.
+
+When creating a new Depends object, you give it a name, which is the name
+of the module you are building. You can also specify the names of modules
+on which this module depends. These dependencies will be loaded
+automatically, and their typemaps, header files, etc merged with your new
+object's stuff. When you store the data for your object, the list of
+dependencies are stored with it, so that another module depending on your
+needn't know on exactly which modules yours depends.
+
+For example:
+
+ Gtk2 depends on Glib
+
+ Gnome2::Canvas depends on Gtk2
+
+ ExtUtils::Depends->new ('Gnome2::Canvas', 'Gtk2');
+ this command automatically brings in all the stuff needed
+ for Glib, since Gtk2 depends on it.
+
+
+=head1 METHODS
+
+=over
+
+=item $object = ExtUtils::Depends->new($name, @deps)
+
+Create a new depends object named I<$name>. Any modules listed in I<@deps>
+(which may be empty) are added as dependencies and their dependency
+information is loaded. An exception is raised if any dependency information
+cannot be loaded.
+
+=item $depends->add_deps (@deps)
+
+Add modules listed in I<@deps> as dependencies.
+
+=item (hashes) = $depends->get_deps
+
+Fetch information on the dependencies of I<$depends> as a hash of hashes,
+which are dependency information indexed by module name. See C<load>.
+
+=item $depends->set_inc (@newinc)
+
+Add strings to the includes or cflags variables.
+
+=item $depends->set_libs (@newlibs)
+
+Add strings to the libs (linker flags) variable.
+
+=item $depends->add_pm (%pm_files)
+
+Add files to the hash to be passed through ExtUtils::WriteMakefile's
+PM key.
+
+=item $depends->add_xs (@xs_files)
+
+Add xs files to be compiled.
+
+=item $depends->add_c (@c_files)
+
+Add C files to be compiled.
+
+=item $depends->add_typemaps (@typemaps)
+
+Add typemap files to be used and installed.
+
+=item $depends->add_headers (list)
+
+No-op, for backward compatibility.
+
+=item $depends->install (@files)
+
+Install I<@files> to the data directory for I<$depends>.
+
+This actually works by adding them to the hash of pm files that gets
+passed through WriteMakefile's PM key.
+
+=item $depends->save_config ($filename)
+
+Save the important information from I<$depends> to I<$filename>, and
+set it up to be installed as I<name>::Install::Files.
+
+Note: the actual value of I<$filename> seems to be irrelevant, but its
+usage is kept for backward compatibility.
+
+=item hash = $depends->get_makefile_vars
+
+Return the information in I<$depends> in a format digestible by
+WriteMakefile.
+
+This sets at least the following keys:
+
+ INC
+ LIBS
+ TYPEMAPS
+ PM
+
+And these if there is data to fill them:
+
+ clean
+ OBJECT
+ XS
+
+=item hashref = ExtUtils::Depends::load (name)
+
+Load and return dependency information for I<name>. Croaks if no such
+information can be found. The information is returned as an anonymous
+hash containing these keys:
+
+=over
+
+=item instpath
+
+The absolute path to the data install directory for this module.
+
+=item typemaps
+
+List of absolute pathnames for this module's typemap files.
+
+=item inc
+
+CFLAGS string for this module.
+
+=item libs
+
+LIBS string for this module.
+
+=item deps
+
+List of modules on which this one depends. This key will not exist when
+loading files created by old versions of ExtUtils::Depends.
+
+=back
+
+=item $depends->load_deps
+
+Load I<$depends> dependencies, by calling C<load> on each dependency module.
+This is usually done for you, and should only be needed if you want to call
+C<get_deps> after calling C<add_deps> manually.
+
+=back
+
+
+=head1 BUGS
+
+Version 0.2 discards some of the more esoteric features provided by the
+older versions. As they were completely undocumented, and this module
+has yet to reach 1.0, this may not exactly be a bug.
+
+This module is tightly coupled to the ExtUtils::MakeMaker architecture.
+
+=head1 SEE ALSO
+
+ExtUtils::MakeMaker.
+
+=head1 AUTHOR
+
+Paolo Molaro <lupus at debian dot org> wrote the original version for
+Gtk-Perl. muppet <scott at asofyet dot org> rewrote the innards for
+version 0.2, borrowing liberally from Paolo's code.
+
+=head1 MAINTAINER
+
+The Gtk2 project, http://gtk2-perl.sf.net/
+
+=head1 LICENSE
+
+This library is free software; you may redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
diff --git a/perl-ExtUtils-Depends.spec.in b/perl-ExtUtils-Depends.spec.in
new file mode 100644
index 0000000..1558add
--- /dev/null
+++ b/perl-ExtUtils-Depends.spec.in
@@ -0,0 +1,54 @@
+Summary: ExtUtils-Depends Perl module
+Name: perl-ExtUtils-Depends
+Version: @VERSION@
+Release: 1
+Packager: gtk-perl-list at gnome.org
+License: LGPL
+Group: Development/Tools
+URL: http://search.cpan.org/dist/ExtUtils-Depends/
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
+BuildArch: noarch
+BuildRequires: perl >= 2:5.8.0
+Source0: @SOURCE@
+
+%description
+This module tries to make it easy to build Perl extensions that use functions
+and typemaps provided by other perl extensions. This means that a perl
+extension is treated like a shared library that provides also a C and an XS
+interface besides the perl one. This works as long as the base extension is
+loaded with the RTLD_GLOBAL flag (usually done with a sub dl_load_flags {0x01}
+in the main .pm file) if you need to use functions defined in the module.
+
+%prep
+%setup -q -n ExtUtils-Depends-%{version}
+
+%build
+CFLAGS="$RPM_OPT_FLAGS" perl Makefile.PL PREFIX=$RPM_BUILD_ROOT%{_prefix}
+make OPTIMIZE="$RPM_OPT_FLAGS"
+make test
+
+%install
+%makeinstall
+
+[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress
+
+find $RPM_BUILD_ROOT \( -name perllocal.pod -o -name .packlist \) -exec rm -v {} \;
+
+find $RPM_BUILD_ROOT/usr -type f -print | \
+ sed "s@^$RPM_BUILD_ROOT@@g" | \
+ grep -v perllocal.pod | \
+ grep -v "\.packlist" > %{name}-%{version}-filelist
+if [ "$(cat %{name}-%{version}-filelist)X" = "X" ] ; then
+ exit -1
+fi
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files -f %{name}-%{version}-filelist
+%defattr(-,root,root)
+
+%changelog
+* @DATE@ gtk-perl-list at gnome.org - @VERSION@
+- Specfile autogenerated.
+
diff --git a/t/01_load.t b/t/01_load.t
new file mode 100644
index 0000000..2004925
--- /dev/null
+++ b/t/01_load.t
@@ -0,0 +1,6 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+use_ok ('ExtUtils::Depends');
diff --git a/t/02_save_load.t b/t/02_save_load.t
new file mode 100644
index 0000000..b08010f
--- /dev/null
+++ b/t/02_save_load.t
@@ -0,0 +1,85 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More tests => 24;
+use ExtUtils::Depends;
+
+my $dep_info = ExtUtils::Depends->new ('DepTest');
+
+my $inc = '-Iinclude -I/usr/local/include -W -Wall -Werror -ansi';
+$dep_info->set_inc ($inc);
+
+my $libs = '-L/usr/local/lib -lfoobar';
+$dep_info->set_libs ($libs);
+
+my %pm_mapping = ('DepTest.pm' => 'build/DepTest.pm',
+ 'DepTest/Helper.pm' => 'build/DepTest/Helper.pm');
+$dep_info->add_pm (%pm_mapping);
+
+my @xs_files = qw(DepTestFoo.xs
+ DepTestBar.xs);
+$dep_info->add_xs (@xs_files);
+
+my @c_files = qw(dep-test-foo.c
+ dep-test-bar.c);
+$dep_info->add_c (@c_files);
+
+my @typemaps = qw(build/foo.typemap
+ build/bar.typemap);
+$dep_info->add_typemaps (@typemaps);
+
+my @installed_files = qw(dep.h
+ dep-private.h);
+$dep_info->install (@installed_files);
+
+$dep_info->save_config ('t/inc/DepTest/Install/Files.pm');
+
+# --------------------------------------------------------------------------- #
+
+my %vars = $dep_info->get_makefile_vars;
+is_deeply ($vars{TYPEMAPS}, \@typemaps);
+is ($vars{INC}, $inc);
+is ($vars{LIBS}, $libs);
+
+foreach my $pm (keys %pm_mapping) {
+ like ($vars{PM}{$pm}, qr/\Q$pm_mapping{$pm}\E/);
+}
+
+ok (exists $vars{PM}{'t/inc/DepTest/Install/Files.pm'});
+
+foreach my $file (@installed_files) {
+ like ($vars{PM}{$file}, qr/\Q$file\E/);
+}
+
+foreach my $xs_file (@xs_files) {
+ ok (exists $vars{XS}{$xs_file});
+}
+
+foreach my $file (@c_files, @xs_files) {
+ (my $stem = $file) =~ s/\.(?:c|xs)\z//;
+ like ($vars{OBJECT}, qr/\Q$stem\E/);
+ like ($vars{clean}{FILES}, qr/\Q$stem\E/);
+}
+
+# --------------------------------------------------------------------------- #
+
+use lib qw(t/inc);
+
+my $info = ExtUtils::Depends::load ('DepTest');
+
+my $install_part = qr|DepTest.Install|;
+like ($info->{inc}, $install_part);
+ok (-1 != index $info->{inc}, $inc);
+
+isa_ok ($info->{typemaps}, 'ARRAY');
+
+like ($info->{instpath}, $install_part);
+
+is_deeply ($info->{deps}, []);
+
+is ($info->{libs}, $libs);
+
+# --------------------------------------------------------------------------- #
+
+unlink 't/inc/DepTest/Install/Files.pm';
diff --git a/t/03_deps.t b/t/03_deps.t
new file mode 100644
index 0000000..51e9566
--- /dev/null
+++ b/t/03_deps.t
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+use ExtUtils::Depends;
+
+my $dep_info = ExtUtils::Depends->new ('DepTest');
+$dep_info->save_config ('t/inc/DepTest/Install/Files.pm');
+
+# --------------------------------------------------------------------------- #
+
+use lib qw(t/inc);
+
+my $info = ExtUtils::Depends->new ('UseTest', 'DepTest');
+
+my %deps = $info->get_deps;
+ok (exists $deps{DepTest});
+
+# --------------------------------------------------------------------------- #
+
+$info = ExtUtils::Depends->new ('UseTest');
+$info->add_deps ('DepTest');
+$info->load_deps;
+
+%deps = $info->get_deps;
+ok (exists $deps{DepTest});
+
+# --------------------------------------------------------------------------- #
+
+unlink 't/inc/DepTest/Install/Files.pm';
diff --git a/t/04_extra_libs.t b/t/04_extra_libs.t
new file mode 100644
index 0000000..90700f4
--- /dev/null
+++ b/t/04_extra_libs.t
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More;
+use ExtUtils::Depends;
+
+plan (($^O eq 'MSWin32' || $^O eq 'cygwin') ?
+ (tests => 1) :
+ (skip_all => 'test only applicable to MSWin32 and cygwin'));
+
+my $dep_info = ExtUtils::Depends->new ('DepTest');
+$dep_info->save_config ('t/inc/DepTest/Install/Files.pm');
+
+# --------------------------------------------------------------------------- #
+
+use lib qw(t/inc);
+
+my $use_info = ExtUtils::Depends->new ('UseTest', 'DepTest');
+my %vars = $use_info->get_makefile_vars;
+
+like ($vars{LIBS}, qr/DepTest/);
+
+# --------------------------------------------------------------------------- #
+
+unlink 't/inc/DepTest/Install/Files.pm';
diff --git a/t/inc/DepTest/DepTest.lib b/t/inc/DepTest/DepTest.lib
new file mode 100644
index 0000000..e69de29
diff --git a/t/inc/DepTest/Install/.keep b/t/inc/DepTest/Install/.keep
new file mode 100644
index 0000000..e69de29
--
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