r66479 - in /branches/upstream/libextutils-libbuilder-perl: ./ current/ current/lib/ current/lib/ExtUtils/ current/t/

danai at users.alioth.debian.org danai at users.alioth.debian.org
Mon Dec 27 00:38:49 UTC 2010


Author: danai
Date: Mon Dec 27 00:38:40 2010
New Revision: 66479

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=66479
Log:
[svn-inject] Installing original source of libextutils-libbuilder-perl (0.04)

Added:
    branches/upstream/libextutils-libbuilder-perl/
    branches/upstream/libextutils-libbuilder-perl/current/
    branches/upstream/libextutils-libbuilder-perl/current/Build.PL
    branches/upstream/libextutils-libbuilder-perl/current/Changes
    branches/upstream/libextutils-libbuilder-perl/current/MANIFEST
    branches/upstream/libextutils-libbuilder-perl/current/META.yml
    branches/upstream/libextutils-libbuilder-perl/current/README
    branches/upstream/libextutils-libbuilder-perl/current/lib/
    branches/upstream/libextutils-libbuilder-perl/current/lib/ExtUtils/
    branches/upstream/libextutils-libbuilder-perl/current/lib/ExtUtils/LibBuilder.pm
    branches/upstream/libextutils-libbuilder-perl/current/t/
    branches/upstream/libextutils-libbuilder-perl/current/t/00-load.t
    branches/upstream/libextutils-libbuilder-perl/current/t/01-simple.t
    branches/upstream/libextutils-libbuilder-perl/current/t/manifest.t
    branches/upstream/libextutils-libbuilder-perl/current/t/pod-coverage.t
    branches/upstream/libextutils-libbuilder-perl/current/t/pod.t

Added: branches/upstream/libextutils-libbuilder-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-libbuilder-perl/current/Build.PL?rev=66479&op=file
==============================================================================
--- branches/upstream/libextutils-libbuilder-perl/current/Build.PL (added)
+++ branches/upstream/libextutils-libbuilder-perl/current/Build.PL Mon Dec 27 00:38:40 2010
@@ -1,0 +1,19 @@
+use strict;
+use warnings;
+use Module::Build;
+
+my $builder = Module::Build->new(
+    module_name         => 'ExtUtils::LibBuilder',
+    license             => 'perl',
+    dist_author         => q{Alberto Simoes <ambs at cpan.org>},
+    dist_version_from   => 'lib/ExtUtils/LibBuilder.pm',
+    build_requires => {
+                       'ExtUtils::CBuilder' => '0.23',
+                       'File::Spec' => 0,
+                       'File::Temp' => 0,
+                       'Test::More' => 0,
+    },
+    add_to_cleanup      => [ 'ExtUtils-LibBuilder-*' ],
+);
+
+$builder->create_build_script();

Added: branches/upstream/libextutils-libbuilder-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-libbuilder-perl/current/Changes?rev=66479&op=file
==============================================================================
--- branches/upstream/libextutils-libbuilder-perl/current/Changes (added)
+++ branches/upstream/libextutils-libbuilder-perl/current/Changes Mon Dec 27 00:38:40 2010
@@ -1,0 +1,18 @@
+Revision history for ExtUtils-LibBuilder
+
+0.04    Sun Nov 21 13:38:35 WET 2010
+        - Trying my luck on IRIX...
+
+0.03    Sat Oct  9 15:06:40 WEST 2010
+        - Mainly documentation fixes.
+
+0.02    Fri Sep 24 09:34:01 WEST 2010
+        - Fixed tests and their relative search paths.
+
+0.01    Thu Sep 23 21:19:17 WEST 2010
+        - Ported the code from Config::AutoConf::Linker to this new module
+        - Factorized the code for readability and usability
+        - Still missing real documentation (check t/01-simple.t for an example)
+        - Should work on Linux, MacOS X and Strawberry Perl.
+          Let me know of other supported operating systems. Thank you!
+

