哪些工具可以帮助构建 XS 项目?
我最近开始使用 perlxstut 学习 XS,教程建议我使用旧的 h2xs 工具,用于创建 ExtUtils::MakeMaker 基于项目。然而,对于纯 Perl 项目,h2xs/EUMM 长期以来一直不受青睐,取而代之的是 Module::Install< /a>、Module::Build 或 Dist::Zilla。
是否有更现代的方式来创建 XS 项目? Module::Starter 可以创建 XS 项目吗? Module::Build 或 Dist::Zilla 可以构建 XS 项目吗?他们的播客页面对此事保持沉默。
另一方面,针对 h2xs/EUMM 的批评是否适用于 XS 项目?如果您无论如何都需要一个 C 编译器,那么还需要一个 make 工具是否合理?
编辑:我看到这个问题 回答了我关于创建项目的问题。我仍然想了解有关构建的信息:EUMM 是唯一的选择,还是 Module::Build 和 Dist::Zilla 也能够构建 XS?
I've recently started learning XS using perlxstut and the tutorial suggests that I create my module using the old h2xs tool to create an ExtUtils::MakeMaker-based project. However for pure Perl projects, h2xs/EUMM has long been disfavoured in favour of Module::Install, Module::Build or Dist::Zilla.
Is there a more modern way of creating XS projects? Can Module::Starter create XS projects? Can Module::Build or Dist::Zilla build XS projects? Their pod pages are silent on the matter.
On the flip side, does the criticism that was levelled at h2xs/EUMM apply to XS projects? If you need a C compiler anyway, is it reasonable to demand a make tool as well?
EDIT: I see this question answers my question about creating a project. I'd still like to know about building: is EUMM the only option, or are Module::Build and Dist::Zilla also capable of building XS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
事实证明,Module::Build 完全能够编译 XS。这是我设法拼凑在一起的完整 Build.PL:
这将构建一个包含
include 中的
目录,.h
包含文件(例如ppport.h
)的发行版/src/
目录中的.c
源文件,以及Chocolate 包对应的
在项目基目录中。.xs
文件::Belgianextra_compiler_flags
对应于 makeCCFLAGS
,而extra_linker_flags
对应于LIBS
(所以你可能需要-lm< /code> 链接 C 数学库)。
It turns out that Module::Build is perfectly capable of compiling XS. Here is a complete Build.PL I managed to scrape together:
This will build a distribution with
.h
include files (such asppport.h
) in theinclude/
directory,.c
source files in thesrc/
directory, and an.xs
file corresponding to packageChocolate::Belgian
in the project base directory.extra_compiler_flags
corresponds to makeCCFLAGS
, whileextra_linker_flags
corresponds toLIBS
(so you might want-lm
there to link the C math library).Dist::Zilla 不是 EUMM 或 Module::Build 的替代品,它会为你生成一个
Makefile.Pl
(等等),我不会很惊讶地听到它无法为 XS 项目执行此操作,但有一些方法可以管理您自己的 dzil 项目。它可以与它提供的任何Makefile.Pl
(或Build.pl)一起使用。因此,我对您问题中的 Dist::Zilla 部分的回答是,Dist::Zilla 在项目中不担任该角色。
Dist::Zilla is not a replacement for EUMM or Module::Build, what it will do is generate a
Makefile.Pl
(etc) for you, I would not be surprised to hear that it can't do this for an XS project, but there are ways of managing your own for a dzil project. It can work with whateverMakefile.Pl
it is provided with (or Build.pl).So my answer on the Dist::Zilla part of your question is, Dist::Zilla does not fill that role in a project.
我总是使用一些相当简单的 XS 发行版作为起点。 h2xs 可以通过解析标头来生成一些 XS,但大多数时候,我发现这太有限了,没有什么用处。
如果您打算包装 C++,您可能需要看看 Module::Build::WithXSpp。
I always just use some fairly simple XS distribution as a starting point. h2xs can do some of the XS generation by parsing a header, but most of the time, I found that too limited to be useful.
If you're planning to wrap C++, you may want to take a look at Module::Build::WithXSpp.