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

📄 api.pod

📁 source of perl for linux application,
💻 POD
📖 第 1 页 / 共 4 页
字号:
  {   ok => $whether_the_dependency_is_satisfied,   have => $version_already_installed,   need => $version_requested, # Same as incoming $version argument   message => $informative_error_message,  }If no version of C<$module> is currently installed, the C<have> valuewill be the string C<< "<none>" >>.  Otherwise the C<have> value willsimply be the version of the installed module.  Note that this meansthat if C<$module> is installed but doesn't define a version number,the C<have> value will be C<undef> - this is why we don't use C<undef>for the case when C<$module> isn't installed at all.This method may be called either as an object method(C<< $build->check_installed_status($module, $version) >>)or as a class method(C<< Module::Build->check_installed_status($module, $version) >>).=item check_installed_version($module, $version)[version 0.05]Like L<check_installed_status()|/"check_installed_status($module, $version)">,but simply returns true or false depending on whether moduleC<$module> satisfies the dependency C<$version>.If the check succeeds, the return value is the actual version ofC<$module> installed on the system.  This allows you to do thefollowing:  my $installed = $build->check_installed_version('DBI', '1.15');  if ($installed) {    print "Congratulations, version $installed of DBI is installed.\n";  } else {    die "Sorry, you must install DBI.\n";  }If the check fails, we return false and set C<$@> to an informativeerror message.If C<$version> is any non-true value (notably zero) and any version ofC<$module> is installed, we return true.  In this case, if C<$module>doesn't define a version, or if its version is zero, we return thespecial value "0 but true", which is numerically zero, but logicallytrue.In general you might prefer to use C<check_installed_status> if youneed detailed information, or this method if you just need a yes/noanswer.=item compare_versions($v1, $op, $v2)[version 0.28]Compares two module versions C<$v1> and C<$v2> using the operatorC<$op>, which should be one of Perl's numeric operators like C<!=> orC<< >= >> or the like.  We do at least a halfway-decent job ofhandling versions that aren't strictly numeric, like C<0.27_02>, butexotic stuff will likely cause problems.In the future, the guts of this method might be replaced with a callout to C<version.pm>.=item config($key)=item config($key, $value)=item config() [deprecated][version 0.22]With a single argument C<$key>, returns the value associated with thatkey in the C<Config.pm> hash, including any changes the author or userhas specified.With C<$key> and C<$value> arguments, sets the value for futurecallers of C<config($key)>.With no arguments, returns a hash reference containing all suchkey-value pairs.  This usage is deprecated, though, because it's aresource hog and violates encapsulation.=item config_data($name)=item config_data($name => $value)[version 0.26]With a single argument, returns the value of the configurationvariable C<$name>.  With two arguments, sets the given configurationvariable to the given value.  The value may be any Perl scalar that'sserializable with C<Data::Dumper>.  For instance, if you write amodule that can use a MySQL or PostgreSQL back-end, you might createconfiguration variables called C<mysql_connect> andC<postgres_connect>, and set each to an array of connection parametersfor C<< DBI->connect() >>.Configuration values set in this way using the Module::Build objectwill be available for querying during the build/test process and afterinstallation via the generated C<...::ConfigData> module, asC<< ...::ConfigData->config($name) >>.The L<feature()|/"feature($name)"> and C<config_data()> methods representModule::Build's main support for configuration of installed modules.See also L<Module::Build::Authoring/"SAVING CONFIGURATION INFORMATION">.=item conflicts()[version 0.21]Returns a hash reference indicating the C<conflicts> prerequisitesthat were passed to the C<new()> method.=item contains_pod($file)[version 0.20][Deprecated] Please see L<Module::Build::ModuleInfo> instead.Returns true if the given file appears to contain POD documentation.Currently this checks whether the file has a line beginning with'=pod', '=head', or '=item', but the exact semantics may change in thefuture.=item copy_if_modified(%parameters)[version 0.19]Takes the file in the C<from> parameter and copies it to the file inthe C<to> parameter, or the directory in the C<to_dir> 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 ofC<from> will be copied into C<to_dir>; an optional C<flatten>parameter will copy into C<to_dir> without doing so.Returns the path to the destination file, or C<undef> if nothingneeded to be copied.Any directories that need to be created in order to perform thecopying will be automatically created.The destination file is set to read-only. If the source file has theexecutable bit set, then the destination file will be made executable.=item create_build_script()[version 0.05]Creates an executable script called C<Build> 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 C<ExtUtils::MakeMaker>.  This method also creates some temporarydata in a directory called C<_build/>.  Both of these will be removedwhen the C<realclean> action is performed.Among the files created in C<_build/> is a F<_build/prereqs> filecontaining the set of prerequisites for this distribution, as a hashof hashes.  This file may be C<eval()>-ed to obtain the authoritativeset of prereqs, which might be different from the contents ofF<META.yml> (because F<Build.PL> might have set them dynamically).But fancy developers take heed: do not put any fancy custom runtimecode in the F<_build/prereqs> file, leave it as a static declarationcontaining only strings and numbers.  Similarly, do not alter thestructure of the internal C<< $self->{properties}{requires} >> (etc.)data members, because that's where this data comes from.=item current_action()[version 0.28]Returns the name of the currently-running action, such as "build" or"test".  This action is not necessarily the action that was originallyinvoked by the user.  For example, if the user invoked the "test"action, current_action() would initially return "test".  However,action "test" depends on action "code", so current_action() willreturn "code" while that dependency is being executed.  Once thataction has completed, current_action() will again return "test".If you need to know the name of the original action invoked by theuser, see L</invoked_action()> below.=item depends_on(@actions)[version 0.28]Invokes 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).Note that the name of this method is something of a misnomer; itshould really be called something likeC<invoke_actions_unless_already_invoked()> or something, but forbetter or worse (perhaps better!) we were still thinking inC<make>-like dependency terms when we created this method.See also L<dispatch()|/"dispatch($action, %args)">.  The maindistinction between the two is that C<depends_on()> is meant to callan action from inside another action, whereas C<dispatch()> is meantto set the very top action in motion.=item dir_contains($first_dir, $second_dir)[version 0.28]Returns true if the first directory logically contains the seconddirectory.  This is just a convenience function because C<File::Spec>doesn't really provide an easy way to figure this out (butC<Path::Class> does...).=item dispatch($action, %args)[version 0.03]Invokes the build action C<$action>.  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.Custom options that have not been registered must be passed in as ahash reference in a key named "args":  $build->dispatch('foo', verbose => 1, args => { my_option => 'value' });This method is intended to be used to programmatically invoke buildactions, e.g. by applications controlling Module::Build-based buildsrather than by subclasses.See also L<depends_on()|/"depends_on(@actions)">.  The maindistinction between the two is that C<depends_on()> is meant to callan action from inside another action, whereas C<dispatch()> is meantto set the very top action in motion.=item dist_dir()[version 0.28]Returns the name of the directory that will be created during theC<dist> action.  The name is derived from the C<dist_name> andC<dist_version> properties.=item dist_name()[version 0.21]Returns the name of the current distribution, as passed to theC<new()> method in a C<dist_name> or modified C<module_name>parameter.=item dist_version()[version 0.21]Returns the version of the current distribution, as determined by theC<new()> method from a C<dist_version>, C<dist_version_from>, orC<module_name> parameter.=item do_system($cmd, @args)[version 0.21]This is a fairly simple wrapper around Perl's C<system()> built-incommand.  Given a command and an array of optional arguments, thismethod will print the command to C<STDOUT>, and then execute it usingPerl's C<system()>.  It returns true or false to indicate success orfailure (the opposite of how C<system()> works, but more intuitive).Note that if you supply a single argument to C<do_system()>, 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.=item feature($name)=item feature($name => $value)[version 0.26]With 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 "feature" 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 C<mysql_support> and C<postgres_support>, and set themto true/false depending on whether the user has the proper databasesinstalled and configured.Features set in this way using the Module::Build object will beavailable for querying during the build/test process and afterinstallation via the generated C<...::ConfigData> module, asC<< ...::ConfigData->feature($name) >>.The C<feature()> and C<config_data()> methods representModule::Build's main support for configuration of installed modules.See also L<Module::Build::Authoring/"SAVING CONFIGURATION INFORMATION">.=item have_c_compiler()[version 0.21]Returns 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.=item install_base_relpaths()=item install_base_relpaths($type)=item install_base_relpaths($type => $path)[version 0.28]Set or retrieve the relative paths that are appended toC<install_base> for any installable element. This is useful if youwant to set the relative install path for custom build elements.With no argument, it returns a reference to a hash containing allelements and their respective values. This hash should not be modifieddirectly; use the multi-argument below form to change values.The single argument form returns the value associated with theelement C<$type>.The multi-argument form allows you to set the paths for element types.C<$value> must be a relative path using unix-like paths.  (A series ofdirectories seperated by slashes.  Eg 'foo/bar'.)  The return value is alocalized path based on C<$value>.Assigning the value C<undef> to an element causes it to be removed.=item install_destination($type)[version 0.28]Returns the directory in which items of type C<$type> (e.g. C<lib>,C<arch>, C<bin>, or anything else returned by the L</install_types()>method) will be installed during the C<install> action.  Any settingsfor C<install_path>, C<install_base>, and C<prefix> are taken intoaccount when determining the return value.=item install_path()=item install_path($type)=item install_path($type => $path)[version 0.28]Set or retrieve paths for specific installable elements. This isuseful when you want to examine any explicit install paths specifiedby the user on the command line, or if you want to set the installpath for a specific installable element based on another attributelike C<install_base()>.With no argument, it returns a reference to a hash containing allelements and their respective values. This hash should not be modifieddirectly; use the multi-argument below form to change values.The single argument form returns the value associated with theelement C<$type>.The multi-argument form allows you to set the paths for element types.The supplied C<$path> should be an absolute path to install elementsof C<$type>.  The return value is C<$path>.Assigning the value C<undef> to an element causes it to be removed.=item install_types()[version 0.28]Returns a list of installable types that this build knows about.These types each correspond to the name of a directory in F<blib/>,and the list usually includes items such as C<lib>, C<arch>, C<bin>,C<script>, C<libdoc>, C<bindoc>, and if HTML documentation is to bebuilt, C<libhtml> and C<binhtml>.  Other user-defined types may alsoexist.=item invoked_action()[version 0.28]This is the name of the original action invoked by the user.  Thisvalue is set when the user invokes F<Build.PL>, the F<Build> script,or programatically through the L<dispatch()|/"dispatch($action, %args)">method.  It does not change as sub-actions are executed asdependencies are evaluated.To get the name of the currently executing dependency, seeL</current_action()> above.=item notes()=item notes($key)=item notes($key => $value)[version 0.20]The C<notes()> value allows you to store your own persistentinformation about the build, and to share that information amongdifferent entities involved in the build.  See the example in theC<current()> method.The C<notes()> method is essentally a glorified hash access.  With noarguments, C<notes()> returns the entire hash of notes.  With one argument,C<notes($key)> returns the value associated with the given key.  With twoarguments, C<notes($key, $value)> sets the value associated with the given keyto C<$value> and returns the new value.The lifetime of the C<notes> data is for "a build" - that is, theC<notes> hash is created when C<perl Build.PL> is run (or when theC<new()> method is run, if the Module::Build Perl API is being usedinstead of called from a shell), and lasts until C<perl Build.PL> isrun again or the C<clean> action is run.=item orig_dir()[version 0.28]Returns a string containing the working directory that was in effectbefore the F<Build> script chdir()-ed into the C<base_dir>.  Thismight be useful for writing wrapper tools that might need to chdir()back out.=item os_type()[version 0.04]If you're subclassing Module::Build and some code needs to alter its

⌨️ 快捷键说明

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