Added: branches/upstream/libextutils-libbuilder-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-libbuilder-perl/current/MANIFEST?rev=66479&op=file
==============================================================================
--- branches/upstream/libextutils-libbuilder-perl/current/MANIFEST (added)
+++ branches/upstream/libextutils-libbuilder-perl/current/MANIFEST Mon Dec 27 00:38:40 2010
@@ -1,0 +1,11 @@
+Build.PL
+Changes
+MANIFEST
+README
+lib/ExtUtils/LibBuilder.pm
+t/00-load.t
+t/01-simple.t
+t/manifest.t
+t/pod-coverage.t
+t/pod.t
+META.yml

Added: branches/upstream/libextutils-libbuilder-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-libbuilder-perl/current/META.yml?rev=66479&op=file
==============================================================================
--- branches/upstream/libextutils-libbuilder-perl/current/META.yml (added)
+++ branches/upstream/libextutils-libbuilder-perl/current/META.yml Mon Dec 27 00:38:40 2010
@@ -1,0 +1,24 @@
+---
+abstract: 'A tool to build C libraries.'
+author:
+  - 'Alberto Simoes <ambs at cpan.org>'
+build_requires:
+  ExtUtils::CBuilder: 0.23
+  File::Spec: 0
+  File::Temp: 0
+  Test::More: 0
+configure_requires:
+  Module::Build: 0.36
+generated_by: 'Module::Build version 0.3607'
+license: perl
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: 1.4
+name: ExtUtils-LibBuilder
+provides:
+  ExtUtils::LibBuilder:
+    file: lib/ExtUtils/LibBuilder.pm
+    version: 0.04
+resources:
+  license: http://dev.perl.org/licenses/
+version: 0.04

Added: branches/upstream/libextutils-libbuilder-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-libbuilder-perl/current/README?rev=66479&op=file
==============================================================================
--- branches/upstream/libextutils-libbuilder-perl/current/README (added)
+++ branches/upstream/libextutils-libbuilder-perl/current/README Mon Dec 27 00:38:40 2010
@@ -1,0 +1,52 @@
+
+==  ExtUtils-LibBuilder ==
+
+Some Perl modules need to ship C libraries together with their Perl
+code. Although there are mechanisms to compile and link (or glue) C
+code in your Perl programs, there isn't a clear method to compile
+standard, self-contained C libraries.
+
+This module main goal is to help in that task.
+
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+	perl Build.PL
+	./Build
+	./Build test
+	./Build install
+
+SUPPORT AND DOCUMENTATION
+
+After installing, you can find documentation for this module with the
+perldoc command.
+
+    perldoc ExtUtils::LibBuilder
+
+You can also look for information at:
+
+    RT, CPAN's request tracker
+        http://rt.cpan.org/NoAuth/Bugs.html?Dist=ExtUtils-LibBuilder
+
+    AnnoCPAN, Annotated CPAN documentation
+        http://annocpan.org/dist/ExtUtils-LibBuilder
+
+    CPAN Ratings
+        http://cpanratings.perl.org/d/ExtUtils-LibBuilder
+
+    Search CPAN
+        http://search.cpan.org/dist/ExtUtils-LibBuilder/
+
+
+LICENSE AND COPYRIGHT
+
+Copyright (C) 2010 Alberto Simoes
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of either: the GNU General Public License as published
+by the Free Software Foundation; or the Artistic License.
+
+See http://dev.perl.org/licenses/ for more information.
+

