如何将多个 Perl 模块添加到 Makefile.PL?

发布于 2024-08-18 09:59:43 字数 583 浏览 4 评论 0原文

正在寻找有关如何将多个 PM 文件添加到 MakeMaker 脚本的见解?

我看到此文档和所有示例看起来像是添加了一个文件,如何添加多个文件?

use ExtUtils::MakeMaker;

WriteMakefile(
   NAME => 'Your::Module',
   VERSION_FROM => 'lib/Your/Module.pm'
);

我只需添加另一组值吗?

use ExtUtils::MakeMaker;

WriteMakefile(
   NAME => 'Your::Module',
   VERSION_FROM => 'lib/Your/Module.pm'

   NAME => 'Your::Module2',
   VERSION_FROM => 'lib/Your/Module2.pm'
);

Looking for some insight on how to add multiple PM files to the MakeMaker script?

I see this documentation and all the examples look like one file is added, how do I add multiple files?

use ExtUtils::MakeMaker;

WriteMakefile(
   NAME => 'Your::Module',
   VERSION_FROM => 'lib/Your/Module.pm'
);

Do I just add another set of values?

use ExtUtils::MakeMaker;

WriteMakefile(
   NAME => 'Your::Module',
   VERSION_FROM => 'lib/Your/Module.pm'

   NAME => 'Your::Module2',
   VERSION_FROM => 'lib/Your/Module2.pm'
);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

机场等船 2024-08-25 09:59:43

答案是:什么也不做。您的原始代码和布局都很好。 MakeMaker 会在 lib 中找到您的模块,而无需您费力。尝试一下看看。

像 toolic 的答案中那样明确写出 PM 是不必要的,而且很脆弱。

The answer is: do nothing. Your original code and layout is fine. MakeMaker will find your modules in lib without you lifting a finger. Try it and see.

Explicitly writing out PM as in toolic's answer is unnecessary and brittle.

极度宠爱 2024-08-25 09:59:43

工具的答案已经将您指向文档,但我会回答问题的另一部分(尽管它也在文档中):

NAME 是 Makemaker 用于发行版名称的字符串。尽管这通常是主模块,但它实际上可以是您喜欢的任何模块。

VERSION_FROM 告诉 Makemaker 它应该从特定文件中获取 $VERSION 并在分发版本中使用它。大多数情况下,人们使用主模块的版本作为分发版本,但您不必这样做。

toolic's answer already points you to the docs, but I'll answer the other part of the question (although it is also in the docs):

NAME is the string Makemaker uses for the distribution name. Although this is often the main module, it can really be anything you like.

VERSION_FROM tells Makemaker that it should take the $VERSION from a specific file and use that at the distribution version. Most often, people use the version of the main module as the distribution version, but you don't have to do that.

飘过的浮云 2024-08-25 09:59:43

也许您可以尝试使用PMExtUtils::MakeMaker 文档说:

.pm 文件和 *.pl 文件的哈希引用
被安装。例如

我查看了从 CPAN 下载的其他一些模块以获取其用法示例,我在 GD Makefile.PL 代码:

WriteMakefile(
    'NAME'  => 'GD',
    'VERSION_FROM'  => 'GD.pm',
    'PREREQ_PM' => {
            'Math::Trig' => 0,
            },
    'PM'        => { 'GD.pm' => '$(INST_LIBDIR)/GD.pm',
                     'GD/Polyline.pm' => '$(INST_LIBDIR)/GD/Polyline.pm',
                     'GD/Polygon.pm' => '$(INST_LIBDIR)/GD/Polygon.pm',
                     'GD/Simple.pm' => '$(INST_LIBDIR)/GD/Simple.pm',
                     'GD/Image.pm' => '$(INST_LIBDIR)/GD/Image.pm',
                     'GD/Group.pm' => '$(INST_LIBDIR)/GD/Group.pm',
                     'qd.pl' => '$(INST_LIBDIR)/qd.pl'},

我怀疑您发布的代码是否有效,因为您传递给 WriteMakefile 函数的哈希具有重复的键。

Perhaps you could try to use PM. The ExtUtils::MakeMaker doc says:

Hashref of .pm files and *.pl files to
be installed. e.g.

I went looking through some other modules I downloaded from CPAN for an example of its usage, and I found it in the GD Makefile.PL code:

WriteMakefile(
    'NAME'  => 'GD',
    'VERSION_FROM'  => 'GD.pm',
    'PREREQ_PM' => {
            'Math::Trig' => 0,
            },
    'PM'        => { 'GD.pm' => '$(INST_LIBDIR)/GD.pm',
                     'GD/Polyline.pm' => '$(INST_LIBDIR)/GD/Polyline.pm',
                     'GD/Polygon.pm' => '$(INST_LIBDIR)/GD/Polygon.pm',
                     'GD/Simple.pm' => '$(INST_LIBDIR)/GD/Simple.pm',
                     'GD/Image.pm' => '$(INST_LIBDIR)/GD/Image.pm',
                     'GD/Group.pm' => '$(INST_LIBDIR)/GD/Group.pm',
                     'qd.pl' => '$(INST_LIBDIR)/qd.pl'},

I doubt the code you posted would work because the hash you are passing to the WriteMakefile function has duplicate keys.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文