📄 module::build::api.3
字号:
.IP "\fIinstall_base_relpaths()\fR" 4.IX Item "install_base_relpaths()".PD 0.IP "install_base_relpaths($type)" 4.IX Item "install_base_relpaths($type)".ie n .IP "install_base_relpaths($type => $path)" 4.el .IP "install_base_relpaths($type => \f(CW$path\fR)" 4.IX Item "install_base_relpaths($type => $path)".PD[version 0.28].SpSet or retrieve the relative paths that are appended to\&\f(CW\*(C`install_base\*(C'\fR for any installable element. This is useful if youwant to set the relative install path for custom build elements..SpWith 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..SpThe single argument form returns the value associated with theelement \f(CW$type\fR..SpThe multi-argument form allows you to set the paths for element types.\&\f(CW$value\fR 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 \f(CW$value\fR..SpAssigning the value \f(CW\*(C`undef\*(C'\fR to an element causes it to be removed..IP "install_destination($type)" 4.IX Item "install_destination($type)"[version 0.28].SpReturns the directory in which items of type \f(CW$type\fR (e.g. \f(CW\*(C`lib\*(C'\fR,\&\f(CW\*(C`arch\*(C'\fR, \f(CW\*(C`bin\*(C'\fR, or anything else returned by the \*(L"\fIinstall_types()\fR\*(R"method) will be installed during the \f(CW\*(C`install\*(C'\fR action. Any settingsfor \f(CW\*(C`install_path\*(C'\fR, \f(CW\*(C`install_base\*(C'\fR, and \f(CW\*(C`prefix\*(C'\fR are taken intoaccount when determining the return value..IP "\fIinstall_path()\fR" 4.IX Item "install_path()".PD 0.IP "install_path($type)" 4.IX Item "install_path($type)".ie n .IP "install_path($type => $path)" 4.el .IP "install_path($type => \f(CW$path\fR)" 4.IX Item "install_path($type => $path)".PD[version 0.28].SpSet 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 \f(CW\*(C`install_base()\*(C'\fR..SpWith 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..SpThe single argument form returns the value associated with theelement \f(CW$type\fR..SpThe multi-argument form allows you to set the paths for element types.The supplied \f(CW$path\fR should be an absolute path to install elementsof \f(CW$type\fR. The return value is \f(CW$path\fR..SpAssigning the value \f(CW\*(C`undef\*(C'\fR to an element causes it to be removed..IP "\fIinstall_types()\fR" 4.IX Item "install_types()"[version 0.28].SpReturns a list of installable types that this build knows about.These types each correspond to the name of a directory in \fIblib/\fR,and the list usually includes items such as \f(CW\*(C`lib\*(C'\fR, \f(CW\*(C`arch\*(C'\fR, \f(CW\*(C`bin\*(C'\fR,\&\f(CW\*(C`script\*(C'\fR, \f(CW\*(C`libdoc\*(C'\fR, \f(CW\*(C`bindoc\*(C'\fR, and if \s-1HTML\s0 documentation is to bebuilt, \f(CW\*(C`libhtml\*(C'\fR and \f(CW\*(C`binhtml\*(C'\fR. Other user-defined types may alsoexist..IP "\fIinvoked_action()\fR" 4.IX Item "invoked_action()"[version 0.28].SpThis is the name of the original action invoked by the user. Thisvalue is set when the user invokes \fIBuild.PL\fR, the \fIBuild\fR script,or programatically through the \fIdispatch()\fRmethod. It does not change as sub-actions are executed asdependencies are evaluated..SpTo get the name of the currently executing dependency, see\&\*(L"\fIcurrent_action()\fR\*(R" above..IP "\fInotes()\fR" 4.IX Item "notes()".PD 0.IP "notes($key)" 4.IX Item "notes($key)".ie n .IP "notes($key => $value)" 4.el .IP "notes($key => \f(CW$value\fR)" 4.IX Item "notes($key => $value)".PD[version 0.20].SpThe \f(CW\*(C`notes()\*(C'\fR 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 the\&\f(CW\*(C`current()\*(C'\fR method..SpThe \f(CW\*(C`notes()\*(C'\fR method is essentally a glorified hash access. With noarguments, \f(CW\*(C`notes()\*(C'\fR returns the entire hash of notes. With one argument,\&\f(CW\*(C`notes($key)\*(C'\fR returns the value associated with the given key. With twoarguments, \f(CW\*(C`notes($key, $value)\*(C'\fR sets the value associated with the given keyto \f(CW$value\fR and returns the new value..SpThe lifetime of the \f(CW\*(C`notes\*(C'\fR data is for \*(L"a build\*(R" \- that is, the\&\f(CW\*(C`notes\*(C'\fR hash is created when \f(CW\*(C`perl Build.PL\*(C'\fR is run (or when the\&\f(CW\*(C`new()\*(C'\fR method is run, if the Module::Build Perl \s-1API\s0 is being usedinstead of called from a shell), and lasts until \f(CW\*(C`perl Build.PL\*(C'\fR isrun again or the \f(CW\*(C`clean\*(C'\fR action is run..IP "\fIorig_dir()\fR" 4.IX Item "orig_dir()"[version 0.28].SpReturns a string containing the working directory that was in effectbefore the \fIBuild\fR script \fIchdir()\fR\-ed into the \f(CW\*(C`base_dir\*(C'\fR. Thismight be useful for writing wrapper tools that might need to \fIchdir()\fRback out..IP "\fIos_type()\fR" 4.IX Item "os_type()"[version 0.04].SpIf you're subclassing Module::Build and some code needs to alter itsbehavior based on the current platform, you may only need to knowwhether you're running on Windows, Unix, MacOS, \s-1VMS\s0, etc., and not thefine-grained value of Perl's \f(CW$^O\fR variable. The \f(CW\*(C`os_type()\*(C'\fR methodwill return a string like \f(CW\*(C`Windows\*(C'\fR, \f(CW\*(C`Unix\*(C'\fR, \f(CW\*(C`MacOS\*(C'\fR, \f(CW\*(C`VMS\*(C'\fR, orwhatever is appropriate. If you're running on an unknown platform, itwill return \f(CW\*(C`undef\*(C'\fR \- there shouldn't be many unknown platformsthough..IP "\fIis_vmsish()\fR" 4.IX Item "is_vmsish()".PD 0.IP "\fIis_windowsish()\fR" 4.IX Item "is_windowsish()".IP "\fIis_unixish()\fR" 4.IX Item "is_unixish()".PDConvenience functions that return a boolean value indicating whetherthis platform behaves respectively like \s-1VMS\s0, Windows, or Unix. Forarbitrary reasons other platforms don't get their own such functions,at least not yet..IP "\fIprefix_relpaths()\fR" 4.IX Item "prefix_relpaths()".PD 0.IP "prefix_relpaths($installdirs)" 4.IX Item "prefix_relpaths($installdirs)".ie n .IP "prefix_relpaths($installdirs, $type)" 4.el .IP "prefix_relpaths($installdirs, \f(CW$type\fR)" 4.IX Item "prefix_relpaths($installdirs, $type)".ie n .IP "prefix_relpaths($installdirs, $type\fR => \f(CW$path)" 4.el .IP "prefix_relpaths($installdirs, \f(CW$type\fR => \f(CW$path\fR)" 4.IX Item "prefix_relpaths($installdirs, $type => $path)".PD[version 0.28].SpSet or retrieve the relative paths that are appended to \f(CW\*(C`prefix\*(C'\fR forany installable element. This is useful if you want to set therelative install path for custom build elements..SpWith no argument, it returns a reference to a hash containing allelements and their respective values as defined by the current\&\f(CW\*(C`installdirs\*(C'\fR setting..SpWith a single argument, it returns a reference to a hash containingall elements and their respective values as defined by\&\f(CW$installdirs\fR..SpThe hash returned by the above calls should not be modified directly;use the three-argument below form to change values..SpThe two argument form returns the value associated with theelement \f(CW$type\fR..SpThe multi-argument form allows you to set the paths for element types.\&\f(CW$value\fR 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 \f(CW$value\fR..SpAssigning the value \f(CW\*(C`undef\*(C'\fR to an element causes it to be removed..IP "\fIprepare_metadata()\fR" 4.IX Item "prepare_metadata()"[version 0.28].SpThis method is provided for authors to override to customize thefields of \fI\s-1META\s0.yml\fR. It is passed a YAML::Node node object which canbe modified as desired and then returned. E.g..Sp.Vb 2\& package My::Builder;\& use base \*(AqModule::Build\*(Aq;\&\& sub prepare_metadata {\& my $self = shift;\& my $node = $self\->SUPER::prepare_metadata( shift );\& $node\->{custom_field} = \*(Aqfoo\*(Aq;\& return $node;\& }.Ve.IP "\fIprereq_failures()\fR" 4.IX Item "prereq_failures()"[version 0.11].SpReturns a data structure containing information about any failedprerequisites (of any of the types described above), or \f(CW\*(C`undef\*(C'\fR ifall prerequisites are met..SpThe data structure returned is a hash reference. The top level keysare the type of prerequisite failed, one of \*(L"requires\*(R",\&\*(L"build_requires\*(R", \*(L"conflicts\*(R", or \*(L"recommends\*(R". The associated valuesare hash references whose keys are the names of required (orconflicting) modules. The associated values of those are hashreferences indicating some information about the failure. For example:.Sp.Vb 5\& {\& have => \*(Aq0.42\*(Aq,\& need => \*(Aq0.59\*(Aq,\& message => \*(AqVersion 0.42 is installed, but we need version 0.59\*(Aq,\& }.Ve.Spor.Sp.Vb 5\& {\& have => \*(Aq<none>\*(Aq,\& need => \*(Aq0.59\*(Aq,\& message => \*(AqPrerequisite Foo isn\*(Aqt installed\*(Aq,\& }.Ve.SpThis hash has the same structure as the hash returned by the\&\f(CW\*(C`check_installed_status()\*(C'\fR method, except that in the case of\&\*(L"conflicts\*(R" dependencies we change the \*(L"need\*(R" key to \*(L"conflicts\*(R" andconstruct a proper message..SpExamples:.Sp.Vb 2\& # Check a required dependency on Foo::Bar\& if ( $build\->prereq_failures\->{requires}{Foo::Bar} ) { ...\&\& # Check whether there were any failures\& if ( $build\->prereq_failures ) { ...\&\& # Show messages for all failures\& my $failures = $build\->prereq_failures;\& while (my ($type, $list) = each %$failures) {\& while (my ($name, $hash) = each %$list) {\& print "Failure for $name: $hash\->{message}\en";\& }\& }.Ve.IP "\fIprereq_report()\fR" 4.IX Item "prereq_report()"[version 0.28].SpReturns a human-readable (table-form) string showing allprerequisites, the versions required, and the versions actuallyinstalled. This can be useful for reviewing the configuration of yoursystem prior to a build, or when compiling data to send for a bugreport. The \f(CW\*(C`prereq_report\*(C'\fR action is just a thin wrapper around the\&\f(CW\*(C`prereq_report()\*(C'\fR method..ie n .IP "prompt($message, $default)" 4.el .IP "prompt($message, \f(CW$default\fR)" 4.IX Item "prompt($message, $default)"[version 0.12].SpAsks the user a question and returns their response as a string. Thefirst argument specifies the message to display to the user (forexample, \f(CW"Where do you keep your money?"\fR). The second argument,which is optional, specifies a default answer (for example,\&\f(CW"wallet"\fR). The user will be asked the question once..SpIf \f(CW\*(C`prompt()\*(C'\fR detects that it is not running interactively and thereis nothing on \s-1STDIN\s0 or if the \s-1PERL_MM_USE_DEFAULT\s0 environment variableis set to true, the \f(CW$default\fR will be used without prompting..SpTo prevent automated processes from blocking, the user must either set\&\s-1PERL_MM_USE_DEFAULT\s0 or attach something to \s-1STDIN\s0 (this can be apipe/file containing a scripted set of answers or /dev/null.).SpIf no \f(CW$default\fR is provided an empty string will be used instead. Innon-interactive mode, the absence of \f(CW$default\fR is an error (thoughexplicitly passing \f(CW\*(C`undef()\*(C'\fR as the default is valid as of 0.27.).SpThis method may be called as a class or object method..IP "\fIrecommends()\fR" 4.IX Item "recommends()"[version 0.21].SpReturns a hash reference indicating the \f(CW\*(C`recommends\*(C'\fR prerequisitesthat were passed to the \f(CW\*(C`new()\*(C'\fR method..IP "\fIrequires()\fR" 4.IX Item "requires()"[version 0.21].SpReturns a hash reference indicating the \f(CW\*(C`requires\*(C'\fR prerequisites thatwere passed to the \f(CW\*(C`new()\*(C'\fR method..ie n .IP "rscan_dir($dir, $pattern)" 4.el .IP "rscan_dir($dir, \f(CW$pattern\fR)" 4.IX Item "rscan_dir($dir, $pattern)"[version 0.28].SpUses \f(CW\*(C`File::Find\*(C'\fR to traverse the directory \f(CW$dir\fR, returning areference to an array of entries matching \f(CW$pattern\fR. \f(CW$pattern\fRmay either be a regular expression (using \f(CW\*(C`qr//\*(C'\fR or just a plainstring), or a reference to a subroutine that will return true forwanted entries. If \f(CW$pattern\fR is not giv
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -