From 6036a8f3dfd860e2c0ef3333d6b540027f8112fb Mon Sep 17 00:00:00 2001 From: Petr Písař Date: Mar 01 2018 14:32:49 +0000 Subject: Do not require a compiler if c_source is an empty list --- diff --git a/Module-Build-0.4224-Do-not-need-a-compiler-if-c_source-is-an-empty-list.patch b/Module-Build-0.4224-Do-not-need-a-compiler-if-c_source-is-an-empty-list.patch new file mode 100644 index 0000000..bae98c6 --- /dev/null +++ b/Module-Build-0.4224-Do-not-need-a-compiler-if-c_source-is-an-empty-list.patch @@ -0,0 +1,145 @@ +From 6b096ea5670ed291abac632b296222b56d9fadb4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Thu, 1 Mar 2018 14:44:40 +0100 +Subject: [PATCH] Do not need a compiler if c_source is an empty list +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +c_source used to be string, then it allowed a reference to an array. +But in case the array was empty, auto_require() still enabled +needs_compiler property and thus implied probing a compiler and +a failure if none was available. + +Minilla generates these Build.PLs for pure-Perl distributions. See +KAZUHO/Server-Starter-0.34. + +This patch makes Module::Build not require C compiler for +c_source = []. + +Petr Písař: Ported to 0.4224. + +Signed-off-by: Petr Písař +--- + lib/Module/Build/API.pod | 8 ++++---- + lib/Module/Build/Base.pm | 6 +++++- + t/properties/needs_compiler.t | 46 ++++++++++++++++++++++++++++++++++++++++--- + 3 files changed, 52 insertions(+), 8 deletions(-) + +diff --git a/lib/Module/Build/API.pod b/lib/Module/Build/API.pod +index cd2021a..c9be539 100644 +--- a/lib/Module/Build/API.pod ++++ b/lib/Module/Build/API.pod +@@ -209,10 +209,10 @@ created by Module::Build. + + [version 0.04] + +-An optional C argument specifies a directory which contains +-C source files that the rest of the build may depend on. Any C<.c> +-files in the directory will be compiled to object files. The +-directory will be added to the search path during the compilation and ++An optional C argument specifies a directory or a reference to array ++of directories which contain C source files that the rest of the build may ++depend on. Any C<.c> files in the directory will be compiled to object files. ++The directory will be added to the search path during the compilation and + linking phases of any C or XS files. + + [version 0.3604] +diff --git a/lib/Module/Build/Base.pm b/lib/Module/Build/Base.pm +index 984810a..a29c664 100644 +--- a/lib/Module/Build/Base.pm ++++ b/lib/Module/Build/Base.pm +@@ -1517,7 +1517,11 @@ sub auto_require { + # If set, we need ExtUtils::CBuilder (and a compiler) + my $xs_files = $self->find_xs_files; + if ( ! defined $p->{needs_compiler} ) { +- $self->needs_compiler( keys %$xs_files || defined $self->c_source ); ++ $self->needs_compiler( keys %$xs_files || ++ ( defined $self->c_source && ++ ( ref($self->c_source) ne 'ARRAY' || @{$self->c_source} ) ++ ) ++ ); + } + if ($self->needs_compiler) { + $self->_add_prereq('build_requires', 'ExtUtils::CBuilder', 0); +diff --git a/t/properties/needs_compiler.t b/t/properties/needs_compiler.t +index f616dfc..c76d38f 100644 +--- a/t/properties/needs_compiler.t ++++ b/t/properties/needs_compiler.t +@@ -5,7 +5,7 @@ use lib 't/lib'; + use MBTest; + use DistGen; + +-plan tests => 19; ++plan tests => 27; + + # Ensure any Module::Build modules are loaded from correct directory + blib_load('Module::Build'); +@@ -24,7 +24,7 @@ ok( ! exists $mb->{properties}{build_requires}{'ExtUtils::CBuilder'}, + ); + + #--------------------------------------------------------------------------# +-# try with c_source ++# try with c_source as a string + #--------------------------------------------------------------------------# + $dist->change_build_pl({ + module_name => $dist->name, +@@ -34,7 +34,7 @@ $dist->change_build_pl({ + $dist->regen; + stderr_of(sub { + ok( $mb = $dist->new_from_context, +- "Build.PL with c_source" ++ "Build.PL with string c_source" + ); + }); + is( $mb->c_source, 'src', "c_source is set" ); +@@ -44,6 +44,46 @@ ok( exists $mb->{properties}{build_requires}{'ExtUtils::CBuilder'}, + ); + + #--------------------------------------------------------------------------# ++# try with c_source as an array ++#--------------------------------------------------------------------------# ++$dist->change_build_pl({ ++ module_name => $dist->name, ++ license => 'perl', ++ c_source => ['src'], ++}); ++$dist->regen; ++stderr_of(sub { ++ ok( $mb = $dist->new_from_context, ++ "Build.PL with non-empty array c_source" ++ ); ++}); ++is_deeply( $mb->c_source, ['src'], "c_source is set" ); ++ok( $mb->needs_compiler, "needs_compiler is true" ); ++ok( exists $mb->{properties}{build_requires}{'ExtUtils::CBuilder'}, ++ "ExtUtils::CBuilder was added to build_requires" ++); ++ ++#--------------------------------------------------------------------------# ++# try with c_source as an empty array ++#--------------------------------------------------------------------------# ++$dist->change_build_pl({ ++ module_name => $dist->name, ++ license => 'perl', ++ c_source => [], ++}); ++$dist->regen; ++stderr_of(sub { ++ ok( $mb = $dist->new_from_context, ++ "Build.PL with empty array c_source" ++ ); ++}); ++is_deeply( $mb->c_source, [], "c_source is set" ); ++ok( ! $mb->needs_compiler, "needs_compiler is false" ); ++ok( ! exists $mb->{properties}{build_requires}{'ExtUtils::CBuilder'}, ++ "ExtUtils::CBuilder is not in build_requires" ++); ++ ++#--------------------------------------------------------------------------# + # try with xs files + #--------------------------------------------------------------------------# + $dist = DistGen->new(dir => 'MBTest', xs => 1); +-- +2.13.6 + diff --git a/perl-Module-Build.spec b/perl-Module-Build.spec index a169e43..ef4e414 100644 --- a/perl-Module-Build.spec +++ b/perl-Module-Build.spec @@ -8,11 +8,15 @@ Name: perl-Module-Build Epoch: 2 Version: %{cpan_version_major}%{?cpan_version_minor:.%cpan_version_minor} -Release: 6%{?dist} +Release: 7%{?dist} Summary: Build and install Perl modules License: GPL+ or Artistic URL: http://search.cpan.org/dist/Module-Build/ Source0: http://www.cpan.org/authors/id/L/LE/LEONT/Module-Build-%{cpan_version}.tar.gz +# Do not require a compiler if c_source is an empty list, bug #1547165, +# CPAN RT#124625, +# +Patch0: Module-Build-0.4224-Do-not-need-a-compiler-if-c_source-is-an-empty-list.patch BuildArch: noarch BuildRequires: coreutils BuildRequires: perl-interpreter @@ -128,6 +132,7 @@ works fine on perl 5.005 if you can install a few additional modules. %prep %setup -q -n Module-Build-%{cpan_version} +%patch0 -p1 %build perl Build.PL installdirs=vendor @@ -150,6 +155,9 @@ LANG=C TEST_SIGNATURE=1 MB_TEST_EXPERIMENTAL=1 ./Build test %{_mandir}/man3/* %changelog +* Thu Mar 01 2018 Petr Pisar - 2:0.42.24-7 +- Do not require a compiler if c_source is an empty list (bug #1547165) + * Fri Feb 23 2018 Petr Pisar - 2:0.42.24-6 - Do not hard-require ExtUtils::CBuilder (bug #1547165)