Added: branches/upstream/libextutils-libbuilder-perl/current/lib/ExtUtils/LibBuilder.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-libbuilder-perl/current/lib/ExtUtils/LibBuilder.pm?rev=66479&op=file
==============================================================================
--- branches/upstream/libextutils-libbuilder-perl/current/lib/ExtUtils/LibBuilder.pm (added)
+++ branches/upstream/libextutils-libbuilder-perl/current/lib/ExtUtils/LibBuilder.pm Mon Dec 27 00:38:40 2010
@@ -1,0 +1,226 @@
+package ExtUtils::LibBuilder;
+
+use warnings;
+use strict;
+
+our $VERSION = '0.04';
+our $DEBUG   = 0;
+
+use base 'ExtUtils::CBuilder';
+
+use File::Spec;
+use File::Temp qw/tempdir/;
+
+=head1 NAME
+
+ExtUtils::LibBuilder - A tool to build C libraries.
+
+=head1 SYNOPSIS
+
+    use ExtUtils::LibBuilder;
+    my $libbuilder = ExtUtils::LibBuilder->new( %options );
+
+=head1 METHODS
+
+Supports all the method from ExtUtils::CBuilder. The following three
+methods were adapted to be used in standalone C libraries.
+
+=head2 new
+
+This method creates a new ExtUtils::LibBuilder object. While it
+supports all C<ExtUtils::CBuilder> methods some might work slightly
+differently (namely the two bellow).
+
+You can supply to the constructor any option recognized by
+C<ExtUtils::CBuilder> constructor. None of them will be used by
+C<LibBuilder>.
+
+=head2 link
+
+   $libbuilder -> link( objects     => [ "foo.o", "bar.o" ],
+                        module_name => "foobar",
+                        lib_file    => "libfoobar$libbuilder->{libext}");
+
+Options to the link method are the same as the C<CBuilder>
+counterpart. Note that the result is a standalone C Library and not a
+bundle to be loaded by Perl.
+
+Also, note that you can use the C<libext> key to retrieve from the
+object the common library extension on the running system (including
+the dot).
+
+=head2 link_executable
+
+  $libbuilder->link_executable( objects => ["main.o"],
+                                extra_linker_flags => "-L. -lfoobar",
+                                exe_file => "foobarcmd$libbuilder->{exeext}");
+
+The C<link_executable> needs, as C<extra_linker_flags> options, the
+name of the library and the search path. Future versions might include
+better handling on the library files.
+
+Also, note that you can use the C<exeext> key to retrieve from the
+object the common executable extension on the running system
+(including the dot).
+
+=cut
+
+sub new {
+    my $class = shift;
+    my %options = @_;
+
+    my $self = bless ExtUtils::CBuilder->new(%options) => $class;
+    # $self->{quiet} = 1;
+
+    $self->{libext} = $^O eq "darwin" ? ".dylib" : ( $^O =~ /win/i ? ".dll" : ".so");
+    $self->{exeext} = $^O =~ /win32/i ? ".exe" : "";
+
+    $DEBUG && print STDERR "\nTesting Linux\n\n";
+    return $self if $^O !~ /darwin|win32/i && $self->_try;
+
+    $DEBUG && print STDERR "\nTesting Darwin\n\n";
+    $self->{config}{lddlflags} =~ s/-bundle/-dynamiclib/;
+    return $self if $^O !~ /win32/i && $self->_try;
+
+    $DEBUG && print STDERR "\nTesting Win32\n\n";
+    *link = sub {
+        my ($self, %options) = @_;
+        my $LD = $self->{config}{ld};
+        $options{objects} = [$options{objects}] unless ref $options{objects};
+        system($LD, "-shared", "-o",
+               $options{lib_file},
+               @{$options{objects}});
+    };
+    *link_executable = sub {
+        my ($self, %options) = @_;
+        my $LD = $self->{config}{ld};
+        my @CFLAGS = split /\s+/, $options{extra_linker_flags};
+        $options{objects} = [$options{objects}] unless ref $options{objects};
+        system($LD, "-o",
+               $options{exe_file},
+               @CFLAGS,
+               @{$options{objects}});
+    };
+    return $self if $self->_try;
+
+    $DEBUG && print STDERR "\nNothing...\n\n";
+    return undef;
+}
+
+sub _try {
+    my ($self) = @_;
+    my $tmp = tempdir CLEANUP => 1;
+    _write_files($tmp);
+
+    my @csources = map { File::Spec->catfile($tmp, $_) } qw'library.c test.c';
+    my @cobjects = map { $self->compile( source => $_) } @csources;
+
+    my $libfile = File::Spec->catfile($tmp => "libfoo$self->{libext}");
+    my $exefile = File::Spec->catfile($tmp => "foo$self->{exeext}");
+
+    $self->link( objects     => [$cobjects[0]],
+                 module_name => "foo",
+                 lib_file    => $libfile );
+
+    return 0 unless -f $libfile;
+
+    $self->link_executable( exe_file           => $exefile,
+                            extra_linker_flags => "-L$tmp -lfoo",
+                            objects => [$cobjects[1]]);
+
+    return 0 unless -f $exefile && -x _;
+    return 1;
+}
+
+=head1 AUTHOR
+
+Alberto Simoes, C<< <ambs at cpan.org> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to
+C<bug-extutils-libbuilder at rt.cpan.org>, or through the web
+interface at
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ExtUtils-LibBuilder>.
+I will be notified, and then you'll automatically be notified of
+progress on your bug as I make changes.
+
+
+
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+    perldoc ExtUtils::LibBuilder
+
+
+You can also look for information at:
+
+=over 4
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=ExtUtils-LibBuilder>
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/ExtUtils-LibBuilder>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/ExtUtils-LibBuilder>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/ExtUtils-LibBuilder/>
+
+=back
+
+=head1 LICENSE AND COPYRIGHT
+
+Copyright 2010 Alberto Simoes.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of either: the GNU General Public License as published
+by the Free Software Foundation; or the Artistic License.
+
+See http://dev.perl.org/licenses/ for more information.
+
+
+=cut
+
+
+sub _write_files {
+    my $outpath = shift;
+    my $fh;
+    seek DATA, 0, 0;
+    while(<DATA>) {
+        if (m!^==\[(.*?)\]==!) {
+	    my $fname = $1;
+            $fname = File::Spec->catfile($outpath, $fname);
+            open $fh, ">$fname" or die "Can't create temporary file $fname\n";
+        } elsif ($fh) {
+            print $fh $_;
+        }
+    }
+}
+
+1; # End of ExtUtils::LibBuilder
+
+
+__DATA__
+==[library.c]==
+  int answer(void) {
+      return 42;
+  }
+==[test.c]==
+#include <stdio.h>
+extern int answer(void);
+int main() {
+    int a = answer();
+    printf("%d\n", a);
+    return 0;
+}
+
+

