Alien-CMake

 view release on metacpan or  search on metacpan

inc/My/Builder.pm  view on Meta::CPAN

    $self->config_data('build_arch', $Config{archname});
    $self->config_data('build_os', $^O);
    $self->config_data('script', '');            # just to be sure
    $self->config_data('config', {});            # just to be sure

    if($bp->{buildtype} eq 'use_already_existing') {
      $self->config_data('script', $bp->{script});
      $self->set_config_data($bp->{prefix});
    }
    elsif($bp->{buildtype} eq 'use_prebuilt_binaries') {
      # all the following functions die on error, no need to test ret values
      $self->fetch_binaries($download);
      $self->clean_dir($build_out);
      $self->extract_binaries($download, $build_out, $build_src);
      $self->set_config_data($build_out);
    }
    elsif($bp->{buildtype} eq 'build_from_sources' ) {
      # all the following functions die on error, no need to test ret values
      $self->fetch_sources($download);
      $self->extract_sources($download, $patches, $build_src);
      $self->clean_dir($build_out);
      $self->build_binaries($build_out, $build_src);
      $self->set_config_data($build_out);
    }

    # mark sucessfully finished build
    $self->touch_build_done_marker;
  }

inc/My/Builder.pm  view on Meta::CPAN

}

sub extract_binaries {
  my ($self, $download, $build_out, $build_src) = @_;

  # do extract binaries
  my $bp = $self->notes('build_params');
  my $archive = catfile($download, File::Fetch->new(uri => $bp->{url})->file);
  print "Extracting $archive...\n";
  my $ae = Archive::Extract->new( archive => $archive );
  die "###ERROR###: Cannot extract $archive ", $ae->error unless $ae->extract(to => $build_src);

  my ($prefix, $bindir, $sharedir) = find_CMake_dir(rel2abs($build_src));
  dircopy($bindir,   catdir($build_out, 'bin'));
  dircopy($sharedir, catdir($build_out, 'share'));
}

sub extract_sources {
  my ($self, $download, $patches, $build_src) = @_;
  my $bp = $self->notes('build_params');

  my $srcdir = catfile($build_src, $bp->{dirname});
  my $unpack = 'y';
  $unpack = $self->prompt("Dir '$srcdir' exists, wanna replace with clean sources?", "n") if (-d $srcdir);
  if (lc($unpack) eq 'y') {
    $self->clean_dir($srcdir);
    my $archive = catfile($download, File::Fetch->new(uri => $bp->{url})->file);
    print "Extracting sources...\n";
    my $ae = Archive::Extract->new( archive => $archive );
    die "###ERROR###: cannot extract $bp ", $ae->error unless $ae->extract(to => $build_src);
    foreach my $i (@{$bp->{patches}}) {
      chdir $srcdir;
      print "Applying patch '$i'\n";
      my $cmd = $self->patch_command($srcdir, catfile($patches, $i));
      if ($cmd) {
        print "(cmd: $cmd)\n";
        $self->do_system($cmd) or die "###ERROR### [$?] during patch ... ";
      }
      chdir $self->base_dir();
    }



( run in 0.579 second using v1.01-cache-2.11-cpan-65fba6d93b7 )