Skip Menu |

This queue is for tickets about the Audio-FLAC-Header CPAN distribution.

Report information
The Basics
Id: 44930
Status: resolved
Priority: 0/
Queue: Audio-FLAC-Header

People
Owner: Nobody in particular
Requestors: nick.cpan [...] xlmt.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.3
Fixed in: (no value)



Subject: Won't build without libFLAC [patch suggested]
README says: Show quoted text
> If you have a C compiler & libFLAC installed, the library will build > and use a XS version, which is much faster than the pure perl one.
I do not have libFLAC installed on my machine. Running #perl Makefile.PL gives: * libFLAC is not installed or not in the default lib path. Aborting. I'm using: perl v5.8.8 Linux version 2.6.27-gentoo-r7 on x86 Audio::FLAC::Header from github: http://github.com/dsully/perl-audio-flac-header/commit/49bad1c6663a290d39d6ce8ba2a5525891a04dca The attached patch to Makefile.PL offers a choice whether to build just the pure perl version, or the XS version as well. It will make this choice automatically if no argument is given. After changing the Makefile.PL, a number of the tests will fail as they try to exercise the XS code paths. I attach patches for the following tests: application-id.t basic.t id3tagged.t md5.t picture.t
Subject: 0001-Enable-build-without-libFLAC-patch.patch
From 13bcc5bdc133c10af189f7975d4543f7064a3b08 Mon Sep 17 00:00:00 2001 From: Nick Prater <nick@xlmt.com> Date: Fri, 10 Apr 2009 19:56:49 +0100 Subject: [PATCH] Enable build without libFLAC [patch] README says: > If you have a C compiler & libFLAC installed, the library will build > and use a XS version, which is much faster than the pure perl one. I do not have libFLAC installed on my machine. Running #perl Makefile.PL gives: * libFLAC is not installed or not in the default lib path. Aborting. I'm using: perl v5.8.8 Linux version 2.6.27-gentoo-r7 on x86 Audio::FLAC::Header from github: http://github.com/dsully/perl-audio-flac-header/commit/49bad1c6663a290d39d6ce8ba2a5525891a04dca The attached patch to Makefile.PL offers a choice whether to build just the pure perl version, or the XS version as well. It will make this choice automatically if no argument is given. After changing the Makefile.PL, a number of the tests will fail as they try to exercise the XS code paths. I attach patches for the following tests: application-id.t basic.t id3tagged.t md5.t picture.t --- Makefile.PL | 68 ++++++++++++++++++++++++++++++++++----------------- t/application-id.t | 14 ++++++++++- t/basic.t | 15 ++++++++++- t/id3tagged.t | 14 +++++++++- t/md5.t | 14 +++++++++- t/picture.t | 15 ++++++++++- 6 files changed, 108 insertions(+), 32 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index e14aab1..85a24fb 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,6 +1,51 @@ # $Id: Makefile.PL 10 1998-12-16 23:02:45Z daniel $ +# Code to select XS or Pure Perl version inspired by Scalar::List::Utils + +use strict; +use warnings; use Config; +use inc::Module::Install; + +# Automatically select XS or PP version in case neither argument is given +my $got_libFLAC = defined(search_lib('-lFLAC')); +my $do_xs = can_cc() && $got_libFLAC; + +# Select XS or PP version if argument is given +for (@ARGV) { + /^-pp/ and $do_xs = 0; + /^-xs/ and $do_xs = 1; +} + +if ($do_xs && !$got_libFLAC) { + warn "* libFLAC is not installed or not in the default lib path. Cannot build XS version.\n"; + die "* Try building pure perl version by using -pp argument.\n"; +} + +name('Audio-FLAC-Header'); +license('perl'); +perl_version('5.005'); +all_from('Header.pm'); +requires_external_cc() if $do_xs; + +if ($do_xs) { + requires_external_cc(); + print "Building XS version.\n"; + if ($^O =~ /win32/i) { + cc_lib_links('FLAC_static'); + } else { + cc_lib_links('FLAC'); + cc_optimize_flags('-Wall') if $Config::Config{'archname'} =~ /gnu/i; + } +} +else { + print "Not building XS version.\n"; + makemaker_args ( XS => {}, C => [] ); +} + +auto_install(); +WriteAll(); + sub search_lib { my ($lib) = @_; @@ -23,26 +68,3 @@ sub search_lib { } return undef; } - -if (!defined search_lib('-lFLAC')) { - warn "* libFLAC is not installed or not in the default lib path. Aborting.\n"; - exit; -} - -use inc::Module::Install; - -name('Audio-FLAC-Header'); -license('perl'); -perl_version('5.005'); -all_from('Header.pm'); -requires_external_cc(); - -if ($^O =~ /win32/i) { - cc_lib_links('FLAC_static'); -} else { - cc_lib_links('FLAC'); - cc_optimize_flags('-Wall') if $Config::Config{'archname'} =~ /gnu/i; -} - -auto_install(); -WriteAll(); diff --git a/t/application-id.t b/t/application-id.t index de93011..0f42441 100644 --- a/t/application-id.t +++ b/t/application-id.t @@ -10,8 +10,20 @@ BEGIN { use_ok('Audio::FLAC::Header') }; { + # Always test pure perl + my @constructors = ('_new_PP'); + + # Only test XS if built + SKIP: { + eval { Audio::FLAC::Header->_new_XS(catdir('data', 'appId.flac')) }; + skip "Not built with XS", 5 if $@; + + push @constructors, '_new_XS'; + } + + # Be sure to test both code paths. - for my $constructor (qw(_new_PP _new_XS)) { + for my $constructor (@constructors) { my $flac = Audio::FLAC::Header->$constructor(catdir('data', 'appId.flac')); diff --git a/t/basic.t b/t/basic.t index ba46697..e3b445f 100644 --- a/t/basic.t +++ b/t/basic.t @@ -9,9 +9,20 @@ BEGIN { use_ok('Audio::FLAC::Header') }; ######################### { + # Always test pure perl + my @constructors = ('_new_PP'); - # Be sure to test both code paths. - for my $constructor (qw(_new_PP _new_XS)) { + # Only test XS if built + SKIP: { + eval { Audio::FLAC::Header->_new_XS(catdir('data', 'test.flac')) }; + skip "Not built with XS", 15 if $@; + + push @constructors, '_new_XS'; + } + + + # Be sure to test both code paths. + for my $constructor (@constructors) { my $flac = Audio::FLAC::Header->$constructor(catdir('data', 'test.flac')); diff --git a/t/id3tagged.t b/t/id3tagged.t index a7876f0..f5b52f3 100644 --- a/t/id3tagged.t +++ b/t/id3tagged.t @@ -9,9 +9,19 @@ BEGIN { use_ok('Audio::FLAC::Header') }; ######################### { + # Always test pure perl + my @constructors = ('_new_PP'); - # Be sure to test both code paths. - for my $constructor (qw(_new_PP _new_XS)) { + # Only test XS if built + SKIP: { + eval { Audio::FLAC::Header->_new_XS(catdir('data', 'id3tagged.flac')) }; + skip "Not built with XS", 4 if $@; + + push @constructors, '_new_XS'; + } + + # Be sure to test both code paths. + for my $constructor (@constructors) { my $flac = Audio::FLAC::Header->$constructor(catdir('data', 'id3tagged.flac')); diff --git a/t/md5.t b/t/md5.t index 5597df5..e9440e8 100644 --- a/t/md5.t +++ b/t/md5.t @@ -9,9 +9,19 @@ BEGIN { use_ok('Audio::FLAC::Header') }; ######################### { + # Always test pure perl + my @constructors = ('_new_PP'); - # Be sure to test both code paths. - for my $constructor (qw(_new_PP _new_XS)) { + # Only test XS if built + SKIP: { + eval { Audio::FLAC::Header->_new_XS(catdir('data', 'md5.flac')) }; + skip "Not built with XS", 1 if $@; + + push @constructors, '_new_XS'; + } + + # Be sure to test both code paths. + for my $constructor (@constructors) { my $flac = Audio::FLAC::Header->$constructor(catdir('data', 'md5.flac')); diff --git a/t/picture.t b/t/picture.t index 26ab3e6..6539541 100644 --- a/t/picture.t +++ b/t/picture.t @@ -9,8 +9,19 @@ BEGIN { use_ok('Audio::FLAC::Header') }; ######################### { - # Be sure to test both code paths. - for my $constructor (qw(_new_PP _new_XS)) { + # Always test pure perl + my @constructors = ('_new_PP'); + + # Only test XS if built + SKIP: { + eval { Audio::FLAC::Header->_new_XS(catdir('data', 'picture.flac')) }; + skip "Not built with XS", 3 if $@; + + push @constructors, '_new_XS'; + } + + # Be sure to test both code paths. + for my $constructor (@constructors) { my $flac = Audio::FLAC::Header->$constructor(catdir('data', 'picture.flac')); -- 1.6.0.6
Thanks. Applied & pushed to github.