Alien-Base-ModuleBuild
view release on metacpan or search on metacpan
lib/Alien/Base/ModuleBuild.pm view on Meta::CPAN
my $version = $self->config_data( 'alien_version' );
if ( ! defined( $version ) ) {
carp "Version substution requested but unable to identify";
} else {
$string =~ s/(?<!\%)\%v/$version/g;
}
}
$string =~ s/(?<!\%)\%\{([a-zA-Z_][a-zA-Z_0-9]+)\}/$self->_alien_execute_helper($1)/eg;
#remove escapes (%%)
$string =~ s/\%(?=\%)//g;
return $string;
}
sub alien_exec_prefix {
my $self = shift;
if ( $self->is_windowsish ) {
return '';
} else {
lib/Alien/Base/ModuleBuild/API.pod view on Meta::CPAN
[version 0.009]
Each command may be either a string or an array reference. If the array reference form is used then the multiple argument form of C<system> is used. Prior to version 0.009, only the string form was supported.
=item alien_env
[version 0.027]
Environment overrides. Allows you to set environment variables as a hash
reference that will override environment variables. You can use the same
interpolated escape sequences and helpers that commands use. Set to undef
to remove the variable.
...
Alien::Base::ModuleBuild->new(
...
alien_env => {
PERL => '%X', # sets the environment variable PERL to the location
# of the Perl interpreter.
PERCENT => '%%', # evaluates to '%'
REMOVE => undef, # remove the environment variable if it is defined
lib/Alien/Base/ModuleBuild/API.pod view on Meta::CPAN
The version number installed or available.
=item working_directory
Holder for the full path to the extracted source of the library. This is used to munge the pkg-config data later on.
=back
=head2 COMMAND INTERPOLATION
Before L<Alien::Base::ModuleBuild> executes system commands, it replaces a few special escape sequences with useful data. This is needed especially for referencing the full path to the C<alien_share_dir> before this path is known. The available seque...
=over
=item %{I<helper>}
[version 0.020]
Call the given helper, either provided by the C<alien_helper> or C<alien_bin_requires> property. See L<Alien::Base#alien_helper>.
=item %c
lib/Alien/Base/ModuleBuild/FAQ.pod view on Meta::CPAN
is not provided.
A more powerful approach to patching is to write a perl subroutine to modify the source after it has been
extracted. One way to do this is to create a module in your distribution's inc directory that does the
patching (modules in inc can be used during build/test but won't be installed):
# inc/My/AlienPatch.pm
package My::AlienPatch;
# add this sub to the main namespace
# so we don't need to quote or escape
# anything below
sub main::alien_patch {
# is executed in the package root,
# make what ever changes you need to
# to the source here.
}
1;
# Build.PL
t/alien_base_modulebuild.t view on Meta::CPAN
skip_all "Needs c compiler" unless $builder->have_c_compiler();
ok( $builder->alien_validate_repo( {platform => 'src'} ), "platform src");
};
};
subtest 'basic interpolation' => sub {
my $builder = builder();
is( $builder->alien_interpolate('%phello'), $builder->alien_exec_prefix . 'hello', 'prefix interpolation');
is( $builder->alien_interpolate('%%phello'), '%phello', 'no prefix interpolation with escape');
my $path = $builder->alien_library_destination;
is( $builder->alien_interpolate('thing other=%s'), "thing other=$path", 'share_dir interpolation');
is( $builder->alien_interpolate('thing other=%%s'), 'thing other=%s', 'no share_dir interpolation with escape');
my $perl = $builder->perl;
is( $builder->alien_interpolate('%x'), $perl, '%x is current interpreter' );
unlike( $builder->alien_interpolate('%X'), qr{\\}, 'no backslash in %X' );
};
subtest 'interpolation of version' => sub {
my $builder = builder();
( run in 0.351 second using v1.01-cache-2.11-cpan-c21f80fb71c )