Acme-Sort-Sleep
view release on metacpan or search on metacpan
local/lib/perl5/Module/Build/API.pod view on Meta::CPAN
For a distribution where a compiler is I<optional>, e.g. a dual XS/pure-Perl
distribution, C<needs_compiler> should explicitly be set to a false value.
=item PL_files
[version 0.06]
An optional parameter specifying a set of C<.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
C<lib/Foo/Bar.pm.PL> might create the file C<lib/Foo/Bar.pm>.
The files are specified with the C<.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 I<always> given in Unix-like
format, not in the style of the local system.
If your C<.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
F<lib/> and F<bin/>.
=item pm_files
[version 0.19]
An optional parameter specifying the set of C<.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 C<MakeMaker> distribution for a
module called C<Foo::Bar> and a F<Bar.pm> file at the top level of the
distribution, you could specify your layout in your C<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 C<lib/>, because this is where
they would be found in a "normal" Module::Build-style distribution.
Note also that the path specifications are I<always> given in
Unix-like format, not in the style of the local system.
=item pod_files
[version 0.19]
Just like C<pm_files>, but used for specifying the set of C<.pod>
files in your distribution.
=item recommends
[version 0.08]
This is just like the L</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 L<Module::Build::Authoring/"PREREQUISITES">
for the details of how requirements can be specified.
=item recursive_test_files
[version 0.28]
Normally, C<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.
=item release_status
[version 0.37]
local/lib/perl5/Module/Build/API.pod view on Meta::CPAN
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.
=item check_installed_status($module, $version)
[version 0.11]
This method returns a hash reference indicating whether a version
dependency on a certain module is satisfied. The C<$module> argument
is given as a string like C<"Data::Dumper"> or C<"perl">, and the
C<$version> argument can take any of the forms described in L</requires>
above. This allows very fine-grained version checking.
The returned hash reference has the following structure:
{
ok => $whether_the_dependency_is_satisfied,
have => $version_already_installed,
need => $version_requested, # Same as incoming $version argument
message => $informative_error_message,
}
If no version of C<$module> is currently installed, the C<have> value
will be the string C<< "<none>" >>. Otherwise the C<have> value will
simply be the version of the installed module. Note that this means
that if C<$module> is installed but doesn't define a version number,
the C<have> value will be C<undef> - this is why we don't use C<undef>
for the case when C<$module> isn't installed at all.
This method may be called either as an object method
(C<< $build->check_installed_status($module, $version) >>)
or as a class method
(C<< Module::Build->check_installed_status($module, $version) >>).
=item check_installed_version($module, $version)
[version 0.05]
Like L<check_installed_status()|/"check_installed_status($module, $version)">,
but simply returns true or false depending on whether module
C<$module> satisfies the dependency C<$version>.
If the check succeeds, the return value is the actual version of
C<$module> installed on the system. This allows you to do the
following:
my $installed = $build->check_installed_version('DBI', '1.15');
if ($installed) {
print "Congratulations, version $installed of DBI is installed.\n";
} else {
die "Sorry, you must install DBI.\n";
}
If the check fails, we return false and set C<$@> to an informative
error message.
If C<$version> is any non-true value (notably zero) and any version of
C<$module> is installed, we return true. In this case, if C<$module>
doesn't define a version, or if its version is zero, we return the
special value "0 but true", which is numerically zero, but logically
true.
In general you might prefer to use C<check_installed_status> if you
need detailed information, or this method if you just need a yes/no
answer.
=item compare_versions($v1, $op, $v2)
[version 0.28]
Compares two module versions C<$v1> and C<$v2> using the operator
C<$op>, which should be one of Perl's numeric operators like C<!=> or
C<< >= >> or the like. We do at least a halfway-decent job of
handling versions that aren't strictly numeric, like C<0.27_02>, but
exotic stuff will likely cause problems.
In the future, the guts of this method might be replaced with a call
out to C<version.pm>.
=item config($key)
=item config($key, $value)
=item config() [deprecated]
[version 0.22]
With a single argument C<$key>, returns the value associated with that
key in the C<Config.pm> hash, including any changes the author or user
has specified.
With C<$key> and C<$value> arguments, sets the value for future
callers of C<config($key)>.
With no arguments, returns a hash reference containing all such
key-value pairs. This usage is deprecated, though, because it's a
resource hog and violates encapsulation.
=item config_data($name)
=item config_data($name => $value)
[version 0.26]
With a single argument, returns the value of the configuration
variable C<$name>. With two arguments, sets the given configuration
variable to the given value. The value may be any Perl scalar that's
serializable with C<Data::Dumper>. For instance, if you write a
module that can use a MySQL or PostgreSQL back-end, you might create
configuration variables called C<mysql_connect> and
C<postgres_connect>, and set each to an array of connection parameters
for C<< DBI->connect() >>.
Configuration values set in this way using the Module::Build object
will be available for querying during the build/test process and after
installation via the generated C<...::ConfigData> module, as
C<< ...::ConfigData->config($name) >>.
The L<feature()|/"feature($name)"> and C<config_data()> methods represent
Module::Build's main support for configuration of installed modules.
See also L<Module::Build::Authoring/"SAVING CONFIGURATION INFORMATION">.
=item conflicts()
[version 0.21]
Returns a hash reference indicating the C<conflicts> prerequisites
that were passed to the C<new()> method.
=item contains_pod($file) [deprecated]
[version 0.20]
[Deprecated] Please see L<Module::Metadata> instead.
Returns true if the given file appears to contain POD documentation.
Currently this checks whether the file has a line beginning with
'=pod', '=head', or '=item', but the exact semantics may change in the
future.
=item copy_if_modified(%parameters)
[version 0.19]
Takes the file in the C<from> parameter and copies it to the file in
the C<to> parameter, or the directory in the C<to_dir> parameter, if
the file has changed since it was last copied (or if it doesn't exist
in the new location). By default the entire directory structure of
C<from> will be copied into C<to_dir>; an optional C<flatten>
parameter will copy into C<to_dir> without doing so.
Returns the path to the destination file, or C<undef> if nothing
needed to be copied.
Any directories that need to be created in order to perform the
copying will be automatically created.
The destination file is set to read-only. If the source file has the
executable bit set, then the destination file will be made executable.
=item create_build_script()
[version 0.05]
Creates an executable script called C<Build> in the current directory
that will be used to execute further user actions. This script is
roughly analogous (in function, not in form) to the Makefile created
by C<ExtUtils::MakeMaker>. This method also creates some temporary
data in a directory called C<_build/>. Both of these will be removed
when the C<realclean> action is performed.
Among the files created in C<_build/> is a F<_build/prereqs> file
containing the set of prerequisites for this distribution, as a hash
of hashes. This file may be C<eval()>-ed to obtain the authoritative
set of prerequisites, which might be different from the contents of
F<META.yml> (because F<Build.PL> might have set them dynamically).
But fancy developers take heed: do not put any fancy custom runtime
code in the F<_build/prereqs> file, leave it as a static declaration
containing only strings and numbers. Similarly, do not alter the
structure of the internal C<< $self->{properties}{requires} >> (etc.)
data members, because that's where this data comes from.
=item current_action()
[version 0.28]
Returns the name of the currently-running action, such as "build" or
"test". This action is not necessarily the action that was originally
invoked by the user. For example, if the user invoked the "test"
action, current_action() would initially return "test". However,
action "test" depends on action "code", so current_action() will
return "code" while that dependency is being executed. Once that
action has completed, current_action() will again return "test".
If you need to know the name of the original action invoked by the
user, see L</invoked_action()> below.
=item depends_on(@actions)
[version 0.28]
Invokes the named action or list of actions in sequence. Using this
method is preferred to calling the action explicitly because it
performs some internal record-keeping, and it ensures that the same
action is not invoked multiple times (note: in future versions of
Module::Build it's conceivable that this run-only-once mechanism will
be changed to something more intelligent).
Note that the name of this method is something of a misnomer; it
should really be called something like
C<invoke_actions_unless_already_invoked()> or something, but for
better or worse (perhaps better!) we were still thinking in
C<make>-like dependency terms when we created this method.
See also L<dispatch()|/"dispatch($action, %args)">. The main
distinction between the two is that C<depends_on()> is meant to call
an action from inside another action, whereas C<dispatch()> is meant
to set the very top action in motion.
=item dir_contains($first_dir, $second_dir)
[version 0.28]
Returns true if the first directory logically contains the second
directory. This is just a convenience function because C<File::Spec>
doesn't really provide an easy way to figure this out (but
C<Path::Class> does...).
=item dispatch($action, %args)
[version 0.03]
Invokes the build action C<$action>. Optionally, a list of options
and their values can be passed in. This is equivalent to invoking an
action at the command line, passing in a list of options.
Custom options that have not been registered must be passed in as a
hash reference in a key named "args":
$build->dispatch('foo', verbose => 1, args => { my_option => 'value' });
This method is intended to be used to programmatically invoke build
actions, e.g. by applications controlling Module::Build-based builds
rather than by subclasses.
See also L<depends_on()|/"depends_on(@actions)">. The main
distinction between the two is that C<depends_on()> is meant to call
an action from inside another action, whereas C<dispatch()> is meant
to set the very top action in motion.
=item dist_dir()
[version 0.28]
Returns the name of the directory that will be created during the
C<dist> action. The name is derived from the C<dist_name> and
C<dist_version> properties.
=item dist_name()
[version 0.21]
Returns the name of the current distribution, as passed to the
C<new()> method in a C<dist_name> or modified C<module_name>
parameter.
=item dist_version()
[version 0.21]
Returns the version of the current distribution, as determined by the
C<new()> method from a C<dist_version>, C<dist_version_from>, or
C<module_name> parameter.
=item do_system($cmd, @args)
[version 0.21]
This is a fairly simple wrapper around Perl's C<system()> built-in
command. Given a command and an array of optional arguments, this
method will print the command to C<STDOUT>, and then execute it using
Perl's C<system()>. It returns true or false to indicate success or
failure (the opposite of how C<system()> works, but more intuitive).
( run in 0.530 second using v1.01-cache-2.11-cpan-39bf76dae61 )