Added: branches/upstream/libextutils-libbuilder-perl/current/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-libbuilder-perl/current/t/00-load.t?rev=66479&op=file
==============================================================================
--- branches/upstream/libextutils-libbuilder-perl/current/t/00-load.t (added)
+++ branches/upstream/libextutils-libbuilder-perl/current/t/00-load.t Mon Dec 27 00:38:40 2010
@@ -1,0 +1,10 @@
+#!perl -T
+
+use Test::More tests => 1;
+
+BEGIN {
+    use_ok( 'ExtUtils::LibBuilder' ) || print "Bail out!\n";
+}
+
+diag( "Testing ExtUtils::LibBuilder $ExtUtils::LibBuilder::VERSION, Perl $], $^X" );
+

Added: branches/upstream/libextutils-libbuilder-perl/current/t/01-simple.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-libbuilder-perl/current/t/01-simple.t?rev=66479&op=file
==============================================================================
--- branches/upstream/libextutils-libbuilder-perl/current/t/01-simple.t (added)
+++ branches/upstream/libextutils-libbuilder-perl/current/t/01-simple.t Mon Dec 27 00:38:40 2010
@@ -1,0 +1,89 @@
+#!perl
+
+use Test::More tests => 7;
+use ExtUtils::LibBuilder;
+
+our @CLEAN;
+
+my $libbuilder = ExtUtils::LibBuilder->new();
+
+isa_ok($libbuilder, 'ExtUtils::CBuilder');
+
+open OUT, ">", "lib.c" or die "Can't create test file";
+print OUT <<'EOT';
+int sum(int a, int b) { return a + b; }
+EOT
+close OUT;
+add_to_cleanup("lib.c");
+
+$libbuilder->compile( source => 'lib.c' );
+ok(-f "lib.o");
+add_to_cleanup("lib.o");
+
+$libbuilder->link( objects     => "lib.o",
+                   module_name => "bar",
+                   lib_file    => "libbar$libbuilder->{libext}");
+ok(-f "libbar$libbuilder->{libext}");
+add_to_cleanup("libbar$libbuilder->{libext}");
+
+open OUT, ">", "main.c" or die "Can't create test file";
+print OUT <<'EOT';
+#include <stdio.h>
+extern int sum(int a, int b);
+int main(void) {
+  int a, b, c;
+  a = 5;
+  b = sum(a, a);
+  c = sum(a, b);
+  printf("%d\n", c);
+  return 0;
+}
+EOT
+close OUT;
+add_to_cleanup("main.c");
+
+$libbuilder->compile( source => 'main.c' );
+add_to_cleanup("main.o");
+ok(-f "main.o");
+
+$libbuilder->link_executable( exe_file => "add$libbuilder->{exeext}",
+                              extra_linker_flags => "-L. -lbar",
+                              objects => ["main.o"]);
+ok(-f "add$libbuilder->{exeext}");
+ok(-x "add$libbuilder->{exeext}");
+add_to_cleanup("add$libbuilder->{exeext}");
+
+
+if ($^O =~ /mswin32/i) {
+    $ENV{PATH} = ".;$ENV{PATH}";
+} elsif ($^O =~ /darwin/i) {
+    $ENV{DYLD_LIBRARY_PATH} = ".";
+}
+elsif ($^O =~ /(?:linux|bsd|sun|sol|dragonfly|hpux|irix)/i) {
+    $ENV{LD_LIBRARY_PATH} = ".";
+    if ($^O =~ /irix/) {
+        # trying my luck
+        $ENV{LD_LIBRARYN32_PATH} = ".";
+        $ENV{LD_LIBRARYN64_PATH} = ".";
+    }
+}
+elsif ($^O =~ /aix/i) {
+    my $oldlibpath = $ENV{LIBPATH} || '/lib:/usr/lib';
+    $ENV{LIBPATH} = ".:$oldlibpath";
+}
+
+my $P;
+$P = "./" unless $^O =~ /mswin32/i;
+my $ans = `${P}add$libbuilder->{exeext}`;
+chomp $ans;
+is($ans, 15);
+
+clean();
+
+sub add_to_cleanup {
+    push @CLEAN, @_;
+}
+
+sub clean {
+    unlink $_ for @CLEAN;
+}

