Package init

This commit is contained in:
dogsheng 2019-12-14 21:08:36 +08:00
parent 079ea83fc8
commit 76f4d5256a
5 changed files with 215 additions and 75 deletions

View File

@ -0,0 +1,145 @@
From 6b096ea5670ed291abac632b296222b56d9fadb4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
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ř <ppisar@redhat.com>
---
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<c_source> 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<c_source> 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

BIN
Module-Build-0.4224.tar.gz Normal file

Binary file not shown.

View File

@ -1,36 +0,0 @@
# perl-Module-Build
#### Description
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -1,39 +0,0 @@
# perl-Module-Build
#### 介绍
{**以下是码云平台说明,您可以替换此简介**
码云是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN。专为开发者提供稳定、高效、安全的云端软件开发协作平台
无论是个人、团队、或是企业,都能够用码云实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 码云特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

70
perl-Module-Build.spec Normal file
View File

@ -0,0 +1,70 @@
%{?perl_default_filter}
%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\((ExtUtils::Install|File::Spec|Module::Build|Module::Metadata|Perl::OSType)\\)$
%global __requires_exclude %__requires_exclude|^perl\\(CPAN::Meta::YAML\\) >= 0.002$
Name: perl-Module-Build
Epoch: 2
Version: 0.42.24
Release: 12
Summary: Build and install Perl modules
License: GPL+ or Artistic
URL: https://metacpan.org/release/Module-Build
Source0: https://cpan.metacpan.org/authors/id/L/LE/LEONT/Module-Build-0.4224.tar.gz
Patch0: Module-Build-0.4224-Do-not-need-a-compiler-if-c_source-is-an-empty-list.patch
BuildArch: noarch
BuildRequires: coreutils, perl-interpreter, perl-devel, perl-generators, perl(Archive::Tar), perl(AutoSplit), perl(base), perl(Carp), perl(Config)
BuildRequires: perl(CPAN::Meta) >= 2.142060, perl(CPAN::Meta::Converter) >= 2.141170, perl(CPAN::Meta::Merge), perl(CPAN::Meta::YAML) >= 0.003
BuildRequires: perl(Cwd), perl(Data::Dumper), perl(DynaLoader), perl(Exporter), perl(ExtUtils::CBuilder) >= 0.27, perl(ExtUtils::Install) >= 0.3
BuildRequires: perl(ExtUtils::Installed), perl(ExtUtils::Manifest) >= 1.54, perl(ExtUtils::Mkbootstrap), perl(ExtUtils::Packlist), perl(ExtUtils::ParseXS) >= 2.21
BuildRequires: perl(File::Basename), perl(File::Compare), perl(File::Copy), perl(File::Find), perl(File::Path), perl(File::Spec) >= 0.82, perl(File::Spec::Functions)
BuildRequires: perl(File::Temp) >= 0.15, perl(Getopt::Long), perl(inc::latest), perl(lib), perl(Module::Metadata) >= 1.000002, perl(Parse::CPAN::Meta) >= 1.4401
BuildRequires: perl(Perl::OSType) >= 1, perl(strict), perl(Archive::Zip), perl(File::ShareDir) >= 1.00, perl(TAP::Harness), perl(TAP::Harness::Env)
BuildRequires: perl(Test::Harness) >= 3.29, perl(Test::More) >= 0.49, perl(Text::ParseWords), perl(utf8), perl(vars), perl(version) >= 0.87, perl(warnings)
Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version)), perl(CPAN::Meta) >= 2.142060, perl(CPAN::Meta::Converter) >= 2.141170
Requires: perl(CPAN::Meta::Merge), perl(ExtUtils::Install) >= 0.3, perl(ExtUtils::Manifest) >= 1.54, perl(ExtUtils::Mkbootstrap), perl(ExtUtils::ParseXS) >= 2.21
Requires: perl(inc::latest), perl(Module::Metadata) >= 1.000002, perl(Perl::OSType) >= 1, perl(TAP::Harness::Env), perl(Test::Harness), perl(Software::License)
Requires: perl(Pod::Html), perl(Pod::Man) >= 2.17, perl(Pod::Text)
Recommends: perl(ExtUtils::CBuilder) >= 0.27
%description
Module::Build is a system for building, testing, and installing Perl modules.
It is meant to be an alternative to ExtUtils::MakeMaker. Developers may alter
the behavior of the module through subclassing. It also does not require a make
on your system - most of the Module::Build code is pure-perl and written in a
very cross-platform way.
%package help
Summary: man files for %{name}
Requires: man
%description help
This package includes man files for %{name}.
%prep
%autosetup -n Module-Build-0.4224 -p1
%build
perl Build.PL installdirs=vendor
./Build
%install
./Build install destdir=$RPM_BUILD_ROOT create_packlist=0
%{_fixperms} $RPM_BUILD_ROOT/*
%check
rm -f t/signature.t
LANG=C TEST_SIGNATURE=1 MB_TEST_EXPERIMENTAL=1 ./Build test
%files
%license LICENSE
%doc contrib README
%{_bindir}/config_data
%{perl_vendorlib}/*
%files help
%{_mandir}/man*/*
%changelog
* Fri Nov 29 2019 openEuler Buildteam <buildteam@openeuler.org> - 2:0.42.24-12
- Package init