Alien-Base-ModuleBuild

 view release on metacpan or  search on metacpan

lib/Alien/Base/ModuleBuild.pm  view on Meta::CPAN

    grep { $self->alien_validate_repo($_) }
    @repos;

  unless (@repos) {
    croak "No valid repositories available";
  }

  return @repos;

}

sub alien_validate_repo {
  my $self = shift;
  my ($repo) = @_;
  my $platform = $repo->{platform};

  # return true if platform is undefined
  return 1 unless defined $platform;

  # if $valid is src, check for c compiler
  if ($platform eq 'src') {
    return !$repo->{c_compiler_required} || $self->have_c_compiler;
  }

  # $valid is a string (OS) to match against
  return $self->os_type eq $platform;
}

sub alien_library_destination {
  my $self = shift;

  # send the library into the blib if running under the blib scheme
  my $lib_dir =
    $self->notes('alien_blib_scheme') || $self->alien_stage_install
    ? File::Spec->catdir( $self->base_dir, $self->blib, 'lib' )
    : $self->install_destination($self->alien_arch ? 'arch' : 'lib');

  my $dist_name = $self->dist_name;
  my $dest = _catdir( $lib_dir, qw/auto share dist/, $dist_name );
  return $dest;
}

# CPAN testers often run tests without installing modules, but rather add
# blib dirs to @INC, this is a problem, so here we try to deal with it
sub alien_detect_blib_scheme {
  my $self = shift;

  return 0 if $self->alien_stage_install;
  return $ENV{ALIEN_BLIB} if defined $ENV{ALIEN_BLIB};

  # 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;
  $scg->comment(
    'this script sets the environment needed to build this package.',
    'generated by: ' . __FILE__,
  );
  $scg;
}

sub _filter_defines
{
  join ' ', grep !/^-D/, shellwords($_[0]);
}

sub _alien_bin_require {
  my($self, $mod) = @_;

  my $version = $self->alien_bin_requires->{$mod};

  unless(eval { $mod->can('new') })
  {
    my $pm = "$mod.pm";
    $pm =~ s/::/\//g;
    require $pm;
    $mod->VERSION($version) if $version;
  }

  if($mod->can('alien_helper')) {
    my $helpers = $mod->alien_helper;
    foreach my $k (keys %$helpers) {
      my $v = $helpers->{$k};
      next if defined $self->alien_helper->{$k};
      $self->alien_helper->{$k} = $v;
    }
  }
}

sub alien_do_system {
  my $self = shift;
  my $command = shift;

  local %ENV = %ENV;

  if ($self->config_data( 'msys' )) {
    $self->alien_bin_requires->{'Alien::MSYS'} ||= 0
  }

  my $config;

lib/Alien/Base/ModuleBuild.pm  view on Meta::CPAN

please see L<Alien::Build::Manual::AlienAuthor>.  Although the
Alien-Base / Alien-Build team will continue to maintain this module,
(we will continue to fix bugs where appropriate), we aren't adding any
new features to this module.

This is a subclass of L<Module::Build>, that with L<Alien::Base> allows
for easy creation of Alien distributions.  This module is used during the
build step of your distribution.  When properly configured it will

=over 4

=item use pkg-config to find and use the system version of the library

=item download, build and install the library if the system does not provide it

=back

=head1 METHODS

=head2 alien_check_installed_version

[version 0.001]

 my $version = $abmb->alien_check_installed_version;

This function determines if the library is already installed as part of
the operating system, and returns the version as a string.  If it can't
be detected then it should return empty list.

The default implementation relies on C<pkg-config>, but you will probably
want to override this with your own implementation if the package you are
building does not use C<pkg-config>.

=head2 alien_check_built_version

[version 0.006]

 my $version = $amb->alien_check_built_version;

This function determines the version of the library after it has been
built from source.  This function only gets called if the operating
system version can not be found and the package is successfully built.
The version is returned on success.  If the version can't be detected
then it should return empty list.  Note that failing to detect a version
is considered a failure and the corresponding C<./Build> action will
fail!

Any string is valid as a version as far as L<Alien::Base> is concerned.
The most useful value would be a number or dotted decimal that most
software developers recognize and that software tools can differentiate.
In some cases packages will not have a clear version number, in which
case the string C<unknown> would be a reasonable choice.

The default implementation relies on C<pkg-config>, and other heuristics,
but you will probably want to override this with your own implementation
if the package you are building does not use C<pkg-config>.

When this method is called, the current working directory will be the
build root.

If you see an error message like this:

 Library looks like it installed, but no version was determined

After the package is built from source code then you probably need to
provide an implementation for this method.

=head2 alien_extract_archive

[version 0.024]

  my $dir = $amb->alien_extract_archive($filename);

This function unpacks the given archive and returns the directory
containing the unpacked files.

The default implementation relies on L<Archive::Extract> that is able
to handle most common formats. In order to handle other formats or
archives requiring some special treatment you may want to override
this method.

=head2 alien_do_system

[version 0.024]

  my %result = $amb->alien_do_system($cmd)

Similar to
L<Module::Build's do_system|Module::Build::API/"do_system($cmd, @args)">,
also sets the path and several environment variables in accordance
to the object configuration (i.e. C<alien_bin_requires>) and
performs the interpolation of the patterns described in
L<Alien::Base::ModuleBuild::API/"COMMAND INTERPOLATION">.

Returns a set of key value pairs including C<stdout>, C<stderr>,
C<success> and C<command>.

=head2 alien_do_commands

 $amb->alien_do_commands($phase);

Executes the commands for the given phase.

=head2 alien_interpolate

 my $string = $amb->alien_interpolate($string);

Takes the input string and interpolates the results.

=head2 alien_install_network

[version 1.16]

 my $bool = $amb->alien_install_network;

Returns true if downloading source from the internet is allowed.  This
is true unless C<ALIEN_INSTALL_NETWORK> is defined and false.

=head2 alien_download_rule

[version 1.16]



( run in 0.947 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )