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

📄 module::build::api.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 5 页
字号:
This method returns a hash reference indicating whether a versiondependency on a certain module is satisfied.  The \f(CW$module\fR argumentis given as a string like \f(CW"Data::Dumper"\fR or \f(CW"perl"\fR, and the\&\f(CW$version\fR argument can take any of the forms described in \*(L"requires\*(R"above.  This allows very fine-grained version checking..SpThe returned hash reference has the following structure:.Sp.Vb 6\&  {\&   ok => $whether_the_dependency_is_satisfied,\&   have => $version_already_installed,\&   need => $version_requested, # Same as incoming $version argument\&   message => $informative_error_message,\&  }.Ve.SpIf no version of \f(CW$module\fR is currently installed, the \f(CW\*(C`have\*(C'\fR valuewill be the string \f(CW"<none>"\fR.  Otherwise the \f(CW\*(C`have\*(C'\fR value willsimply be the version of the installed module.  Note that this meansthat if \f(CW$module\fR is installed but doesn't define a version number,the \f(CW\*(C`have\*(C'\fR value will be \f(CW\*(C`undef\*(C'\fR \- this is why we don't use \f(CW\*(C`undef\*(C'\fRfor the case when \f(CW$module\fR isn't installed at all..SpThis method may be called either as an object method(\f(CW\*(C`$build\->check_installed_status($module, $version)\*(C'\fR)or as a class method(\f(CW\*(C`Module::Build\->check_installed_status($module, $version)\*(C'\fR)..ie n .IP "check_installed_version($module, $version)" 4.el .IP "check_installed_version($module, \f(CW$version\fR)" 4.IX Item "check_installed_version($module, $version)"[version 0.05].SpLike \fIcheck_installed_status()\fR,but simply returns true or false depending on whether module\&\f(CW$module\fR satisfies the dependency \f(CW$version\fR..SpIf the check succeeds, the return value is the actual version of\&\f(CW$module\fR installed on the system.  This allows you to do thefollowing:.Sp.Vb 6\&  my $installed = $build\->check_installed_version(\*(AqDBI\*(Aq, \*(Aq1.15\*(Aq);\&  if ($installed) {\&    print "Congratulations, version $installed of DBI is installed.\en";\&  } else {\&    die "Sorry, you must install DBI.\en";\&  }.Ve.SpIf the check fails, we return false and set \f(CW$@\fR to an informativeerror message..SpIf \f(CW$version\fR is any non-true value (notably zero) and any version of\&\f(CW$module\fR is installed, we return true.  In this case, if \f(CW$module\fRdoesn't define a version, or if its version is zero, we return thespecial value \*(L"0 but true\*(R", which is numerically zero, but logicallytrue..SpIn general you might prefer to use \f(CW\*(C`check_installed_status\*(C'\fR if youneed detailed information, or this method if you just need a yes/noanswer..ie n .IP "compare_versions($v1, $op\fR, \f(CW$v2)" 4.el .IP "compare_versions($v1, \f(CW$op\fR, \f(CW$v2\fR)" 4.IX Item "compare_versions($v1, $op, $v2)"[version 0.28].SpCompares two module versions \f(CW$v1\fR and \f(CW$v2\fR using the operator\&\f(CW$op\fR, which should be one of Perl's numeric operators like \f(CW\*(C`!=\*(C'\fR or\&\f(CW\*(C`>=\*(C'\fR or the like.  We do at least a halfway-decent job ofhandling versions that aren't strictly numeric, like \f(CW\*(C`0.27_02\*(C'\fR, butexotic stuff will likely cause problems..SpIn the future, the guts of this method might be replaced with a callout to \f(CW\*(C`version.pm\*(C'\fR..IP "config($key)" 4.IX Item "config($key)".PD 0.ie n .IP "config($key, $value)" 4.el .IP "config($key, \f(CW$value\fR)" 4.IX Item "config($key, $value)".IP "\fIconfig()\fR [deprecated]" 4.IX Item "config() [deprecated]".PD[version 0.22].SpWith a single argument \f(CW$key\fR, returns the value associated with thatkey in the \f(CW\*(C`Config.pm\*(C'\fR hash, including any changes the author or userhas specified..SpWith \f(CW$key\fR and \f(CW$value\fR arguments, sets the value for futurecallers of \f(CW\*(C`config($key)\*(C'\fR..SpWith no arguments, returns a hash reference containing all suchkey-value pairs.  This usage is deprecated, though, because it's aresource hog and violates encapsulation..IP "config_data($name)" 4.IX Item "config_data($name)".PD 0.ie n .IP "config_data($name => $value)" 4.el .IP "config_data($name => \f(CW$value\fR)" 4.IX Item "config_data($name => $value)".PD[version 0.26].SpWith a single argument, returns the value of the configurationvariable \f(CW$name\fR.  With two arguments, sets the given configurationvariable to the given value.  The value may be any Perl scalar that'sserializable with \f(CW\*(C`Data::Dumper\*(C'\fR.  For instance, if you write amodule that can use a MySQL or PostgreSQL back-end, you might createconfiguration variables called \f(CW\*(C`mysql_connect\*(C'\fR and\&\f(CW\*(C`postgres_connect\*(C'\fR, and set each to an array of connection parametersfor \f(CW\*(C`DBI\->connect()\*(C'\fR..SpConfiguration values set in this way using the Module::Build objectwill be available for querying during the build/test process and afterinstallation via the generated \f(CW\*(C`...::ConfigData\*(C'\fR module, as\&\f(CW\*(C`...::ConfigData\->config($name)\*(C'\fR..SpThe \fIfeature()\fR and \f(CW\*(C`config_data()\*(C'\fR methods representModule::Build's main support for configuration of installed modules.See also \*(L"\s-1SAVING\s0 \s-1CONFIGURATION\s0 \s-1INFORMATION\s0\*(R" in Module::Build::Authoring..IP "\fIconflicts()\fR" 4.IX Item "conflicts()"[version 0.21].SpReturns a hash reference indicating the \f(CW\*(C`conflicts\*(C'\fR prerequisitesthat were passed to the \f(CW\*(C`new()\*(C'\fR method..IP "contains_pod($file)" 4.IX Item "contains_pod($file)"[version 0.20].Sp[Deprecated] Please see Module::Build::ModuleInfo instead..SpReturns true if the given file appears to contain \s-1POD\s0 documentation.Currently this checks whether the file has a line beginning with\&'=pod', '=head', or '=item', but the exact semantics may change in thefuture..IP "copy_if_modified(%parameters)" 4.IX Item "copy_if_modified(%parameters)"[version 0.19].SpTakes the file in the \f(CW\*(C`from\*(C'\fR parameter and copies it to the file inthe \f(CW\*(C`to\*(C'\fR parameter, or the directory in the \f(CW\*(C`to_dir\*(C'\fR parameter, ifthe file has changed since it was last copied (or if it doesn't existin the new location).  By default the entire directory structure of\&\f(CW\*(C`from\*(C'\fR will be copied into \f(CW\*(C`to_dir\*(C'\fR; an optional \f(CW\*(C`flatten\*(C'\fRparameter will copy into \f(CW\*(C`to_dir\*(C'\fR without doing so..SpReturns the path to the destination file, or \f(CW\*(C`undef\*(C'\fR if nothingneeded to be copied..SpAny directories that need to be created in order to perform thecopying will be automatically created..SpThe destination file is set to read-only. If the source file has theexecutable bit set, then the destination file will be made executable..IP "\fIcreate_build_script()\fR" 4.IX Item "create_build_script()"[version 0.05].SpCreates an executable script called \f(CW\*(C`Build\*(C'\fR in the current directorythat will be used to execute further user actions.  This script isroughly analogous (in function, not in form) to the Makefile createdby \f(CW\*(C`ExtUtils::MakeMaker\*(C'\fR.  This method also creates some temporarydata in a directory called \f(CW\*(C`_build/\*(C'\fR.  Both of these will be removedwhen the \f(CW\*(C`realclean\*(C'\fR action is performed..SpAmong the files created in \f(CW\*(C`_build/\*(C'\fR is a \fI_build/prereqs\fR filecontaining the set of prerequisites for this distribution, as a hashof hashes.  This file may be \f(CW\*(C`eval()\*(C'\fR\-ed to obtain the authoritativeset of prereqs, which might be different from the contents of\&\fI\s-1META\s0.yml\fR (because \fIBuild.PL\fR might have set them dynamically).But fancy developers take heed: do not put any fancy custom runtimecode in the \fI_build/prereqs\fR file, leave it as a static declarationcontaining only strings and numbers.  Similarly, do not alter thestructure of the internal \f(CW\*(C`$self\->{properties}{requires}\*(C'\fR (etc.)data members, because that's where this data comes from..IP "\fIcurrent_action()\fR" 4.IX Item "current_action()"[version 0.28].SpReturns the name of the currently-running action, such as \*(L"build\*(R" or\&\*(L"test\*(R".  This action is not necessarily the action that was originallyinvoked by the user.  For example, if the user invoked the \*(L"test\*(R"action, \fIcurrent_action()\fR would initially return \*(L"test\*(R".  However,action \*(L"test\*(R" depends on action \*(L"code\*(R", so \fIcurrent_action()\fR willreturn \*(L"code\*(R" while that dependency is being executed.  Once thataction has completed, \fIcurrent_action()\fR will again return \*(L"test\*(R"..SpIf you need to know the name of the original action invoked by theuser, see \*(L"\fIinvoked_action()\fR\*(R" below..IP "depends_on(@actions)" 4.IX Item "depends_on(@actions)"[version 0.28].SpInvokes the named action or list of actions in sequence.  Using thismethod is preferred to calling the action explicitly because itperforms some internal record-keeping, and it ensures that the sameaction is not invoked multiple times (note: in future versions ofModule::Build it's conceivable that this run-only-once mechanism willbe changed to something more intelligent)..SpNote that the name of this method is something of a misnomer; itshould really be called something like\&\f(CW\*(C`invoke_actions_unless_already_invoked()\*(C'\fR or something, but forbetter or worse (perhaps better!) we were still thinking in\&\f(CW\*(C`make\*(C'\fR\-like dependency terms when we created this method..SpSee also \fIdispatch()\fR.  The maindistinction between the two is that \f(CW\*(C`depends_on()\*(C'\fR is meant to callan action from inside another action, whereas \f(CW\*(C`dispatch()\*(C'\fR is meantto set the very top action in motion..ie n .IP "dir_contains($first_dir, $second_dir)" 4.el .IP "dir_contains($first_dir, \f(CW$second_dir\fR)" 4.IX Item "dir_contains($first_dir, $second_dir)"[version 0.28].SpReturns true if the first directory logically contains the seconddirectory.  This is just a convenience function because \f(CW\*(C`File::Spec\*(C'\fRdoesn't really provide an easy way to figure this out (but\&\f(CW\*(C`Path::Class\*(C'\fR does...)..ie n .IP "dispatch($action, %args)" 4.el .IP "dispatch($action, \f(CW%args\fR)" 4.IX Item "dispatch($action, %args)"[version 0.03].SpInvokes the build action \f(CW$action\fR.  Optionally, a list of optionsand their values can be passed in.  This is equivalent to invoking anaction at the command line, passing in a list of options..SpCustom options that have not been registered must be passed in as ahash reference in a key named \*(L"args\*(R":.Sp.Vb 1\&  $build\->dispatch(\*(Aqfoo\*(Aq, verbose => 1, args => { my_option => \*(Aqvalue\*(Aq });.Ve.SpThis method is intended to be used to programmatically invoke buildactions, e.g. by applications controlling Module::Build\-based buildsrather than by subclasses..SpSee also \fIdepends_on()\fR.  The maindistinction between the two is that \f(CW\*(C`depends_on()\*(C'\fR is meant to callan action from inside another action, whereas \f(CW\*(C`dispatch()\*(C'\fR is meantto set the very top action in motion..IP "\fIdist_dir()\fR" 4.IX Item "dist_dir()"[version 0.28].SpReturns the name of the directory that will be created during the\&\f(CW\*(C`dist\*(C'\fR action.  The name is derived from the \f(CW\*(C`dist_name\*(C'\fR and\&\f(CW\*(C`dist_version\*(C'\fR properties..IP "\fIdist_name()\fR" 4.IX Item "dist_name()"[version 0.21].SpReturns the name of the current distribution, as passed to the\&\f(CW\*(C`new()\*(C'\fR method in a \f(CW\*(C`dist_name\*(C'\fR or modified \f(CW\*(C`module_name\*(C'\fRparameter..IP "\fIdist_version()\fR" 4.IX Item "dist_version()"[version 0.21].SpReturns the version of the current distribution, as determined by the\&\f(CW\*(C`new()\*(C'\fR method from a \f(CW\*(C`dist_version\*(C'\fR, \f(CW\*(C`dist_version_from\*(C'\fR, or\&\f(CW\*(C`module_name\*(C'\fR parameter..ie n .IP "do_system($cmd, @args)" 4.el .IP "do_system($cmd, \f(CW@args\fR)" 4.IX Item "do_system($cmd, @args)"[version 0.21].SpThis is a fairly simple wrapper around Perl's \f(CW\*(C`system()\*(C'\fR built-incommand.  Given a command and an array of optional arguments, thismethod will print the command to \f(CW\*(C`STDOUT\*(C'\fR, and then execute it usingPerl's \f(CW\*(C`system()\*(C'\fR.  It returns true or false to indicate success orfailure (the opposite of how \f(CW\*(C`system()\*(C'\fR works, but more intuitive)..SpNote that if you supply a single argument to \f(CW\*(C`do_system()\*(C'\fR, itwill/may be processed by the systems's shell, and any specialcharacters will do their special things.  If you supply multiplearguments, no shell will get involved and the command will be executeddirectly..IP "feature($name)" 4.IX Item "feature($name)".PD 0.ie n .IP "feature($name => $value)" 4.el .IP "feature($name => \f(CW$value\fR)" 4.IX Item "feature($name => $value)".PD[version 0.26].SpWith a single argument, returns true if the given feature is set.With two arguments, sets the given feature to the given boolean value.In this context, a \*(L"feature\*(R" is any optional functionality of aninstalled module.  For instance, if you write a module that couldoptionally support a MySQL or PostgreSQL backend, you might createfeatures called \f(CW\*(C`mysql_support\*(C'\fR and \f(CW\*(C`postgres_support\*(C'\fR, and set themto true/false depending on whether the user has the proper databasesinstalled and configured..SpFeatures set in this way using the Module::Build object will beavailable for querying during the build/test process and afterinstallation via the generated \f(CW\*(C`...::ConfigData\*(C'\fR module, as\&\f(CW\*(C`...::ConfigData\->feature($name)\*(C'\fR..SpThe \f(CW\*(C`feature()\*(C'\fR and \f(CW\*(C`config_data()\*(C'\fR methods representModule::Build's main support for configuration of installed modules.See also \*(L"\s-1SAVING\s0 \s-1CONFIGURATION\s0 \s-1INFORMATION\s0\*(R" in Module::Build::Authoring..IP "\fIhave_c_compiler()\fR" 4.IX Item "have_c_compiler()"[version 0.21].SpReturns true if the current system seems to have a working C compiler.We currently determine this by attempting to compile a simple C sourcefile and reporting whether the attempt was successful.

⌨️ 快捷键说明

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