Added: branches/upstream/libextutils-libbuilder-perl/current/t/manifest.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-libbuilder-perl/current/t/manifest.t?rev=66479&op=file
==============================================================================
--- branches/upstream/libextutils-libbuilder-perl/current/t/manifest.t (added)
+++ branches/upstream/libextutils-libbuilder-perl/current/t/manifest.t Mon Dec 27 00:38:40 2010
@@ -1,0 +1,13 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+unless ( $ENV{RELEASE_TESTING} ) {
+    plan( skip_all => "Author tests not required for installation" );
+}
+
+eval "use Test::CheckManifest 0.9";
+plan skip_all => "Test::CheckManifest 0.9 required" if $@;
+ok_manifest();

Added: branches/upstream/libextutils-libbuilder-perl/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-libbuilder-perl/current/t/pod-coverage.t?rev=66479&op=file
==============================================================================
--- branches/upstream/libextutils-libbuilder-perl/current/t/pod-coverage.t (added)
+++ branches/upstream/libextutils-libbuilder-perl/current/t/pod-coverage.t Mon Dec 27 00:38:40 2010
@@ -1,0 +1,18 @@
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod::Coverage
+my $min_tpc = 1.08;
+eval "use Test::Pod::Coverage $min_tpc";
+plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
+    if $@;
+
+# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
+# but older versions don't recognize some common documentation styles
+my $min_pc = 0.18;
+eval "use Pod::Coverage $min_pc";
+plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
+    if $@;
+
+all_pod_coverage_ok();

Added: branches/upstream/libextutils-libbuilder-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libextutils-libbuilder-perl/current/t/pod.t?rev=66479&op=file
==============================================================================
--- branches/upstream/libextutils-libbuilder-perl/current/t/pod.t (added)
+++ branches/upstream/libextutils-libbuilder-perl/current/t/pod.t Mon Dec 27 00:38:40 2010
@@ -1,0 +1,12 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod
+my $min_tp = 1.22;
+eval "use Test::Pod $min_tp";
+plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
+
+all_pod_files_ok();




More information about the Pkg-perl-cvs-commits mailing list