⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 extutils::makemaker::faq.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
pure perl.  no make, no shell commands.IP "\(bu" 8easier to customize.IP "\(bu" 8cleaner internals.IP "\(bu" 8less cruft.RE.RS 4.SpModule::Build is the official heir apparent to MakeMaker and weencourage people to work on M::B rather than spending time adding featuresto MakeMaker..RE.Sh "Module Writing".IX Subsection "Module Writing".ie n .IP "How do I keep my $VERSION up to date without resetting it manually?" 4.el .IP "How do I keep my \f(CW$VERSION\fR up to date without resetting it manually?" 4.IX Item "How do I keep my $VERSION up to date without resetting it manually?"Often you want to manually set the \f(CW$VERSION\fR in the main moduledistribution because this is the version that everybody sees on \s-1CPAN\s0and maybe you want to customize it a bit.  But for all the othermodules in your dist, \f(CW$VERSION\fR is really just bookkeeping and all that'simportant is it goes up every time the module is changed.  Doing thisby hand is a pain and you often forget..SpSimplest way to do it automatically is to use your version controlsystem's revision number (you are using version control, right?)..SpIn \s-1CVS\s0, \s-1RCS\s0 and \s-1SVN\s0 you use \f(CW$Revision\fR$ (see the documentation of yourversion control system for details).  Every time the file is checkedin the \f(CW$Revision\fR$ will be updated, updating your \f(CW$VERSION\fR..Sp\&\s-1SVN\s0 uses a simple integer for \f(CW$Revision\fR$ so you can adapt it for your\&\f(CW$VERSION\fR like so:.Sp.Vb 1\&    ($VERSION) = q$Revision$ =~ /(\ed+)/;.Ve.SpIn \s-1CVS\s0 and \s-1RCS\s0 version 1.9 is followed by 1.10.  Since \s-1CPAN\s0 comparesversion numbers numerically we use a \fIsprintf()\fR to convert 1.9 to 1.009and 1.10 to 1.010 which compare properly..Sp.Vb 1\&    $VERSION = sprintf "%d.%03d", q$Revision$ =~ /(\ed+)\e.(\ed+)/g;.Ve.SpIf branches are involved (ie. \f(CW$Revision:\fR 1.5.3.4$) its a little morecomplicated..Sp.Vb 2\&    # must be all on one line or MakeMaker will get confused.\&    $VERSION = do { my @r = (q$Revision$ =~ /\ed+/g); sprintf "%d."."%03d" x $#r, @r };.Ve.SpIn \s-1SVN\s0, \f(CW$Revision\fR$ should be the same for every file in the project sothey would all have the same \f(CW$VERSION\fR.  \s-1CVS\s0 and \s-1RCS\s0 have a different\&\f(CW$Revision\fR$ per file so each file will have a differnt \f(CW$VERSION\fR.Distributed version control systems, such as \s-1SVK\s0, may have a different\&\f(CW$Revision\fR$ based on who checks out the file leading to a different \f(CW$VERSION\fRon each machine!  Finally, some distributed version control systems, suchas darcs, have no concept of revision number at all..IP "What's this \fI\s-1META\s0.yml\fR thing and how did it get in my \fI\s-1MANIFEST\s0\fR?!" 4.IX Item "What's this META.yml thing and how did it get in my MANIFEST?!"\&\fI\s-1META\s0.yml\fR is a module meta-data file pioneered by Module::Build andautomatically generated as part of the 'distdir' target (and thus\&'dist').  See \*(L"Module Meta-Data\*(R" in ExtUtils::MakeMaker..SpTo shut off its generation, pass the \f(CW\*(C`NO_META\*(C'\fR flag to \f(CW\*(C`WriteMakefile()\*(C'\fR..IP "How do I delete everything not in my \fI\s-1MANIFEST\s0\fR?" 4.IX Item "How do I delete everything not in my MANIFEST?"Some folks are surpried that \f(CW\*(C`make distclean\*(C'\fR does not deleteeverything not listed in their \s-1MANIFEST\s0 (thus making a cleandistribution) but only tells them what they need to delete.  This isdone because it is considered too dangerous.  While developing yourmodule you might write a new file, not add it to the \s-1MANIFEST\s0, thenrun a \f(CW\*(C`distclean\*(C'\fR and be sad because your new work was deleted..SpIf you really want to do this, you can use\&\f(CW\*(C`ExtUtils::Manifest::manifind()\*(C'\fR to read the \s-1MANIFEST\s0 and File::Findto delete the files.  But you have to be careful.  Here's a script todo that.  Use at your own risk.  Have fun blowing holes in your foot..Sp.Vb 1\&    #!/usr/bin/perl \-w\&    \&    use strict;\&    \&    use File::Spec;\&    use File::Find;\&    use ExtUtils::Manifest qw(maniread);\&    \&    my %manifest = map  {( $_ => 1 )}\&                   grep { File::Spec\->canonpath($_) }\&                        keys %{ maniread() };\&\&    if( !keys %manifest ) {\&        print "No files found in MANIFEST.  Stopping.\en";\&        exit;\&    }\&    \&    find({\&          wanted   => sub {\&              my $path = File::Spec\->canonpath($_);\&    \&              return unless \-f $path;\&              return if exists $manifest{ $path };\&    \&              print "unlink $path\en";\&              unlink $path;\&          },\&          no_chdir => 1\&         },\&         "."\&    );.Ve.Sh "\s-1XS\s0".IX Subsection "XS".ie n .IP "How to I prevent ""object version X.XX does not match bootstrap parameter Y.YY"" errors?" 4.el .IP "How to I prevent ``object version X.XX does not match bootstrap parameter Y.YY'' errors?" 4.IX Item "How to I prevent object version X.XX does not match bootstrap parameter Y.YY errors?"\&\s-1XS\s0 code is very sensitive to the module version number and willcomplain if the version number in your Perl module doesn't match.  Ifyou change your module's version # without rerunning Makefile.PL the oldversion number will remain in the Makefile causing the \s-1XS\s0 code to be builtwith the wrong number..SpTo avoid this, you can force the Makefile to be rebuilt whenever youchange the module containing the version number by adding this to your\&\fIWriteMakefile()\fR arguments..Sp.Vb 1\&    depend => { \*(Aq$(FIRST_MAKEFILE)\*(Aq => \*(Aq$(VERSION_FROM)\*(Aq }.Ve.IP "How do I make two or more \s-1XS\s0 files coexist in the same directory?" 4.IX Item "How do I make two or more XS files coexist in the same directory?"Sometimes you need to have two and more \s-1XS\s0 files in the same package.One way to go is to put them into separate directories, but sometimesthis is not the most suitable solution. The following technique allowsyou to put two (and more) \s-1XS\s0 files in the same directory..SpLet's assume that we have a package \f(CW\*(C`Cool::Foo\*(C'\fR, which includes\&\f(CW\*(C`Cool::Foo\*(C'\fR and \f(CW\*(C`Cool::Bar\*(C'\fR modules each having a separate \s-1XS\s0file. First we use the following \fIMakefile.PL\fR:.Sp.Vb 1\&  use ExtUtils::MakeMaker;\&\&  WriteMakefile(\&      NAME              => \*(AqCool::Foo\*(Aq,\&      VERSION_FROM      => \*(AqFoo.pm\*(Aq,\&      OBJECT              => q/$(O_FILES)/,\&      # ... other attrs ...\&  );.Ve.SpNotice the \f(CW\*(C`OBJECT\*(C'\fR attribute. MakeMaker generates the followingvariables in \fIMakefile\fR:.Sp.Vb 7\&  # Handy lists of source code files:\&  XS_FILES= Bar.xs \e\&        Foo.xs\&  C_FILES = Bar.c \e\&        Foo.c\&  O_FILES = Bar.o \e\&        Foo.o.Ve.SpTherefore we can use the \f(CW\*(C`O_FILES\*(C'\fR variable to tell MakeMaker to usethese objects into the shared library..SpThat's pretty much it. Now write \fIFoo.pm\fR and \fIFoo.xs\fR, \fIBar.pm\fRand \fIBar.xs\fR, where \fIFoo.pm\fR bootstraps the shared library and\&\fIBar.pm\fR simply loading \fIFoo.pm\fR..SpThe only issue left is to how to bootstrap \fIBar.xs\fR. This is donefrom \fIFoo.xs\fR:.Sp.Vb 1\&  MODULE = Cool::Foo PACKAGE = Cool::Foo\&\&  BOOT:\&  # boot the second XS file\&  boot_Cool_\|_Bar(aTHX_ cv);.Ve.SpIf you have more than two files, this is the place where you shouldboot extra \s-1XS\s0 files from..SpThe following four files sum up all the details discussed so far..Sp.Vb 3\&  Foo.pm:\&  \-\-\-\-\-\-\-\&  package Cool::Foo;\&\&  require DynaLoader;\&\&  our @ISA = qw(DynaLoader);\&  our $VERSION = \*(Aq0.01\*(Aq;\&  bootstrap Cool::Foo $VERSION;\&\&  1;\&\&  Bar.pm:\&  \-\-\-\-\-\-\-\&  package Cool::Bar;\&\&  use Cool::Foo; # bootstraps Bar.xs\&\&  1;\&\&  Foo.xs:\&  \-\-\-\-\-\-\-\&  #include "EXTERN.h"\&  #include "perl.h"\&  #include "XSUB.h"\&\&  MODULE = Cool::Foo  PACKAGE = Cool::Foo\&\&  BOOT:\&  # boot the second XS file\&  boot_Cool_\|_Bar(aTHX_ cv);\&\&  MODULE = Cool::Foo  PACKAGE = Cool::Foo  PREFIX = cool_foo_\&\&  void\&  cool_foo_perl_rules()\&\&      CODE:\&      fprintf(stderr, "Cool::Foo says: Perl Rules\en");\&\&  Bar.xs:\&  \-\-\-\-\-\-\-\&  #include "EXTERN.h"\&  #include "perl.h"\&  #include "XSUB.h"\&\&  MODULE = Cool::Bar  PACKAGE = Cool::Bar PREFIX = cool_bar_\&\&  void\&  cool_bar_perl_rules()\&\&      CODE:\&      fprintf(stderr, "Cool::Bar says: Perl Rules\en");.Ve.SpAnd of course a very basic test:.Sp.Vb 9\&  t/cool.t:\&  \-\-\-\-\-\-\-\-\&  use Test;\&  BEGIN { plan tests => 1 };\&  use Cool::Foo;\&  use Cool::Bar;\&  Cool::Foo::perl_rules();\&  Cool::Bar::perl_rules();\&  ok 1;.Ve.SpThis tip has been brought to you by Nick Ing-Simmons and Stas Bekman..SH "PATCHING".IX Header "PATCHING"If you have a question you'd like to see added to the \s-1FAQ\s0 (whether ornot you have the answer) please send it to makemaker@perl.org..SH "AUTHOR".IX Header "AUTHOR"The denizens of makemaker@perl.org..SH "SEE ALSO".IX Header "SEE ALSO"ExtUtils::MakeMaker

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -