Every remaining (HV *) cast in *.c
[p5sagit/p5-mst-13.2.git] / lib / Module / Build / API.pod
CommitLineData
dc8021d3 1=head1 NAME
2
3Module::Build::API - API Reference for Module Authors
4
5
6=head1 DESCRIPTION
7
8I list here some of the most important methods in C<Module::Build>.
9Normally you won't need to deal with these methods unless you want to
10subclass C<Module::Build>. But since one of the reasons I created
11this module in the first place was so that subclassing is possible
12(and easy), I will certainly write more docs as the interface
13stabilizes.
14
15
16=head2 CONSTRUCTORS
17
18=over 4
19
20=item current()
21
22[version 0.20]
23
24This method returns a reasonable facsimile of the currently-executing
25C<Module::Build> object representing the current build. You can use
7a827510 26this object to query its L</notes()> method, inquire about installed
dc8021d3 27modules, and so on. This is a great way to share information between
28different parts of your build process. For instance, you can ask
29the user a question during C<perl Build.PL>, then use their answer
30during a regression test:
31
32 # In Build.PL:
33 my $color = $build->prompt("What is your favorite color?");
34 $build->notes(color => $color);
35
36 # In t/colortest.t:
37 use Module::Build;
38 my $build = Module::Build->current;
39 my $color = $build->notes('color');
40 ...
41
42The way the C<current()> method is currently implemented, there may be
43slight differences between the C<$build> object in Build.PL and the
44one in C<t/colortest.t>. It is our goal to minimize these differences
45in future releases of Module::Build, so please report any anomalies
46you find.
47
48One important caveat: in its current implementation, C<current()> will
49B<NOT> work correctly if you have changed out of the directory that
50C<Module::Build> was invoked from.
51
52=item new()
53
54[version 0.03]
55
56Creates a new Module::Build object. Arguments to the new() method are
57listed below. Most arguments are optional, but you must provide
7a827510 58either the L</module_name> argument, or L</dist_name> and one of
59L</dist_version> or L</dist_version_from>. In other words, you must
dc8021d3 60provide enough information to determine both a distribution name and
61version.
62
63
64=over 4
65
66=item add_to_cleanup
67
68[version 0.19]
69
70An array reference of files to be cleaned up when the C<clean> action
7a827510 71is performed. See also the L<add_to_cleanup()|/"add_to_cleanup(@files)">
72method.
dc8021d3 73
74=item auto_features
75
76[version 0.26]
77
78This parameter supports the setting of features (see
7a827510 79L</feature($name)>) automatically based on a set of prerequisites. For
dc8021d3 80instance, for a module that could optionally use either MySQL or
81PostgreSQL databases, you might use C<auto_features> like this:
82
83 my $build = Module::Build->new
84 (
85 ...other stuff here...
86 auto_features => {
87 pg_support => {
88 description => "Interface with Postgres databases",
89 requires => { 'DBD::Pg' => 23.3,
90 'DateTime::Format::Pg' => 0 },
91 },
92 mysql_support => {
93 description => "Interface with MySQL databases",
94 requires => { 'DBD::mysql' => 17.9,
95 'DateTime::Format::MySQL' => 0 },
96 },
97 }
98 );
99
100For each feature named, the required prerequisites will be checked, and
101if there are no failures, the feature will be enabled (set to C<1>).
102Otherwise the failures will be displayed to the user and the feature
103will be disabled (set to C<0>).
104
7a827510 105See the documentation for L</requires> for the details of how
dc8021d3 106requirements can be specified.
107
108=item autosplit
109
110[version 0.04]
111
112An optional C<autosplit> argument specifies a file which should be run
7a827510 113through the L<AutoSplit::autosplit()|AutoSplit/autosplit> function.
114If multiple files should be split, the argument may be given as an
115array of the files to split.
dc8021d3 116
117In general I don't consider autosplitting a great idea, because it's
118not always clear that autosplitting achieves its intended performance
119benefits. It may even harm performance in environments like mod_perl,
120where as much as possible of a module's code should be loaded during
121startup.
122
123=item build_class
124
125[version 0.28]
126
7a827510 127The Module::Build class or subclass to use in the build script.
128Defaults to "Module::Build" or the class name passed to or created by
129a call to L</subclass()>. This property is useful if you're
dc8021d3 130writing a custom Module::Build subclass and have a bootstrapping
131problem--that is, your subclass requires modules that may not be
132installed when C<perl Build.PL> is executed, but you've listed in
7a827510 133L</build_requires> so that they should be available when C<./Build> is
dc8021d3 134executed.
135
136=item build_requires
137
138[version 0.07]
139
140Modules listed in this section are necessary to build and install the
141given module, but are not necessary for regular usage of it. This is
142actually an important distinction - it allows for tighter control over
143the body of installed modules, and facilitates correct dependency
144checking on binary/packaged distributions of the module.
145
146See the documentation for L<Module::Build::Authoring/"PREREQUISITES">
147for the details of how requirements can be specified.
148
149=item create_packlist
150
151[version 0.28]
152
153If true, this parameter tells Module::Build to create a F<.packlist>
154file during the C<install> action, just like ExtUtils::MakeMaker does.
155The file is created in a subdirectory of the C<arch> installation
156location. It is used by some other tools (CPAN, CPANPLUS, etc.) for
157determining what files are part of an install.
158
159The default value is true. This parameter was introduced in
160Module::Build version 0.2609; previously no packlists were ever
161created by Module::Build.
162
163=item c_source
164
165[version 0.04]
166
167An optional C<c_source> argument specifies a directory which contains
168C source files that the rest of the build may depend on. Any C<.c>
169files in the directory will be compiled to object files. The
170directory will be added to the search path during the compilation and
171linking phases of any C or XS files.
172
173=item conflicts
174
175[version 0.07]
176
177Modules listed in this section conflict in some serious way with the
178given module. C<Module::Build> (or some higher-level tool) will
179refuse to install the given module if the given module/version is also
180installed.
181
182See the documentation for L<Module::Build::Authoring/"PREREQUISITES">
183for the details of how requirements can be specified.
184
185=item create_makefile_pl
186
187[version 0.19]
188
189This parameter lets you use Module::Build::Compat during the
190C<distdir> (or C<dist>) action to automatically create a Makefile.PL
191for compatibility with ExtUtils::MakeMaker. The parameter's value
7a827510 192should be one of the styles named in the L<Module::Build::Compat>
dc8021d3 193documentation.
194
195=item create_readme
196
197[version 0.22]
198
199This parameter tells Module::Build to automatically create a F<README>
200file at the top level of your distribution. Currently it will simply
201use C<Pod::Text> (or C<Pod::Readme> if it's installed) on the file
202indicated by C<dist_version_from> and put the result in the F<README>
203file. This is by no means the only recommended style for writing a
204README, but it seems to be one common one used on the CPAN.
205
206If you generate a F<README> in this way, it's probably a good idea to
207create a separate F<INSTALL> file if that information isn't in the
208generated F<README>.
209
210=item dist_abstract
211
212[version 0.20]
213
214This should be a short description of the distribution. This is used
215when generating metadata for F<META.yml> and PPD files. If it is not
216given then C<Module::Build> looks in the POD of the module from which
217it gets the distribution's version. It looks for the first line
218matching C<$package\s-\s(.+)>, and uses the captured text as the
219abstract.
220
221=item dist_author
222
223[version 0.20]
224
225This should be something like "John Doe <jdoe@example.com>", or if
226there are multiple authors, an anonymous array of strings may be
227specified. This is used when generating metadata for F<META.yml> and
228PPD files. If this is not specified, then C<Module::Build> looks at
229the module from which it gets the distribution's version. If it finds
230a POD section marked "=head1 AUTHOR", then it uses the contents of
231this section.
232
233=item dist_name
234
235[version 0.11]
236
237Specifies the name for this distribution. Most authors won't need to
238set this directly, they can use C<module_name> to set C<dist_name> to
239a reasonable default. However, some agglomerative distributions like
240C<libwww-perl> or C<bioperl> have names that don't correspond directly
241to a module name, so C<dist_name> can be set independently.
242
243=item dist_version
244
245[version 0.11]
246
7a827510 247Specifies a version number for the distribution. See L</module_name>
248or L</dist_version_from> for ways to have this set automatically from a
dc8021d3 249C<$VERSION> variable in a module. One way or another, a version
250number needs to be set.
251
252=item dist_version_from
253
254[version 0.11]
255
256Specifies a file to look for the distribution version in. Most
7a827510 257authors won't need to set this directly, they can use L</module_name>
dc8021d3 258to set it to a reasonable default.
259
260The version is extracted from the specified file according to the same
7a827510 261rules as L<ExtUtils::MakeMaker> and C<CPAN.pm>. It involves finding
dc8021d3 262the first line that matches the regular expression
263
264 /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/
265
266eval()-ing that line, then checking the value of the C<$VERSION>
267variable. Quite ugly, really, but all the modules on CPAN depend on
268this process, so there's no real opportunity to change to something
269better.
270
271=item dynamic_config
272
273[version 0.07]
274
275A boolean flag indicating whether the F<Build.PL> file must be
276executed, or whether this module can be built, tested and installed
277solely from consulting its metadata file. The main reason to set this
278to a true value is that your module performs some dynamic
279configuration as part of its build/install process. If the flag is
280omitted, the F<META.yml> spec says that installation tools should
281treat it as 1 (true), because this is a safer way to behave.
282
283Currently C<Module::Build> doesn't actually do anything with this flag
7a827510 284- it's up to higher-level tools like C<CPAN.pm> to do something useful
285with it. It can potentially bring lots of security, packaging, and
286convenience improvements.
dc8021d3 287
288=item extra_compiler_flags
289
290=item extra_linker_flags
291
292[version 0.19]
293
294These parameters can contain array references (or strings, in which
295case they will be split into arrays) to pass through to the compiler
296and linker phases when compiling/linking C code. For example, to tell
297the compiler that your code is C++, you might do:
298
299 my $build = Module::Build->new
300 (
301 module_name => 'Foo::Bar',
302 extra_compiler_flags => ['-x', 'c++'],
303 );
304
305To link your XS code against glib you might write something like:
306
307 my $build = Module::Build->new
308 (
309 module_name => 'Foo::Bar',
310 dynamic_config => 1,
311 extra_compiler_flags => scalar `glib-config --cflags`,
312 extra_linker_flags => scalar `glib-config --libs`,
313 );
314
315=item get_options
316
317[version 0.26]
318
319You can pass arbitrary command line options to F<Build.PL> or
320F<Build>, and they will be stored in the Module::Build object and can
7a827510 321be accessed via the L</args()> method. However, sometimes you want
dc8021d3 322more flexibility out of your argument processing than this allows. In
323such cases, use the C<get_options> parameter to pass in a hash
324reference of argument specifications, and the list of arguments to
325F<Build.PL> or F<Build> will be processed according to those
326specifications before they're passed on to C<Module::Build>'s own
327argument processing.
328
329The supported option specification hash keys are:
330
331
332=over 4
333
334=item type
335
336The type of option. The types are those supported by Getopt::Long; consult
337its documentation for a complete list. Typical types are C<=s> for strings,
338C<+> for additive options, and C<!> for negatable options. If the
339type is not specified, it will be considered a boolean, i.e. no
340argument is taken and a value of 1 will be assigned when the option is
341encountered.
342
343=item store
344
345A reference to a scalar in which to store the value passed to the option.
346If not specified, the value will be stored under the option name in the
347hash returned by the C<args()> method.
348
349=item default
350
351A default value for the option. If no default value is specified and no option
352is passed, then the option key will not exist in the hash returned by
353C<args()>.
354
355=back
356
357
358You can combine references to your own variables or subroutines with
359unreferenced specifications, for which the result will also be stored in the
360hash returned by C<args()>. For example:
361
362 my $loud = 0;
363 my $build = Module::Build->new
364 (
365 module_name => 'Foo::Bar',
366 get_options => {
367 loud => { store => \$loud },
368 dbd => { type => '=s' },
369 quantity => { type => '+' },
370 }
371 );
372
373 print STDERR "HEY, ARE YOU LISTENING??\n" if $loud;
374 print "We'll use the ", $build->args('dbd'), " DBI driver\n";
375 print "Are you sure you want that many?\n"
376 if $build->args('quantity') > 2;
377
378The arguments for such a specification can be called like so:
379
380 perl Build.PL --loud --dbd=DBD::pg --quantity --quantity --quantity
381
382B<WARNING:> Any option specifications that conflict with Module::Build's own
383options (defined by its properties) will throw an exception.
384
385Consult the Getopt::Long documentation for details on its usage.
386
387=item include_dirs
388
389[version 0.24]
390
391Specifies any additional directories in which to search for C header
392files. May be given as a string indicating a single directory, or as
393a list reference indicating multiple directories.
394
395=item install_path
396
397[version 0.19]
398
399You can set paths for individual installable elements by using the
400C<install_path> parameter:
401
402 my $build = Module::Build->new
403 (
404 ...other stuff here...
405 install_path => {
406 lib => '/foo/lib',
407 arch => '/foo/lib/arch',
408 }
409 );
410
411=item installdirs
412
413[version 0.19]
414
415Determines where files are installed within the normal perl hierarchy
416as determined by F<Config.pm>. Valid values are: C<core>, C<site>,
417C<vendor>. The default is C<site>. See
418L<Module::Build/"INSTALL PATHS">
419
420=item license
421
422[version 0.07]
423
424Specifies the licensing terms of your distribution. Valid options include:
425
426
427=over 4
428
429=item apache
430
431The distribution is licensed under the Apache Software License
7a827510 432(L<http://opensource.org/licenses/apachepl.php>).
dc8021d3 433
434=item artistic
435
436The distribution is licensed under the Artistic License, as specified
7a827510 437by the F<Artistic> file in the standard Perl distribution.
438
439=item artistic_2
440
441The distribution is licensed under the Artistic 2.0 License
442(L<http://opensource.org/licenses/artistic-license-2.0.php>.)
dc8021d3 443
444=item bsd
445
446The distribution is licensed under the BSD License
7a827510 447(L<http://www.opensource.org/licenses/bsd-license.php>).
dc8021d3 448
449=item gpl
450
7a827510 451The distribution is licensed under the terms of the GNU General
452Public License (L<http://www.opensource.org/licenses/gpl-license.php>).
dc8021d3 453
454=item lgpl
455
7a827510 456The distribution is licensed under the terms of the GNU Lesser
dc8021d3 457General Public License
7a827510 458(L<http://www.opensource.org/licenses/lgpl-license.php>).
dc8021d3 459
460=item mit
461
462The distribution is licensed under the MIT License
7a827510 463(L<http://opensource.org/licenses/mit-license.php>).
dc8021d3 464
465=item mozilla
466
467The distribution is licensed under the Mozilla Public
7a827510 468License. (L<http://opensource.org/licenses/mozilla1.0.php> or
469L<http://opensource.org/licenses/mozilla1.1.php>)
dc8021d3 470
471=item open_source
472
473The distribution is licensed under some other Open Source
474Initiative-approved license listed at
7a827510 475L<http://www.opensource.org/licenses/>.
dc8021d3 476
477=item perl
478
479The distribution may be copied and redistributed under the same terms
7a827510 480as Perl itself (this is by far the most common licensing option for
dc8021d3 481modules on CPAN). This is a dual license, in which the user may
482choose between either the GPL or the Artistic license.
483
484=item restrictive
485
486The distribution may not be redistributed without special permission
487from the author and/or copyright holder.
488
489=item unrestricted
490
491The distribution is licensed under a license that is B<not> approved
492by www.opensource.org but that allows distribution without
493restrictions.
494
495=back
496
497
498Note that you must still include the terms of your license in your
499documentation - this field only lets automated tools figure out your
500licensing restrictions. Humans still need something to read. If you
501choose to provide this field, you should make sure that you keep it in
502sync with your written documentation if you ever change your licensing
503terms.
504
738349a8 505You may also use a license type of C<unknown> if you don't wish to
506specify your terms in the metadata.
507
dc8021d3 508It is a fatal error to use a license other than the ones mentioned
509above. This is not because I wish to impose licensing terms on you -
510please let me know if you would like another license option to be
738349a8 511added to the list. I just started out with a small set of licenses to
512keep things simple, figuring I'd let people with actual working
513knowledge in this area tell me what to do. So if that's you, drop me
514a line.
dc8021d3 515
516=item meta_add
517
518[version 0.28]
519
520A hash of key/value pairs that should be added to the F<META.yml> file
521during the C<distmeta> action. Any existing entries with the same
522names will be overridden.
523
7a827510 524See the L</"MODULE METADATA"> section for details.
525
dc8021d3 526=item meta_merge
527
528[version 0.28]
529
530A hash of key/value pairs that should be merged into the F<META.yml>
531file during the C<distmeta> action. Any existing entries with the
532same names will be overridden.
533
534The only difference between C<meta_add> and C<meta_merge> is their
535behavior on hash-valued and array-valued entries: C<meta_add> will
536completely blow away the existing hash or array value, but
537C<meta_merge> will merge the supplied data into the existing hash or
538array value.
539
7a827510 540See the L</"MODULE METADATA"> section for details.
541
dc8021d3 542=item module_name
543
544[version 0.03]
545
546The C<module_name> is a shortcut for setting default values of
547C<dist_name> and C<dist_version_from>, reflecting the fact that the
548majority of CPAN distributions are centered around one "main" module.
549For instance, if you set C<module_name> to C<Foo::Bar>, then
550C<dist_name> will default to C<Foo-Bar> and C<dist_version_from> will
551default to C<lib/Foo/Bar.pm>. C<dist_version_from> will in turn be
552used to set C<dist_version>.
553
554Setting C<module_name> won't override a C<dist_*> parameter you
555specify explicitly.
556
557=item PL_files
558
559[version 0.06]
560
561An optional parameter specifying a set of C<.PL> files in your
562distribution. These will be run as Perl scripts prior to processing
563the rest of the files in your distribution. They are usually used as
564templates for creating other files dynamically, so that a file like
565C<lib/Foo/Bar.pm.PL> might create the file C<lib/Foo/Bar.pm>.
566
567The files are specified with the C<.PL> files as hash keys, and the
568file(s) they generate as hash values, like so:
569
570 my $build = Module::Build->new
571 (
572 module_name => 'Foo::Bar',
573 ...
574 PL_files => { 'lib/Foo/Bar.pm.PL' => 'lib/Foo/Bar.pm' },
575 );
576
577Note that the path specifications are I<always> given in Unix-like
578format, not in the style of the local system.
579
580If your C<.PL> scripts don't create any files, or if they create files
581with unexpected names, or even if they create multiple files, you can
582indicate that so that Module::Build can properly handle these created
583files:
584
585 PL_files => {
586 'lib/Foo/Bar.pm.PL' => 'lib/Foo/Bar.pm',
587 'lib/something.PL' => ['/lib/something', '/lib/else'],
588 'lib/funny.PL' => [],
589 }
590
591=item pm_files
592
593[version 0.19]
594
595An optional parameter specifying the set of C<.pm> files in this
596distribution, specified as a hash reference whose keys are the files'
597locations in the distributions, and whose values are their logical
598locations based on their package name, i.e. where they would be found
599in a "normal" Module::Build-style distribution. This parameter is
600mainly intended to support alternative layouts of files.
601
602For instance, if you have an old-style MakeMaker distribution for a
603module called C<Foo::Bar> and a F<Bar.pm> file at the top level of the
604distribution, you could specify your layout in your C<Build.PL> like
605this:
606
607 my $build = Module::Build->new
608 (
609 module_name => 'Foo::Bar',
610 ...
611 pm_files => { 'Bar.pm' => 'lib/Foo/Bar.pm' },
612 );
613
614Note that the values should include C<lib/>, because this is where
615they would be found in a "normal" Module::Build-style distribution.
616
617Note also that the path specifications are I<always> given in
618Unix-like format, not in the style of the local system.
619
620=item pod_files
621
622[version 0.19]
623
624Just like C<pm_files>, but used for specifying the set of C<.pod>
625files in your distribution.
626
627=item recommends
628
629[version 0.08]
630
7a827510 631This is just like the L</requires> argument, except that modules listed
dc8021d3 632in this section aren't essential, just a good idea. We'll just print
633a friendly warning if one of these modules aren't found, but we'll
634continue running.
635
636If a module is recommended but not required, all tests should still
637pass if the module isn't installed. This may mean that some tests
638may be skipped if recommended dependencies aren't present.
639
640Automated tools like CPAN.pm should inform the user when recommended
641modules aren't installed, and it should offer to install them if it
642wants to be helpful.
643
644See the documentation for L<Module::Build::Authoring/"PREREQUISITES">
645for the details of how requirements can be specified.
646
647=item recursive_test_files
648
649[version 0.28]
650
651Normally, C<Module::Build> does not search subdirectories when looking
652for tests to run. When this options is set it will search recursively
653in all subdirectories of the standard 't' test directory.
654
655=item requires
656
657[version 0.07]
658
659An optional C<requires> argument specifies any module prerequisites
660that the current module depends on.
661
662One note: currently C<Module::Build> doesn't actually I<require> the
663user to have dependencies installed, it just strongly urges. In the
7a827510 664future we may require it. There's also a L</recommends> section for
dc8021d3 665things that aren't absolutely required.
666
667Automated tools like CPAN.pm should refuse to install a module if one
668of its dependencies isn't satisfied, unless a "force" command is given
669by the user. If the tools are helpful, they should also offer to
670install the dependencies.
671
672A synonym for C<requires> is C<prereq>, to help succour people
673transitioning from C<ExtUtils::MakeMaker>. The C<requires> term is
674preferred, but the C<prereq> term will remain valid in future
675distributions.
676
677See the documentation for L<Module::Build::Authoring/"PREREQUISITES">
678for the details of how requirements can be specified.
679
680=item script_files
681
682[version 0.18]
683
684An optional parameter specifying a set of files that should be
7a827510 685installed as executable Perl scripts when the module is installed.
738349a8 686May be given as an array reference of the files, as a hash reference
687whose keys are the files (and whose values will currently be ignored),
688as a string giving the name of a directory in which to find scripts,
689or as a string giving the name of a single script file.
dc8021d3 690
738349a8 691The default is to install any scripts found in a F<bin> directory at
692the top level of the distribution.
dc8021d3 693
694For backward compatibility, you may use the parameter C<scripts>
695instead of C<script_files>. Please consider this usage deprecated,
696though it will continue to exist for several version releases.
697
698=item sign
699
700[version 0.16]
701
7a827510 702If a true value is specified for this parameter, L<Module::Signature>
dc8021d3 703will be used (via the 'distsign' action) to create a SIGNATURE file
704for your distribution during the 'distdir' action, and to add the
705SIGNATURE file to the MANIFEST (therefore, don't add it yourself).
706
707The default value is false. In the future, the default may change to
708true if you have C<Module::Signature> installed on your system.
709
710=item test_files
711
712[version 0.23]
713
714An optional parameter specifying a set of files that should be used as
715C<Test::Harness>-style regression tests to be run during the C<test>
716action. May be given as an array reference of the files, or as a hash
717reference whose keys are the files (and whose values will currently be
718ignored). If the argument is given as a single string (not in an
719array reference), that string will be treated as a C<glob()> pattern
720specifying the files to use.
721
722The default is to look for a F<test.pl> script in the top-level
723directory of the distribution, and any files matching the glob pattern
724C<*.t> in the F<t/> subdirectory. If the C<recursive_test_files>
725property is true, then the C<t/> directory will be scanned recursively
726for C<*.t> files.
727
738349a8 728=item use_tap_harness
729
730[version 0.2808_03]
731
732An optional parameter indicating whether or not to use TAP::Harness for
733testing rather than Test::Harness. Defaults to false. If set to true, you must
734therefore be sure to add TAP::Harness as a requirement for your module in
735L</build_requires>. Implicitly set to a true value if C<tap_harness_args> is
736specified.
737
738=item tap_harness_args
739
740[version 0.2808_03]
741
742An optional parameter specifying parameters to be passed to TAP::Harness when
743running tests. Must be given as a hash reference of parameters; see the
744L<TAP::Harness|TAP::Harness> documentation for details. Note that specifying
745this parameter will implicitly set C<use_tap_harness> to a true value. You
746must therefore be sure to add TAP::Harness as a requirement for your module in
747L</build_requires>.
77e96e88 748
dc8021d3 749=item xs_files
750
751[version 0.19]
752
753Just like C<pm_files>, but used for specifying the set of C<.xs>
754files in your distribution.
755
756=back
757
758
759=item new_from_context(%args)
760
761[version 0.28]
762
763When called from a directory containing a F<Build.PL> script and a
764F<META.yml> file (in other words, the base directory of a
765distribution), this method will run the F<Build.PL> and return the
766resulting C<Module::Build> object to the caller. Any key-value
767arguments given to C<new_from_context()> are essentially like
768command line arguments given to the F<Build.PL> script, so for example
769you could pass C<< verbose => 1 >> to this method to turn on
770verbosity.
771
772=item resume()
773
774[version 0.03]
775
776You'll probably never call this method directly, it's only called from
777the auto-generated C<Build> script. The C<new()> method is only
778called once, when the user runs C<perl Build.PL>. Thereafter, when
779the user runs C<Build test> or another action, the C<Module::Build>
780object is created using the C<resume()> method to re-instantiate with
781the settings given earlier to C<new()>.
782
783=item subclass()
784
785[version 0.06]
786
787This creates a new C<Module::Build> subclass on the fly, as described
788in the L<Module::Build::Authoring/"SUBCLASSING"> section. The caller
789must provide either a C<class> or C<code> parameter, or both. The
790C<class> parameter indicates the name to use for the new subclass, and
791defaults to C<MyModuleBuilder>. The C<code> parameter specifies Perl
792code to use as the body of the subclass.
793
794=back
795
796
797=head2 METHODS
798
799=over 4
800
801=item add_build_element($type)
802
803[version 0.26]
804
805Adds a new type of entry to the build process. Accepts a single
806string specifying its type-name. There must also be a method defined
807to process things of that type, e.g. if you add a build element called
808C<'foo'>, then you must also define a method called
809C<process_foo_files()>.
810
811See also
812L<Module::Build::Cookbook/"Adding new file types to the build process">.
813
814=item add_to_cleanup(@files)
815
816[version 0.03]
817
818You may call C<< $self->add_to_cleanup(@patterns) >> to tell
819C<Module::Build> that certain files should be removed when the user
820performs the C<Build clean> action. The arguments to the method are
821patterns suitable for passing to Perl's C<glob()> function, specified
822in either Unix format or the current machine's native format. It's
823usually convenient to use Unix format when you hard-code the filenames
824(e.g. in F<Build.PL>) and the native format when the names are
825programmatically generated (e.g. in a testing script).
826
827I decided to provide a dynamic method of the C<$build> object, rather
828than just use a static list of files named in the F<Build.PL>, because
829these static lists can get difficult to manage. I usually prefer to
830keep the responsibility for registering temporary files close to the
831code that creates them.
832
833=item args()
834
835[version 0.26]
836
837 my $args_href = $build->args;
838 my %args = $build->args;
839 my $arg_value = $build->args($key);
840 $build->args($key, $value);
841
842This method is the preferred interface for retrieving the arguments passed via
843command line options to F<Build.PL> or F<Build>, minus the Module-Build
844specific options.
845
846When called in in a scalar context with no arguments, this method returns a
847reference to the hash storing all of the arguments; in an array context, it
848returns the hash itself. When passed a single argument, it returns the value
849stored in the args hash for that option key. When called with two arguments,
850the second argument is assigned to the args hash under the key passed as the
851first argument.
852
853=item autosplit_file($from, $to)
854
855[version 0.28]
856
7a827510 857Invokes the L<AutoSplit> module on the C<$from> file, sending the
dc8021d3 858output to the C<lib/auto> directory inside C<$to>. C<$to> is
859typically the C<blib/> directory.
860
861=item base_dir()
862
863[version 0.14]
864
865Returns a string containing the root-level directory of this build,
866i.e. where the C<Build.PL> script and the C<lib> directory can be
867found. This is usually the same as the current working directory,
868because the C<Build> script will C<chdir()> into this directory as
869soon as it begins execution.
870
871=item build_requires()
872
873[version 0.21]
874
875Returns a hash reference indicating the C<build_requires>
876prerequisites that were passed to the C<new()> method.
877
738349a8 878=item cbuilder()
879
880[version 0.2809]
881
882Returns the internal ExtUtils::CBuilder object that can be used for
883compiling & linking C code. If no such object is available (e.g. if
884the system has no compiler installed) an exception will be thrown.
885
886
dc8021d3 887=item check_installed_status($module, $version)
888
889[version 0.11]
890
891This method returns a hash reference indicating whether a version
892dependency on a certain module is satisfied. The C<$module> argument
893is given as a string like C<"Data::Dumper"> or C<"perl">, and the
7a827510 894C<$version> argument can take any of the forms described in L</requires>
dc8021d3 895above. This allows very fine-grained version checking.
896
897The returned hash reference has the following structure:
898
899 {
900 ok => $whether_the_dependency_is_satisfied,
901 have => $version_already_installed,
902 need => $version_requested, # Same as incoming $version argument
903 message => $informative_error_message,
904 }
905
906If no version of C<$module> is currently installed, the C<have> value
907will be the string C<< "<none>" >>. Otherwise the C<have> value will
908simply be the version of the installed module. Note that this means
909that if C<$module> is installed but doesn't define a version number,
910the C<have> value will be C<undef> - this is why we don't use C<undef>
911for the case when C<$module> isn't installed at all.
912
913This method may be called either as an object method
914(C<< $build->check_installed_status($module, $version) >>)
7a827510 915or as a class method
dc8021d3 916(C<< Module::Build->check_installed_status($module, $version) >>).
917
918=item check_installed_version($module, $version)
919
920[version 0.05]
921
7a827510 922Like L<check_installed_status()|/"check_installed_status($module, $version)">,
923but simply returns true or false depending on whether module
924C<$module> satisfies the dependency C<$version>.
dc8021d3 925
926If the check succeeds, the return value is the actual version of
927C<$module> installed on the system. This allows you to do the
928following:
929
930 my $installed = $build->check_installed_version('DBI', '1.15');
931 if ($installed) {
932 print "Congratulations, version $installed of DBI is installed.\n";
933 } else {
934 die "Sorry, you must install DBI.\n";
935 }
936
937If the check fails, we return false and set C<$@> to an informative
938error message.
939
940If C<$version> is any non-true value (notably zero) and any version of
941C<$module> is installed, we return true. In this case, if C<$module>
942doesn't define a version, or if its version is zero, we return the
943special value "0 but true", which is numerically zero, but logically
944true.
945
946In general you might prefer to use C<check_installed_status> if you
947need detailed information, or this method if you just need a yes/no
948answer.
949
950=item compare_versions($v1, $op, $v2)
951
952[version 0.28]
953
954Compares two module versions C<$v1> and C<$v2> using the operator
955C<$op>, which should be one of Perl's numeric operators like C<!=> or
956C<< >= >> or the like. We do at least a halfway-decent job of
957handling versions that aren't strictly numeric, like C<0.27_02>, but
958exotic stuff will likely cause problems.
959
960In the future, the guts of this method might be replaced with a call
961out to C<version.pm>.
962
77e96e88 963=item config($key)
964
965=item config($key, $value)
966
967=item config() [deprecated]
dc8021d3 968
969[version 0.22]
970
77e96e88 971With a single argument C<$key>, returns the value associated with that
972key in the C<Config.pm> hash, including any changes the author or user
7a827510 973has specified.
77e96e88 974
975With C<$key> and C<$value> arguments, sets the value for future
976callers of C<config($key)>.
977
978With no arguments, returns a hash reference containing all such
979key-value pairs. This usage is deprecated, though, because it's a
980resource hog and violates encapsulation.
dc8021d3 981
982=item config_data($name)
983
984=item config_data($name => $value)
985
986[version 0.26]
987
988With a single argument, returns the value of the configuration
989variable C<$name>. With two arguments, sets the given configuration
7a827510 990variable to the given value. The value may be any Perl scalar that's
dc8021d3 991serializable with C<Data::Dumper>. For instance, if you write a
992module that can use a MySQL or PostgreSQL back-end, you might create
993configuration variables called C<mysql_connect> and
994C<postgres_connect>, and set each to an array of connection parameters
995for C<< DBI->connect() >>.
996
997Configuration values set in this way using the Module::Build object
998will be available for querying during the build/test process and after
999installation via the generated C<...::ConfigData> module, as
1000C<< ...::ConfigData->config($name) >>.
1001
7a827510 1002The L<feature()|/"feature($name)"> and C<config_data()> methods represent
dc8021d3 1003Module::Build's main support for configuration of installed modules.
1004See also L<Module::Build::Authoring/"SAVING CONFIGURATION INFORMATION">.
1005
1006=item conflicts()
1007
1008[version 0.21]
1009
1010Returns a hash reference indicating the C<conflicts> prerequisites
1011that were passed to the C<new()> method.
1012
1013=item contains_pod($file)
1014
1015[version 0.20]
1016
1017[Deprecated] Please see L<Module::Build::ModuleInfo> instead.
1018
1019Returns true if the given file appears to contain POD documentation.
1020Currently this checks whether the file has a line beginning with
1021'=pod', '=head', or '=item', but the exact semantics may change in the
1022future.
1023
1024=item copy_if_modified(%parameters)
1025
1026[version 0.19]
1027
1028Takes the file in the C<from> parameter and copies it to the file in
1029the C<to> parameter, or the directory in the C<to_dir> parameter, if
1030the file has changed since it was last copied (or if it doesn't exist
1031in the new location). By default the entire directory structure of
1032C<from> will be copied into C<to_dir>; an optional C<flatten>
1033parameter will copy into C<to_dir> without doing so.
1034
1035Returns the path to the destination file, or C<undef> if nothing
1036needed to be copied.
1037
1038Any directories that need to be created in order to perform the
1039copying will be automatically created.
1040
1041The destination file is set to read-only. If the source file has the
1042executable bit set, then the destination file will be made executable.
1043
1044=item create_build_script()
1045
1046[version 0.05]
1047
1048Creates an executable script called C<Build> in the current directory
1049that will be used to execute further user actions. This script is
1050roughly analogous (in function, not in form) to the Makefile created
1051by C<ExtUtils::MakeMaker>. This method also creates some temporary
1052data in a directory called C<_build/>. Both of these will be removed
1053when the C<realclean> action is performed.
1054
7253302f 1055Among the files created in C<_build/> is a F<_build/prereqs> file
1056containing the set of prerequisites for this distribution, as a hash
1057of hashes. This file may be C<eval()>-ed to obtain the authoritative
7a827510 1058set of prereqs, which might be different from the contents of
1059F<META.yml> (because F<Build.PL> might have set them dynamically).
1060But fancy developers take heed: do not put any fancy custom runtime
1061code in the F<_build/prereqs> file, leave it as a static declaration
1062containing only strings and numbers. Similarly, do not alter the
1063structure of the internal C<< $self->{properties}{requires} >> (etc.)
1064data members, because that's where this data comes from.
7253302f 1065
dc8021d3 1066=item current_action()
1067
1068[version 0.28]
1069
1070Returns the name of the currently-running action, such as "build" or
1071"test". This action is not necessarily the action that was originally
1072invoked by the user. For example, if the user invoked the "test"
1073action, current_action() would initially return "test". However,
1074action "test" depends on action "code", so current_action() will
1075return "code" while that dependency is being executed. Once that
1076action has completed, current_action() will again return "test".
1077
1078If you need to know the name of the original action invoked by the
7a827510 1079user, see L</invoked_action()> below.
dc8021d3 1080
1081=item depends_on(@actions)
1082
1083[version 0.28]
1084
1085Invokes the named action or list of actions in sequence. Using this
1086method is preferred to calling the action explicitly because it
1087performs some internal record-keeping, and it ensures that the same
1088action is not invoked multiple times (note: in future versions of
1089Module::Build it's conceivable that this run-only-once mechanism will
1090be changed to something more intelligent).
1091
1092Note that the name of this method is something of a misnomer; it
1093should really be called something like
1094C<invoke_actions_unless_already_invoked()> or something, but for
1095better or worse (perhaps better!) we were still thinking in
1096C<make>-like dependency terms when we created this method.
1097
7a827510 1098See also L<dispatch()|/"dispatch($action, %args)">. The main
1099distinction between the two is that C<depends_on()> is meant to call
1100an action from inside another action, whereas C<dispatch()> is meant
1101to set the very top action in motion.
dc8021d3 1102
1103=item dir_contains($first_dir, $second_dir)
1104
1105[version 0.28]
1106
1107Returns true if the first directory logically contains the second
1108directory. This is just a convenience function because C<File::Spec>
1109doesn't really provide an easy way to figure this out (but
1110C<Path::Class> does...).
1111
1112=item dispatch($action, %args)
1113
1114[version 0.03]
1115
1116Invokes the build action C<$action>. Optionally, a list of options
1117and their values can be passed in. This is equivalent to invoking an
1118action at the command line, passing in a list of options.
1119
1120Custom options that have not been registered must be passed in as a
1121hash reference in a key named "args":
1122
1123 $build->dispatch('foo', verbose => 1, args => { my_option => 'value' });
1124
1125This method is intended to be used to programmatically invoke build
1126actions, e.g. by applications controlling Module::Build-based builds
1127rather than by subclasses.
1128
7a827510 1129See also L<depends_on()|/"depends_on(@actions)">. The main
1130distinction between the two is that C<depends_on()> is meant to call
1131an action from inside another action, whereas C<dispatch()> is meant
1132to set the very top action in motion.
dc8021d3 1133
1134=item dist_dir()
1135
1136[version 0.28]
1137
1138Returns the name of the directory that will be created during the
1139C<dist> action. The name is derived from the C<dist_name> and
1140C<dist_version> properties.
1141
1142=item dist_name()
1143
1144[version 0.21]
1145
1146Returns the name of the current distribution, as passed to the
1147C<new()> method in a C<dist_name> or modified C<module_name>
1148parameter.
1149
1150=item dist_version()
1151
1152[version 0.21]
1153
1154Returns the version of the current distribution, as determined by the
1155C<new()> method from a C<dist_version>, C<dist_version_from>, or
1156C<module_name> parameter.
1157
1158=item do_system($cmd, @args)
1159
1160[version 0.21]
1161
1162This is a fairly simple wrapper around Perl's C<system()> built-in
1163command. Given a command and an array of optional arguments, this
1164method will print the command to C<STDOUT>, and then execute it using
1165Perl's C<system()>. It returns true or false to indicate success or
1166failure (the opposite of how C<system()> works, but more intuitive).
1167
1168Note that if you supply a single argument to C<do_system()>, it
1169will/may be processed by the systems's shell, and any special
1170characters will do their special things. If you supply multiple
1171arguments, no shell will get involved and the command will be executed
1172directly.
1173
1174=item feature($name)
1175
1176=item feature($name => $value)
1177
1178[version 0.26]
1179
1180With a single argument, returns true if the given feature is set.
1181With two arguments, sets the given feature to the given boolean value.
1182In this context, a "feature" is any optional functionality of an
1183installed module. For instance, if you write a module that could
1184optionally support a MySQL or PostgreSQL backend, you might create
1185features called C<mysql_support> and C<postgres_support>, and set them
1186to true/false depending on whether the user has the proper databases
1187installed and configured.
1188
1189Features set in this way using the Module::Build object will be
1190available for querying during the build/test process and after
7a827510 1191installation via the generated C<...::ConfigData> module, as
dc8021d3 1192C<< ...::ConfigData->feature($name) >>.
1193
1194The C<feature()> and C<config_data()> methods represent
1195Module::Build's main support for configuration of installed modules.
1196See also L<Module::Build::Authoring/"SAVING CONFIGURATION INFORMATION">.
1197
738349a8 1198=item fix_shebang_line(@files)
1199
1200[version 0.??]
1201
1202Modify any "shebang" line in the specified files to use the path to the
1203perl executable being used for the current build. Files are modified
1204in-place. The existing shebang line must have a command that contains
1205"C<perl>"; arguments to the command do not count. In particular, this
1206means that the use of C<#!/usr/bin/env perl> will not be changed.
1207
1208For an explanation of shebang lines, see
1209L<http://en.wikipedia.org/wiki/Shebang_%28Unix%29>.
1210
dc8021d3 1211=item have_c_compiler()
1212
1213[version 0.21]
1214
1215Returns true if the current system seems to have a working C compiler.
1216We currently determine this by attempting to compile a simple C source
1217file and reporting whether the attempt was successful.
1218
1219=item install_base_relpaths()
1220
1221=item install_base_relpaths($type)
1222
1223=item install_base_relpaths($type => $path)
1224
1225[version 0.28]
1226
1227Set or retrieve the relative paths that are appended to
1228C<install_base> for any installable element. This is useful if you
1229want to set the relative install path for custom build elements.
1230
1231With no argument, it returns a reference to a hash containing all
1232elements and their respective values. This hash should not be modified
1233directly; use the multi-argument below form to change values.
1234
1235The single argument form returns the value associated with the
1236element C<$type>.
1237
1238The multi-argument form allows you to set the paths for element types.
1239C<$value> must be a relative path using unix-like paths. (A series of
1240directories seperated by slashes. Eg 'foo/bar'.) The return value is a
1241localized path based on C<$value>.
1242
1243Assigning the value C<undef> to an element causes it to be removed.
1244
1245=item install_destination($type)
1246
1247[version 0.28]
1248
1249Returns the directory in which items of type C<$type> (e.g. C<lib>,
7a827510 1250C<arch>, C<bin>, or anything else returned by the L</install_types()>
dc8021d3 1251method) will be installed during the C<install> action. Any settings
1252for C<install_path>, C<install_base>, and C<prefix> are taken into
1253account when determining the return value.
1254
1255=item install_path()
1256
1257=item install_path($type)
1258
1259=item install_path($type => $path)
1260
1261[version 0.28]
1262
1263Set or retrieve paths for specific installable elements. This is
1264useful when you want to examine any explicit install paths specified
1265by the user on the command line, or if you want to set the install
1266path for a specific installable element based on another attribute
1267like C<install_base()>.
1268
1269With no argument, it returns a reference to a hash containing all
1270elements and their respective values. This hash should not be modified
1271directly; use the multi-argument below form to change values.
1272
1273The single argument form returns the value associated with the
1274element C<$type>.
1275
1276The multi-argument form allows you to set the paths for element types.
1277The supplied C<$path> should be an absolute path to install elements
1278of C<$type>. The return value is C<$path>.
1279
1280Assigning the value C<undef> to an element causes it to be removed.
1281
1282=item install_types()
1283
1284[version 0.28]
1285
1286Returns a list of installable types that this build knows about.
1287These types each correspond to the name of a directory in F<blib/>,
1288and the list usually includes items such as C<lib>, C<arch>, C<bin>,
1289C<script>, C<libdoc>, C<bindoc>, and if HTML documentation is to be
1290built, C<libhtml> and C<binhtml>. Other user-defined types may also
1291exist.
1292
1293=item invoked_action()
1294
1295[version 0.28]
1296
1297This is the name of the original action invoked by the user. This
1298value is set when the user invokes F<Build.PL>, the F<Build> script,
7a827510 1299or programatically through the L<dispatch()|/"dispatch($action, %args)">
1300method. It does not change as sub-actions are executed as
1301dependencies are evaluated.
dc8021d3 1302
1303To get the name of the currently executing dependency, see
7a827510 1304L</current_action()> above.
dc8021d3 1305
1306=item notes()
1307
1308=item notes($key)
1309
1310=item notes($key => $value)
1311
1312[version 0.20]
1313
1314The C<notes()> value allows you to store your own persistent
1315information about the build, and to share that information among
1316different entities involved in the build. See the example in the
1317C<current()> method.
1318
1319The C<notes()> method is essentally a glorified hash access. With no
1320arguments, C<notes()> returns the entire hash of notes. With one argument,
1321C<notes($key)> returns the value associated with the given key. With two
1322arguments, C<notes($key, $value)> sets the value associated with the given key
1323to C<$value> and returns the new value.
1324
1325The lifetime of the C<notes> data is for "a build" - that is, the
1326C<notes> hash is created when C<perl Build.PL> is run (or when the
1327C<new()> method is run, if the Module::Build Perl API is being used
1328instead of called from a shell), and lasts until C<perl Build.PL> is
1329run again or the C<clean> action is run.
1330
1331=item orig_dir()
1332
1333[version 0.28]
1334
1335Returns a string containing the working directory that was in effect
1336before the F<Build> script chdir()-ed into the C<base_dir>. This
1337might be useful for writing wrapper tools that might need to chdir()
1338back out.
1339
1340=item os_type()
1341
1342[version 0.04]
1343
1344If you're subclassing Module::Build and some code needs to alter its
1345behavior based on the current platform, you may only need to know
1346whether you're running on Windows, Unix, MacOS, VMS, etc., and not the
1347fine-grained value of Perl's C<$^O> variable. The C<os_type()> method
1348will return a string like C<Windows>, C<Unix>, C<MacOS>, C<VMS>, or
1349whatever is appropriate. If you're running on an unknown platform, it
1350will return C<undef> - there shouldn't be many unknown platforms
1351though.
1352
c1d8f74e 1353=item is_vmsish()
1354
1355=item is_windowsish()
1356
1357=item is_unixish()
1358
1359Convenience functions that return a boolean value indicating whether
1360this platform behaves respectively like VMS, Windows, or Unix. For
1361arbitrary reasons other platforms don't get their own such functions,
1362at least not yet.
1363
1364
dc8021d3 1365=item prefix_relpaths()
1366
1367=item prefix_relpaths($installdirs)
1368
1369=item prefix_relpaths($installdirs, $type)
1370
1371=item prefix_relpaths($installdirs, $type => $path)
1372
1373[version 0.28]
1374
1375Set or retrieve the relative paths that are appended to C<prefix> for
1376any installable element. This is useful if you want to set the
1377relative install path for custom build elements.
1378
1379With no argument, it returns a reference to a hash containing all
1380elements and their respective values as defined by the current
1381C<installdirs> setting.
1382
1383With a single argument, it returns a reference to a hash containing
1384all elements and their respective values as defined by
1385C<$installdirs>.
1386
1387The hash returned by the above calls should not be modified directly;
1388use the three-argument below form to change values.
1389
1390The two argument form returns the value associated with the
1391element C<$type>.
1392
1393The multi-argument form allows you to set the paths for element types.
1394C<$value> must be a relative path using unix-like paths. (A series of
1395directories seperated by slashes. Eg 'foo/bar'.) The return value is a
1396localized path based on C<$value>.
1397
1398Assigning the value C<undef> to an element causes it to be removed.
1399
1400=item prepare_metadata()
1401
1402[version 0.28]
1403
1404This method is provided for authors to override to customize the
1405fields of F<META.yml>. It is passed a YAML::Node node object which can
1406be modified as desired and then returned. E.g.
1407
1408 package My::Builder;
1409 use base 'Module::Build';
1410
1411 sub prepare_metadata {
1412 my $self = shift;
1413 my $node = $self->SUPER::prepare_metadata( shift );
1414 $node->{custom_field} = 'foo';
1415 return $node;
1416 }
1417
1418=item prereq_failures()
1419
1420[version 0.11]
1421
1422Returns a data structure containing information about any failed
1423prerequisites (of any of the types described above), or C<undef> if
1424all prerequisites are met.
1425
1426The data structure returned is a hash reference. The top level keys
1427are the type of prerequisite failed, one of "requires",
1428"build_requires", "conflicts", or "recommends". The associated values
1429are hash references whose keys are the names of required (or
1430conflicting) modules. The associated values of those are hash
1431references indicating some information about the failure. For example:
1432
1433 {
1434 have => '0.42',
1435 need => '0.59',
1436 message => 'Version 0.42 is installed, but we need version 0.59',
1437 }
1438
1439or
1440
1441 {
1442 have => '<none>',
1443 need => '0.59',
1444 message => 'Prerequisite Foo isn't installed',
1445 }
1446
1447This hash has the same structure as the hash returned by the
1448C<check_installed_status()> method, except that in the case of
1449"conflicts" dependencies we change the "need" key to "conflicts" and
1450construct a proper message.
1451
1452Examples:
1453
1454 # Check a required dependency on Foo::Bar
1455 if ( $build->prereq_failures->{requires}{Foo::Bar} ) { ...
1456
1457 # Check whether there were any failures
1458 if ( $build->prereq_failures ) { ...
1459
1460 # Show messages for all failures
1461 my $failures = $build->prereq_failures;
1462 while (my ($type, $list) = each %$failures) {
1463 while (my ($name, $hash) = each %$list) {
1464 print "Failure for $name: $hash->{message}\n";
1465 }
1466 }
1467
1468=item prereq_report()
1469
1470[version 0.28]
1471
1472Returns a human-readable (table-form) string showing all
1473prerequisites, the versions required, and the versions actually
1474installed. This can be useful for reviewing the configuration of your
1475system prior to a build, or when compiling data to send for a bug
1476report. The C<prereq_report> action is just a thin wrapper around the
1477C<prereq_report()> method.
1478
1479=item prompt($message, $default)
1480
1481[version 0.12]
1482
1483Asks the user a question and returns their response as a string. The
1484first argument specifies the message to display to the user (for
1485example, C<"Where do you keep your money?">). The second argument,
1486which is optional, specifies a default answer (for example,
1487C<"wallet">). The user will be asked the question once.
1488
1489If C<prompt()> detects that it is not running interactively and there
1490is nothing on STDIN or if the PERL_MM_USE_DEFAULT environment variable
7253302f 1491is set to true, the $default will be used without prompting.
1492
1493To prevent automated processes from blocking, the user must either set
1494PERL_MM_USE_DEFAULT or attach something to STDIN (this can be a
1495pipe/file containing a scripted set of answers or /dev/null.)
dc8021d3 1496
7253302f 1497If no $default is provided an empty string will be used instead. In
1498non-interactive mode, the absence of $default is an error (though
1499explicitly passing C<undef()> as the default is valid as of 0.27.)
dc8021d3 1500
1501This method may be called as a class or object method.
1502
1503=item recommends()
1504
1505[version 0.21]
1506
1507Returns a hash reference indicating the C<recommends> prerequisites
1508that were passed to the C<new()> method.
1509
1510=item requires()
1511
1512[version 0.21]
1513
1514Returns a hash reference indicating the C<requires> prerequisites that
1515were passed to the C<new()> method.
1516
1517=item rscan_dir($dir, $pattern)
1518
1519[version 0.28]
1520
1521Uses C<File::Find> to traverse the directory C<$dir>, returning a
1522reference to an array of entries matching C<$pattern>. C<$pattern>
1523may either be a regular expression (using C<qr//> or just a plain
1524string), or a reference to a subroutine that will return true for
1525wanted entries. If C<$pattern> is not given, all entries will be
1526returned.
1527
1528Examples:
1529
1530 # All the *.pm files in lib/
1531 $m->rscan_dir('lib', qr/\.pm$/)
7a827510 1532
dc8021d3 1533 # All the files in blib/ that aren't *.html files
1534 $m->rscan_dir('blib', sub {-f $_ and not /\.html$/});
1535
1536 # All the files in t/
1537 $m->rscan_dir('t');
1538
1539=item runtime_params()
1540
1541=item runtime_params($key)
1542
1543[version 0.28]
1544
1545The C<runtime_params()> method stores the values passed on the command line
1546for valid properties (that is, any command line options for which
1547C<valid_property()> returns a true value). The value on the command line may
1548override the default value for a property, as well as any value specified in a
1549call to C<new()>. This allows you to programmatically tell if C<perl Build.PL>
1550or any execution of C<./Build> had command line options specified that
1551override valid properties.
1552
1553The C<runtime_params()> method is essentally a glorified read-only hash. With
1554no arguments, C<runtime_params()> returns the entire hash of properties
1555specified on the command line. With one argument, C<runtime_params($key)>
1556returns the value associated with the given key.
1557
1558The lifetime of the C<runtime_params> data is for "a build" - that is, the
1559C<runtime_params> hash is created when C<perl Build.PL> is run (or when the
1560C<new()> method is called, if the Module::Build Perl API is being used instead
1561of called from a shell), and lasts until C<perl Build.PL> is run again or the
1562C<clean> action is run.
1563
1564=item script_files()
1565
1566[version 0.18]
1567
1568Returns a hash reference whose keys are the perl script files to be
1569installed, if any. This corresponds to the C<script_files> parameter to the
1570C<new()> method. With an optional argument, this parameter may be set
1571dynamically.
1572
1573For backward compatibility, the C<scripts()> method does exactly the
1574same thing as C<script_files()>. C<scripts()> is deprecated, but it
1575will stay around for several versions to give people time to
1576transition.
1577
1578=item up_to_date($source_file, $derived_file)
1579
1580=item up_to_date(\@source_files, \@derived_files)
1581
1582[version 0.20]
1583
1584This method can be used to compare a set of source files to a set of
1585derived files. If any of the source files are newer than any of the
1586derived files, it returns false. Additionally, if any of the derived
1587files do not exist, it returns false. Otherwise it returns true.
1588
1589The arguments may be either a scalar or an array reference of file
1590names.
1591
1592=item y_n($message, $default)
1593
1594[version 0.12]
1595
1596Asks the user a yes/no question using C<prompt()> and returns true or
1597false accordingly. The user will be asked the question repeatedly
1598until they give an answer that looks like "yes" or "no".
1599
1600The first argument specifies the message to display to the user (for
1601example, C<"Shall I invest your money for you?">), and the second
1602argument specifies the default answer (for example, C<"y">).
1603
1604Note that the default is specified as a string like C<"y"> or C<"n">,
1605and the return value is a Perl boolean value like 1 or 0. I thought
1606about this for a while and this seemed like the most useful way to do
1607it.
1608
1609This method may be called as a class or object method.
1610
1611=back
1612
1613
1614=head2 Autogenerated Accessors
1615
1616In addition to the aforementioned methods, there are also some get/set
1617accessor methods for the following properties:
1618
1619=over 4
1620
1621=item PL_files()
1622
0ec9ad96 1623=item allow_mb_mismatch()
1624
dc8021d3 1625=item autosplit()
1626
1627=item base_dir()
1628
1629=item bindoc_dirs()
1630
1631=item blib()
1632
1633=item build_bat()
1634
1635=item build_class()
1636
1637=item build_elements()
1638
1639=item build_requires()
1640
1641=item build_script()
1642
1643=item c_source()
1644
dc8021d3 1645=item config_dir()
1646
7a827510 1647=item configure_requires()
1648
dc8021d3 1649=item conflicts()
1650
1651=item create_makefile_pl()
1652
1653=item create_packlist()
1654
1655=item create_readme()
1656
1657=item debugger()
1658
1659=item destdir()
1660
1661=item get_options()
1662
1663=item html_css()
1664
1665=item include_dirs()
1666
1667=item install_base()
1668
1669=item install_sets()
1670
1671=item installdirs()
1672
1673=item libdoc_dirs()
1674
1675=item license()
1676
1677=item magic_number()
1678
1679=item mb_version()
1680
1681=item meta_add()
1682
1683=item meta_merge()
1684
1685=item metafile()
1686
1687=item module_name()
1688
1689=item orig_dir()
1690
1691=item original_prefix()
1692
1693=item perl()
1694
1695=item pm_files()
1696
1697=item pod_files()
1698
1699=item pollute()
1700
1701=item prefix()
1702
1703=item prereq_action_types()
1704
738349a8 1705=item program_name()
1706
dc8021d3 1707=item quiet()
1708
1709=item recommends()
1710
1711=item recurse_into()
1712
1713=item recursive_test_files()
1714
1715=item requires()
1716
1717=item scripts()
1718
738349a8 1719=item sign()
1720
1721=item tap_harness_args()
1722
1723=item test_file_exts()
1724
dc8021d3 1725=item use_rcfile()
1726
738349a8 1727=item use_tap_harness()
1728
dc8021d3 1729=item verbose()
1730
1731=item xs_files()
1732
1733=back
1734
1735
7a827510 1736=head1 MODULE METADATA
1737
1738If you would like to add other useful metadata, C<Module::Build>
1739supports this with the C<meta_add> and C<meta_merge> arguments to
1740L</new>. The authoritative list of supported metadata can be found at
1741L<http://module-build.sourceforge.net/META-spec-current.html>, but for
1742convenience - here are a few of the more useful ones:
1743
1744=over 4
1745
1746=item keywords
1747
1748For describing the distribution using keyword (or "tags") in order to
1749make CPAN.org indexing and search more efficient and useful.
1750
1751See L<http://module-build.sourceforge.net/META-spec-current.html#keywords>.
1752
1753=item resources
1754
1755A list of additional resources available for users of the
1756distribution. This can include links to a homepage on the web, a
1757bugtracker, the repository location, a even subscription page for the
1758distribution mailing list.
1759
1760See L<http://module-build.sourceforge.net/META-spec-current.html#resources>.
1761
1762=back
1763
1764
dc8021d3 1765=head1 AUTHOR
1766
1767Ken Williams <kwilliams@cpan.org>
1768
1769
1770=head1 COPYRIGHT
1771
1772Copyright (c) 2001-2006 Ken Williams. All rights reserved.
1773
1774This library is free software; you can redistribute it and/or
1775modify it under the same terms as Perl itself.
1776
1777
1778=head1 SEE ALSO
1779
1780perl(1), L<Module::Build>(3), L<Module::Build::Authoring>(3),
1781L<Module::Build::Cookbook>(3), L<ExtUtils::MakeMaker>(3), L<YAML>(3)
1782
1783F<META.yml> Specification:
77e96e88 1784L<http://module-build.sourceforge.net/META-spec-current.html>
dc8021d3 1785
1786=cut