Module::Build::API - API Reference for Module Authors
I list here some of the most important methods in Module::Build
. Normally you won't need to deal with these methods unless you want to subclass Module::Build
. But since one of the reasons I created this module in the first place was so that subclassing is possible (and easy), I will certainly write more docs as the interface stabilizes.
[version 0.20]
This method returns a reasonable facsimile of the currently-executing Module::Build
object representing the current build. You can use this object to query its "notes()" method, inquire about installed modules, and so on. This is a great way to share information between different parts of your build process. For instance, you can ask the user a question during perl Build.PL
, then use their answer during a regression test:
# In Build.PL:
my $color = $build->prompt("What is your favorite color?");
$build->notes(color => $color);
# In t/colortest.t:
use Module::Build;
my $build = Module::Build->current;
my $color = $build->notes('color');
...
The way the current()
method is currently implemented, there may be slight differences between the $build
object in Build.PL and the one in t/colortest.t
. It is our goal to minimize these differences in future releases of Module::Build, so please report any anomalies you find.
One important caveat: in its current implementation, current()
will NOT work correctly if you have changed out of the directory that Module::Build
was invoked from.
[version 0.03]
Creates a new Module::Build object. Arguments to the new() method are listed below. Most arguments are optional, but you must provide either the "module_name" argument, or "dist_name" and one of "dist_version" or "dist_version_from". In other words, you must provide enough information to determine both a distribution name and version.
[version 0.19]
An array reference of files to be cleaned up when the clean
action is performed. See also the add_to_cleanup() method.
[version 0.4005]
A bool indicating the module is still functional without its xs parts. When an XS module is build with --pureperl_only, it will otherwise fail.
[version 0.34]
This parameter determines whether Module::Build will add itself automatically to configure_requires (and build_requires) if Module::Build is not already there. The required version will be the last 'major' release, as defined by the decimal version truncated to two decimal places (e.g. 0.34, instead of 0.3402). The default value is true.
[version 0.26]
This parameter supports the setting of features (see "feature($name)") automatically based on a set of prerequisites. For instance, for a module that could optionally use either MySQL or PostgreSQL databases, you might use auto_features
like this:
my $build = Module::Build->new
(
...other stuff here...
auto_features => {
pg_support => {
description => "Interface with Postgres databases",
requires => { 'DBD::Pg' => 23.3,
'DateTime::Format::Pg' => 0 },
},
mysql_support => {
description => "Interface with MySQL databases",
requires => { 'DBD::mysql' => 17.9,
'DateTime::Format::MySQL' => 0 },
},
}
);
For each feature named, the required prerequisites will be checked, and if there are no failures, the feature will be enabled (set to 1
). Otherwise the failures will be displayed to the user and the feature will be disabled (set to 0
).
See the documentation for "requires" for the details of how requirements can be specified.
[version 0.04]
An optional autosplit
argument specifies a file which should be run through the AutoSplit::autosplit() function. If multiple files should be split, the argument may be given as an array of the files to split.
In general I don't consider autosplitting a great idea, because it's not always clear that autosplitting achieves its intended performance benefits. It may even harm performance in environments like mod_perl, where as much as possible of a module's code should be loaded during startup.
[version 0.28]
The Module::Build class or subclass to use in the build script. Defaults to "Module::Build" or the class name passed to or created by a call to "subclass()". This property is useful if you're writing a custom Module::Build subclass and have a bootstrapping problem--that is, your subclass requires modules that may not be installed when perl Build.PL
is executed, but you've listed in "build_requires" so that they should be available when ./Build
is executed.
[version 0.07]
Modules listed in this section are necessary to build and install the given module, but are not necessary for regular usage of it. This is actually an important distinction - it allows for tighter control over the body of installed modules, and facilitates correct dependency checking on binary/packaged distributions of the module.
See the documentation for "PREREQUISITES" in Module::Build::Authoring for the details of how requirements can be specified.
[version 0.30]
Modules listed in this section must be installed before configuring this distribution (i.e. before running the Build.PL script). This might be a specific minimum version of Module::Build
or any other module the Build.PL needs in order to do its stuff. Clients like CPAN.pm
or CPANPLUS
will be expected to pick configure_requires
out of the META.yml file and install these items before running the Build.PL
.
Module::Build may automatically add itself to configure_requires. See "auto_configure_requires" for details.
See the documentation for "PREREQUISITES" in Module::Build::Authoring for the details of how requirements can be specified.
[version 0.4004]
Modules listed in this section must be installed before testing the distribution.
See the documentation for "PREREQUISITES" in Module::Build::Authoring for the details of how requirements can be specified.
[version 0.28]
If true, this parameter tells Module::Build to create a .packlist file during the install
action, just like ExtUtils::MakeMaker
does. The file is created in a subdirectory of the arch
installation location. It is used by some other tools (CPAN, CPANPLUS, etc.) for determining what files are part of an install.
The default value is true. This parameter was introduced in Module::Build version 0.2609; previously no packlists were ever created by Module::Build.
[version 0.04]
An optional c_source
argument specifies a directory which contains C source files that the rest of the build may depend on. Any .c
files in the directory will be compiled to object files. The directory will be added to the search path during the compilation and linking phases of any C or XS files.
[version 0.3604]
A list of directories can be supplied using an anonymous array reference of strings.
[version 0.07]
Modules listed in this section conflict in some serious way with the given module. Module::Build
(or some higher-level tool) will refuse to install the given module if the given module/version is also installed.
See the documentation for "PREREQUISITES" in Module::Build::Authoring for the details of how requirements can be specified.
[version 0.31]
This parameter tells Module::Build to automatically create a LICENSE file at the top level of your distribution, containing the full text of the author's chosen license. This requires Software::License
on the author's machine, and further requires that the license
parameter specifies a license that it knows about.
[version 0.19]
This parameter lets you use Module::Build::Compat
during the distdir
(or dist
) action to automatically create a Makefile.PL for compatibility with ExtUtils::MakeMaker
. The parameter's value should be one of the styles named in the Module::Build::Compat documentation.
[version 0.22]
This parameter tells Module::Build to automatically create a README file at the top level of your distribution. Currently it will simply use Pod::Text
(or Pod::Readme
if it's installed) on the file indicated by dist_version_from
and put the result in the README file. This is by no means the only recommended style for writing a README, but it seems to be one common one used on the CPAN.
If you generate a README in this way, it's probably a good idea to create a separate INSTALL file if that information isn't in the generated README.
[version 0.20]
This should be a short description of the distribution. This is used when generating metadata for META.yml and PPD files. If it is not given then Module::Build
looks in the POD of the module from which it gets the distribution's version. If it finds a POD section marked "=head1 NAME", then it looks for the first line matching \s+-\s+(.+)
, and uses the captured text as the abstract.
[version 0.20]
This should be something like "John Doe <[email protected]>", or if there are multiple authors, an anonymous array of strings may be specified. This is used when generating metadata for META.yml and PPD files. If this is not specified, then Module::Build
looks at the module from which it gets the distribution's version. If it finds a POD section marked "=head1 AUTHOR", then it uses the contents of this section.
[version 0.11]
Specifies the name for this distribution. Most authors won't need to set this directly, they can use module_name
to set dist_name
to a reasonable default. However, some agglomerative distributions like libwww-perl
or bioperl
have names that don't correspond directly to a module name, so dist_name
can be set independently.
[version 0.37]
Specifies an optional suffix to include after the version number in the distribution directory (and tarball) name. The only suffix currently recognized by PAUSE is 'TRIAL', which indicates that the distribution should not be indexed. For example:
Foo-Bar-1.23-TRIAL.tar.gz
This will automatically do the "right thing" depending on dist_version
and release_status
. When dist_version
does not have an underscore and release_status
is not 'stable', then dist_suffix
will default to 'TRIAL'. Otherwise it will default to the empty string, disabling the suffix.
In general, authors should only set this if they must override the default behavior for some particular purpose.
[version 0.11]
Specifies a version number for the distribution. See "module_name" or "dist_version_from" for ways to have this set automatically from a $VERSION
variable in a module. One way or another, a version number needs to be set.
[version 0.11]
Specifies a file to look for the distribution version in. Most authors won't need to set this directly, they can use "module_name" to set it to a reasonable default.
The version is extracted from the specified file according to the same rules as ExtUtils::MakeMaker and CPAN.pm
. It involves finding the first line that matches the regular expression
/([\$*])(([\w\:\']*)\bVERSION)\b.*\=/
eval()-ing that line, then checking the value of the $VERSION
variable. Quite ugly, really, but all the modules on CPAN depend on this process, so there's no real opportunity to change to something better.
If the target file of "dist_version_from" contains more than one package declaration, the version returned will be the one matching the configured "module_name".
[version 0.07]
A boolean flag indicating whether the Build.PL file must be executed, or whether this module can be built, tested and installed solely from consulting its metadata file. The main reason to set this to a true value is that your module performs some dynamic configuration as part of its build/install process. If the flag is omitted, the META.yml spec says that installation tools should treat it as 1 (true), because this is a safer way to behave.
Currently Module::Build
doesn't actually do anything with this flag - it's up to higher-level tools like CPAN.pm
to do something useful with it. It can potentially bring lots of security, packaging, and convenience improvements.
[version 0.19]
These parameters can contain array references (or strings, in which case they will be split into arrays) to pass through to the compiler and linker phases when compiling/linking C code. For example, to tell the compiler that your code is C++, you might do:
my $build = Module::Build->new
(
module_name => 'Foo::Bar',
extra_compiler_flags => ['-x', 'c++'],
);
To link your XS code against glib you might write something like:
my $build = Module::Build->new
(
module_name => 'Foo::Bar',
dynamic_config => 1,
extra_compiler_flags => scalar `glib-config --cflags`,
extra_linker_flags => scalar `glib-config --libs`,
);
[version 0.4006]
Any extra arguments to pass to Pod::Man->new()
when building man pages. One common choice might be utf8 => 1
to get Unicode support.
[version 0.26]
You can pass arbitrary command line options to Build.PL or Build, and they will be stored in the Module::Build object and can be accessed via the "args()" method. However, sometimes you want more flexibility out of your argument processing than this allows. In such cases, use the get_options
parameter to pass in a hash reference of argument specifications, and the list of arguments to Build.PL or Build will be processed according to those specifications before they're passed on to Module::Build
's own argument processing.
The supported option specification hash keys are:
The type of option. The types are those supported by Getopt::Long; consult its documentation for a complete list. Typical types are =s
for strings, +
for additive options, and !
for negatable options. If the type is not specified, it will be considered a boolean, i.e. no argument is taken and a value of 1 will be assigned when the option is encountered.
A reference to a scalar in which to store the value passed to the option. If not specified, the value will be stored under the option name in the hash returned by the args()
method.
A default value for the option. If no default value is specified and no option is passed, then the option key will not exist in the hash returned by args()
.
You can combine references to your own variables or subroutines with unreferenced specifications, for which the result will also be stored in the hash returned by args()
. For example:
my $loud = 0;
my $build = Module::Build->new
(
module_name => 'Foo::Bar',
get_options => {
Loud => { store => \$loud },
Dbd => { type => '=s' },
Quantity => { type => '+' },
}
);
print STDERR "HEY, ARE YOU LISTENING??\n" if $loud;
print "We'll use the ", $build->args('Dbd'), " DBI driver\n";
print "Are you sure you want that many?\n"
if $build->args('Quantity') > 2;
The arguments for such a specification can be called like so:
perl Build.PL --Loud --Dbd=DBD::pg --Quantity --Quantity --Quantity
WARNING: Any option specifications that conflict with Module::Build's own options (defined by its properties) will throw an exception. Use capitalized option names to avoid unintended conflicts with future Module::Build options.
Consult the Getopt::Long documentation for details on its usage.
[version 0.24]
Specifies any additional directories in which to search for C header files. May be given as a string indicating a single directory, or as a list reference indicating multiple directories.
[version 0.19]
You can set paths for individual installable elements by using the install_path
parameter:
my $build = Module::Build->new
(
...other stuff here...
install_path => {
lib => '/foo/lib',
arch => '/foo/lib/arch',
}
);
[version 0.19]
Determines where files are installed within the normal perl hierarchy as determined by Config.pm. Valid values are: core
, site
, vendor
. The default is site
. See "INSTALL PATHS" in Module::Build
[version 0.07]
Specifies the licensing terms of your distribution.
As of Module::Build version 0.36_14, you may use a Software::License subclass name (e.g. 'Apache_2_0') instead of one of the keys below.
The legacy list of valid license values include:
The distribution is licensed under the Apache License, Version 2.0 (http://apache.org/licenses/LICENSE-2.0).
The distribution is licensed under the Apache Software License, Version 1.1 (http://apache.org/licenses/LICENSE-1.1).
The distribution is licensed under the Artistic License, as specified by the Artistic file in the standard Perl distribution.
The distribution is licensed under the Artistic 2.0 License (http://opensource.org/licenses/artistic-license-2.0.php.)
The distribution is licensed under the BSD License (http://www.opensource.org/licenses/bsd-license.php).
The distribution is licensed under the terms of the GNU General Public License (http://www.opensource.org/licenses/gpl-license.php).
The distribution is licensed under the terms of the GNU Lesser General Public License (http://www.opensource.org/licenses/lgpl-license.php).
The distribution is licensed under the MIT License (http://opensource.org/licenses/mit-license.php).
The distribution is licensed under the Mozilla Public License. (http://opensource.org/licenses/mozilla1.0.php or http://opensource.org/licenses/mozilla1.1.php)
The distribution is licensed under some other Open Source Initiative-approved license listed at http://www.opensource.org/licenses/.
The distribution may be copied and redistributed under the same terms as Perl itself (this is by far the most common licensing option for modules on CPAN). This is a dual license, in which the user may choose between either the GPL or the Artistic license.
The distribution may not be redistributed without special permission from the author and/or copyright holder.
The distribution is licensed under a license that is not approved by www.opensource.org but that allows distribution without restrictions.
Note that you must still include the terms of your license in your code and documentation - this field only sets the information that is included in distribution metadata to let automated tools figure out your licensing restrictions. Humans still need something to read. If you choose to provide this field, you should make sure that you keep it in sync with your written documentation if you ever change your licensing terms.
You may also use a license type of unknown
if you don't wish to specify your terms in the metadata.
Also see the create_license
parameter.
[version 0.28]
A hash of key/value pairs that should be added to the META.yml file during the distmeta
action. Any existing entries with the same names will be overridden.
See the "MODULE METADATA" section for details.
[version 0.28]
A hash of key/value pairs that should be merged into the META.yml file during the distmeta
action. Any existing entries with the same names will be overridden.
The only difference between meta_add
and meta_merge
is their behavior on hash-valued and array-valued entries: meta_add
will completely blow away the existing hash or array value, but meta_merge
will merge the supplied data into the existing hash or array value.
See the "MODULE METADATA" section for details.
[version 0.03]
The module_name
is a shortcut for setting default values of dist_name
and dist_version_from
, reflecting the fact that the majority of CPAN distributions are centered around one "main" module. For instance, if you set module_name
to Foo::Bar
, then dist_name
will default to Foo-Bar
and dist_version_from
will default to lib/Foo/Bar.pm
. dist_version_from
will in turn be used to set dist_version
.
Setting module_name
won't override a dist_*
parameter you specify explicitly.
[version 0.36]
The needs_compiler
parameter indicates whether a compiler is required to build the distribution. The default is false, unless XS files are found or the c_source
parameter is set, in which case it is true. If true, ExtUtils::CBuilder is automatically added to build_requires
if needed.
For a distribution where a compiler is optional, e.g. a dual XS/pure-Perl distribution, needs_compiler
should explicitly be set to a false value.
[version 0.06]
An optional parameter specifying a set of .PL
files in your distribution. These will be run as Perl scripts prior to processing the rest of the files in your distribution with the name of the file they're generating as an argument. They are usually used as templates for creating other files dynamically, so that a file like lib/Foo/Bar.pm.PL
might create the file lib/Foo/Bar.pm
.
The files are specified with the .PL
files as hash keys, and the file(s) they generate as hash values, like so:
my $build = Module::Build->new
(
module_name => 'Foo::Bar',
...
PL_files => { 'lib/Foo/Bar.pm.PL' => 'lib/Foo/Bar.pm' },
);
Note that the path specifications are always given in Unix-like format, not in the style of the local system.
If your .PL
scripts don't create any files, or if they create files with unexpected names, or even if they create multiple files, you can indicate that so that Module::Build can properly handle these created files:
PL_files => {
'lib/Foo/Bar.pm.PL' => 'lib/Foo/Bar.pm',
'lib/something.PL' => ['/lib/something', '/lib/else'],
'lib/funny.PL' => [],
}
Here's an example of a simple PL file.
my $output_file = shift;
open my $fh, ">", $output_file or die "Can't open $output_file: $!";
print $fh <<'END';
#!/usr/bin/perl
print "Hello, world!\n";
END
PL files are not installed by default, so its safe to put them in lib/ and bin/.
[version 0.19]
An optional parameter specifying the set of .pm
files in this distribution, specified as a hash reference whose keys are the files' locations in the distributions, and whose values are their logical locations based on their package name, i.e. where they would be found in a "normal" Module::Build-style distribution. This parameter is mainly intended to support alternative layouts of files.
For instance, if you have an old-style MakeMaker
distribution for a module called Foo::Bar
and a Bar.pm file at the top level of the distribution, you could specify your layout in your Build.PL
like this:
my $build = Module::Build->new
(
module_name => 'Foo::Bar',
...
pm_files => { 'Bar.pm' => 'lib/Foo/Bar.pm' },
);
Note that the values should include lib/
, because this is where they would be found in a "normal" Module::Build-style distribution.
Note also that the path specifications are always given in Unix-like format, not in the style of the local system.
[version 0.19]
Just like pm_files
, but used for specifying the set of .pod
files in your distribution.
[version 0.08]
This is just like the "requires" argument, except that modules listed in this section aren't essential, just a good idea. We'll just print a friendly warning if one of these modules aren't found, but we'll continue running.
If a module is recommended but not required, all tests should still pass if the module isn't installed. This may mean that some tests may be skipped if recommended dependencies aren't present.
Automated tools like CPAN.pm should inform the user when recommended modules aren't installed, and it should offer to install them if it wants to be helpful.
See the documentation for "PREREQUISITES" in Module::Build::Authoring for the details of how requirements can be specified.
[version 0.28]
Normally, Module::Build
does not search subdirectories when looking for tests to run. When this options is set it will search recursively in all subdirectories of the standard 't' test directory.
[version 0.37]
The CPAN Meta Spec version 2 adds release_status
to allow authors to specify how a distribution should be indexed. Consistent with the spec, this parameter can only have one three values: 'stable', 'testing' or 'unstable'.
Unless explicitly set by the author, release_status
will default to 'stable' unless dist_version
contains an underscore, in which case it will default to 'testing'.
It is an error to specify a release_status
of 'stable' when dist_version
contains an underscore character.
[version 0.07]
An optional requires
argument specifies any module prerequisites that the current module depends on.
One note: currently Module::Build
doesn't actually require the user to have dependencies installed, it just strongly urges. In the future we may require it. There's also a "recommends" section for things that aren't absolutely required.
Automated tools like CPAN.pm should refuse to install a module if one of its dependencies isn't satisfied, unless a "force" command is given by the user. If the tools are helpful, they should also offer to install the dependencies.
A synonym for requires
is prereq
, to help succour people transitioning from ExtUtils::MakeMaker
. The requires
term is preferred, but the prereq
term will remain valid in future distributions.
See the documentation for "PREREQUISITES" in Module::Build::Authoring for the details of how requirements can be specified.
[version 0.18]
An optional parameter specifying a set of files that should be installed as executable Perl scripts when the module is installed. May be given as an array reference of the files, as a hash reference whose keys are the files (and whose values will currently be ignored), as a string giving the name of a directory in which to find scripts, or as a string giving the name of a single script file.
The default is to install any scripts found in a bin directory at the top level of the distribution, minus any keys of PL_files.
For backward compatibility, you may use the parameter scripts
instead of script_files
. Please consider this usage deprecated, though it will continue to exist for several version releases.
[version 0.36]
An optional parameter specifying directories of static data files to be installed as read-only files for use with File::ShareDir. The share_dir
property supports both distribution-level and module-level share files.
The simplest use of share_dir
is to set it to a directory name or an arrayref of directory names containing files to be installed in the distribution-level share directory.
share_dir => 'share'
Alternatively, if share_dir
is a hashref, it may have dist
or module
keys providing full flexibility in defining how share directories should be installed.
share_dir => {
dist => [ 'examples', 'more_examples' ],
module => {
Foo::Templates => ['share/html', 'share/text'],
Foo::Config => 'share/config',
}
}
If share_dir
is set, then File::ShareDir will automatically be added to the requires
hash.
[version 0.16]
If a true value is specified for this parameter, Module::Signature will be used (via the 'distsign' action) to create a SIGNATURE file for your distribution during the 'distdir' action, and to add the SIGNATURE file to the MANIFEST (therefore, don't add it yourself).
The default value is false. In the future, the default may change to true if you have Module::Signature
installed on your system.
[version 0.2808_03]
An optional parameter specifying parameters to be passed to TAP::Harness when running tests. Must be given as a hash reference of parameters; see the TAP::Harness documentation for details. Note that specifying this parameter will implicitly set use_tap_harness
to a true value. You must therefore be sure to add TAP::Harness as a requirement for your module in "build_requires".
[version 0.23]
An optional parameter specifying a set of files that should be used as Test::Harness
-style regression tests to be run during the test
action. May be given as an array reference of the files, or as a hash reference whose keys are the files (and whose values will currently be ignored). If the argument is given as a single string (not in an array reference), that string will be treated as a glob()
pattern specifying the files to use.
The default is to look for a test.pl script in the top-level directory of the distribution, and any files matching the glob pattern *.t
in the t/ subdirectory. If the recursive_test_files
property is true, then the t/
directory will be scanned recursively for *.t
files.
[version 0.2808_03]
An optional parameter indicating whether or not to use TAP::Harness for testing rather than Test::Harness. Defaults to false. If set to true, you must therefore be sure to add TAP::Harness as a requirement for your module in "build_requires". Implicitly set to a true value if tap_harness_args
is specified.
[version 0.19]
Just like pm_files
, but used for specifying the set of .xs
files in your distribution.
[version 0.28]
When called from a directory containing a Build.PL script (in other words, the base directory of a distribution), this method will run the Build.PL and call resume()
to return the resulting Module::Build
object to the caller. Any key-value arguments given to new_from_context()
are essentially like command line arguments given to the Build.PL script, so for example you could pass verbose => 1
to this method to turn on verbosity.
[version 0.03]
You'll probably never call this method directly, it's only called from the auto-generated Build
script (and the new_from_context
method). The new()
method is only called once, when the user runs perl Build.PL
. Thereafter, when the user runs Build test
or another action, the Module::Build
object is created using the resume()
method to re-instantiate with the settings given earlier to new()
.
[version 0.06]
This creates a new Module::Build
subclass on the fly, as described in the "SUBCLASSING" in Module::Build::Authoring section. The caller must provide either a class
or code
parameter, or both. The class
parameter indicates the name to use for the new subclass, and defaults to MyModuleBuilder
. The code
parameter specifies Perl code to use as the body of the subclass.
[version 0.31]
package 'My::Build';
use base 'Module::Build';
__PACKAGE__->add_property( 'pedantic' );
__PACKAGE__->add_property( answer => 42 );
__PACKAGE__->add_property(
'epoch',
default => sub { time },
check => sub {
return 1 if /^\d+$/;
shift->property_error( "'$_' is not an epoch time" );
return 0;
},
);
Adds a property to a Module::Build class. Properties are those attributes of a Module::Build object which can be passed to the constructor and which have accessors to get and set them. All of the core properties, such as module_name
and license
, are defined using this class method.
The first argument to add_property()
is always the name of the property. The second argument can be either a default value for the property, or a list of key/value pairs. The supported keys are:
default
The default value. May optionally be specified as a code reference, in which case the return value from the execution of the code reference will be used. If you need the default to be a code reference, just use a code reference to return it, e.g.:
default => sub { sub { ... } },
check
A code reference that checks that a value specified for the property is valid. During the execution of the code reference, the new value will be included in the $_
variable. If the value is correct, the check
code reference should return true. If the value is not correct, it sends an error message to property_error()
and returns false.
When this method is called, a new property will be installed in the Module::Build class, and an accessor will be built to allow the property to be get or set on the build object.
print $build->pedantic, $/;
$build->pedantic(0);
If the default value is a hash reference, this generates a special-case accessor method, wherein individual key/value pairs may be set or fetched:
print "stuff{foo} is: ", $build->stuff( 'foo' ), $/;
$build->stuff( foo => 'bar' );
print $build->stuff( 'foo' ), $/; # Outputs "bar"
Of course, you can still set the entire hash reference at once, as well:
$build->stuff( { foo => 'bar', baz => 'yo' } );
In either case, if a check
has been specified for the property, it will be applied to the entire hash. So the check code reference should look something like:
check => sub {
return 1 if defined $_ && exists $_->{foo};
shift->property_error(qq{Property "stuff" needs "foo"});
return 0;
},
[version 0.31]
[version 0.26]
Adds a new type of entry to the build process. Accepts a single string specifying its type-name. There must also be a method defined to process things of that type, e.g. if you add a build element called 'foo'
, then you must also define a method called process_foo_files()
.
See also "Adding new file types to the build process" in Module::Build::Cookbook.
[version 0.03]
You may call $self->add_to_cleanup(@patterns)
to tell Module::Build
that certain files should be removed when the user performs the Build clean
action. The arguments to the method are patterns suitable for passing to Perl's glob()
function, specified in either Unix format or the current machine's native format. It's usually convenient to use Unix format when you hard-code the filenames (e.g. in Build.PL) and the native format when the names are programmatically generated (e.g. in a testing script).
I decided to provide a dynamic method of the $build
object, rather than just use a static list of files named in the Build.PL, because these static lists can get difficult to manage. I usually prefer to keep the responsibility for registering temporary files close to the code that creates them.
[version 0.26]
my $args_href = $build->args;
my %args = $build->args;
my $arg_value = $build->args($key);
$build->args($key, $value);
This method is the preferred interface for retrieving the arguments passed via command line options to Build.PL or Build, minus the Module-Build specific options.
When called in a scalar context with no arguments, this method returns a reference to the hash storing all of the arguments; in an array context, it returns the hash itself. When passed a single argument, it returns the value stored in the args hash for that option key. When called with two arguments, the second argument is assigned to the args hash under the key passed as the first argument.
[version 0.28]
Invokes the AutoSplit module on the $from
file, sending the output to the lib/auto
directory inside $to
. $to
is typically the blib/
directory.
[version 0.14]
Returns a string containing the root-level directory of this build, i.e. where the Build.PL
script and the lib
directory can be found. This is usually the same as the current working directory, because the Build
script will chdir()
into this directory as soon as it begins execution.
[version 0.21]
Returns a hash reference indicating the build_requires
prerequisites that were passed to the new()
method.
Returns a reference to the method that defines $action
, or false otherwise. This is handy for actions defined (or maybe not!) in subclasses.
[version 0.32_xx]
[version 0.2809]
Returns the internal ExtUtils::CBuilder object that can be used for compiling & linking C code. If no such object is available (e.g. if the system has no compiler installed) an exception will be thrown.