Alien-Base-ModuleBuild
view release on metacpan or search on metacpan
% perl Build
% perl Build test
% perl Build install
If your perl is system-managed, you can create a local::lib in your home
directory to install modules to. For details, see the local::lib documentation:
https://metacpan.org/pod/local::lib
The prerequisites of this distribution will also have to be installed manually. The
prerequisites are listed in one of the files: `MYMETA.yml` or `MYMETA.json` generated
by running the manual build process described above.
## Configure Prerequisites
This distribution requires other modules to be installed before this
distribution's installer can be run. They can be found under the
"configure_requires" key of META.yml or the
"{prereqs}{configure}{requires}" key of META.json.
## Other Prerequisites
Alien-Specific Usage (Alien::Base::ModuleBuild)
This is the document you are currently reading.
Authoring Reference (Alien::Base::Authoring)
This document describes the structure and organization of Alien::Base
based projects, beyond that contained in Module::Build::Authoring,
and the relevant concepts needed by authors who are writing Build.PL
scripts for a distribution or controlling Alien::Base::ModuleBuild
processes programmatically.
Note that as it contains information both for the build and use
phases of Alien::Base projects, it is located in the upper namespace.
API Reference (Alien::Base::ModuleBuild::API)
This is a reference to the Alien::Base::ModuleBuild API beyond that
contained in Module::Build::API.
Using the resulting Alien (Alien::Build::Manual::AlienUser)
# for either Class or method.
private:
- Alien::Base::ModuleBuild::Cabinet
- Alien::Base::ModuleBuild::File
- Alien::Base::ModuleBuild::Repository.*
- Alien::Base::ModuleBuild::Utils
# these are just overriden methods
- Alien::Base::ModuleBuild#new
- Alien::Base::ModuleBuild#do_system
- Alien::Base::ModuleBuild#process_share_dir_files
# these are just private methods that probably should have had a prefix
- Alien::Base::ModuleBuild#alien_validate_repo
- Alien::Base::ModuleBuild#alien_configure
- Alien::Base::ModuleBuild#alien_create_repositories
- Alien::Base::ModuleBuild#alien_detect_blib_scheme
- Alien::Base::ModuleBuild#alien_exec_prefix
- Alien::Base::ModuleBuild#alien_find_lib_paths
- Alien::Base::ModuleBuild#alien_generate_manual_pkgconfig
- Alien::Base::ModuleBuild#alien_init_temp_dir
lib/Alien/Base/ModuleBuild.pm view on Meta::CPAN
my $arch_dir = File::Spec->catdir($self->blib, 'arch', 'auto', @parts);
File::Path::mkpath($arch_dir, 0, oct(777)) unless -d $arch_dir;
open my $fh, '>', File::Spec->catfile($arch_dir, $parts[-1].".txt");
print $fh "Alien based distribution with architecture specific file in share\n";
close $fh;
}
$self->depends_on('alien_install') if $self->alien_stage_install;
}
sub process_share_dir_files {
my $self = shift;
$self->SUPER::process_share_dir_files(@_);
# copy the compiled files into blib if running under blib scheme
$self->depends_on('alien_install') if $self->notes('alien_blib_scheme') || $self->alien_stage_install;
}
sub alien_extract_archive {
my ($self, $archive) = @_;
print "Extracting Archive ... ";
my $ae = Archive::Extract->new( archive => $archive );
$ae->extract or croak "Archive extraction failed!";
lib/Alien/Base/ModuleBuild.pm view on Meta::CPAN
print "Done\n";
}
# refresh metadata after library installation
$self->alien_refresh_manual_pkgconfig( $self->alien_library_destination );
$self->config_data( 'finished_installing' => 1 );
if ( $self->notes( 'alien_blib_scheme') || $self->alien_stage_install) {
### TODO: empty if should be claned up before 0.017.
### we used to call process_files_by_extension('pm')
### here, but with gh#121 it is unecessary
## reinstall config_data to blib
#$self->process_files_by_extension('pm');
} else {
# to refresh config_data
$self->SUPER::ACTION_config_data;
# reinstall config_data
$self->SUPER::ACTION_install;
# refresh the packlist
lib/Alien/Base/ModuleBuild.pm view on Meta::CPAN
# check to see if Alien::Base::ModuleBuild is running from blib.
# if so it is likely that this is the blib scheme
(undef, my $dir, undef) = File::Spec->splitpath( __FILE__ );
my @dirs = File::Spec->splitdir($dir);
shift @dirs while @dirs && $dirs[0] ne 'blib';
return unless @dirs;
if ( $dirs[1] && $dirs[1] eq 'lib' ) {
print qq{'blib' scheme is detected. Setting ALIEN_BLIB=1. If this has been done in error, please set ALIEN_BLIB and restart build process to disambiguate.\n};
return 1;
}
carp q{'blib' scheme is suspected, but uncertain. Please set ALIEN_BLIB and restart build process to disambiguate. Setting ALIEN_BLIB=1 for now.};
return 1;
}
###################
# Build Methods #
###################
sub _shell_config_generate
{
my $scg = Shell::Config::Generate->new;
lib/Alien/Base/ModuleBuild.pm view on Meta::CPAN
}
# wrapper for M::B::do_system which interpolates alien_ vars first
# futher it either captures or tees depending on the value of $Verbose
sub do_system {
my $self = shift;
my $opts = ref $_[-1] ? pop : { verbose => 1 };
my $verbose = $Verbose || $opts->{verbose};
# prevent build process from cwd-ing from underneath us
local $CWD;
my $initial_cwd = $CWD;
my @args = map { $self->alien_interpolate($_) } @_;
print "+ @args\n";
my $old_super_verbose = $self->verbose;
$self->verbose(0);
my ($out, $err, $success) =
lib/Alien/Base/ModuleBuild.pm view on Meta::CPAN
=item Alien-Specific Usage (L<Alien::Base::ModuleBuild>)
This is the document you are currently reading.
=item Authoring Reference (L<Alien::Base::Authoring>)
This document describes the structure and organization of
C<Alien::Base> based projects, beyond that contained in
C<Module::Build::Authoring>, and the relevant concepts needed by authors who are
writing F<Build.PL> scripts for a distribution or controlling
C<Alien::Base::ModuleBuild> processes programmatically.
Note that as it contains information both for the build and use phases of
L<Alien::Base> projects, it is located in the upper namespace.
=item API Reference (L<Alien::Base::ModuleBuild::API>)
This is a reference to the C<Alien::Base::ModuleBuild> API beyond that contained
in C<Module::Build::API>.
=item Using the resulting L<Alien> (L<Alien::Build::Manual::AlienUser>)
lib/Alien/Base/ModuleBuild/FAQ.pod view on Meta::CPAN
(we will continue to fix bugs where appropriate), we aren't adding any
new features to this module.
This document serves to answer the most frequently asked questions made by L<Alien::Base> authors.
=head2 What is Alien and Alien::Base?
Alien is a Perl namespace for defining dependencies in CPAN for libraries and tools which are not "native"
to CPAN. For a manifesto style description of the Why, and How see L<Alien>. L<Alien::Base> is a base
class and framework for creating Alien distributions. The idea is to address as many of the common challenges
to developing Alien modules in the base class to simplify the process.
=head2 How do I specify a minimum or exact version requirement for packages that use pkg-config?
The C<alien_version_check> attribute to L<Alien::Base::ModuleBuild> will be executed to determine if
the library is provided by the operating system. The default for this is C<%{pkg_config} --modversion %n>
which simply checks to see if any version of that package is available, and prints the version
number. You can use the C<--atleast-version>, C<--exact-version> options to require a specific range of versions,
but these flags do not work with the C<--modversion> flag, so be sure to invoke separately.
use Alien::Base::ModuleBuild;
lib/Alien/Base/ModuleBuild/FAQ.pod view on Meta::CPAN
=head2 When debugging my package build, I get different results!
If you get results from running the commands in your shell different to what happens when your C<Alien::>
distribution attempts to build, it may be because your environment is different than the one that your
distribution is using. For example, if you use L<Alien::CMake> or L<Alien::gmake> to build with specific tools
that are provided by your operating system, L<Alien::Base::ModuleBuild> will adjust the path before executing
build and install commands.
In the alien build directory (usually C<_alien>) you will find environment files that you can source
into your shell (C<env.csh> for tcsh and C<env.sh> for bourne based shells), which should provide the
identical environment used by the build process in order to troubleshoot the build manually.
% source _alien/env.sh
=head2 Can/Should I write a tool oriented Alien module using C<Alien::Base> that provides executables instead of a library?
Certainly. The original intent was to provide libraries, but tools are also quite doable using the
C<Alien::Base> tool set. A simple minded example of this which is fairly easy to replicate is L<Alien::m4>.
In general, this means specifying a subclass in your C<Build.PL> and bundling it in your distribution C<inc> directory.
t/alien_base_modulebuild.t view on Meta::CPAN
alien_env => {
FOO => 'foo1',
BAR => '%{myhelper}',
BAZ => undef,
},
alien_build_commands => [],
);
isa_ok $builder, 'Alien::Base::ModuleBuild';
my($out, $err, %status) = capture { $builder->alien_do_system([$^X, -e => 'print $ENV{FOO}']) };
is $status{stdout}, 'foo1', 'env FOO passed to process';
($out, $err, %status) = capture { $builder->alien_do_system([$^X, -e => 'print $ENV{BAR}']) };
is $status{stdout}, 'my helper text', 'alien_env works with helpers';
($out, $err, %status) = capture { $builder->alien_do_system([$^X, -e => 'print $ENV{BAZ}||"undef"']) };
is $status{stdout}, 'undef', 'alien_env works with helpers';
};
subtest 'cmake' => sub {
subtest 'default' => sub {
( run in 0.382 second using v1.01-cache-2.11-cpan-8d75d55dd25 )