Alien-CMake
view release on metacpan or search on metacpan
inc/My/Builder.pm view on Meta::CPAN
my $cfg = {
# defaults (used on MS Windows build)
version => $self->notes('build_cmake_version'),
prefix => '@PrEfIx@',
bin => $self->get_path('@PrEfIx@/bin'),
share => $self->get_path('@PrEfIx@/share'),
};
if($self->config_data('build_params')->{version}) {
$cfg->{version} = $self->config_data('build_params')->{version};
}
# write config
$self->config_data('config', $cfg);
}
sub build_binaries {
# this needs to be overriden in My::Builder::<platform>
my ($self, $build_out, $build_src) = @_;
die "###ERROR### My::Builder cannot build CMake from sources, use rather My::Builder::<platform>";
}
sub get_path {
# this needs to be overriden in My::Builder::<platform>
my ( $self, $path ) = @_;
return $path;
}
sub clean_dir {
my( $self, $dir ) = @_;
if (-d $dir) {
remove_tree($dir);
make_path($dir);
}
}
sub check_build_done_marker {
my $self = shift;
return (-e 'build_done');
}
sub touch_build_done_marker {
my $self = shift;
require ExtUtils::Command;
local @ARGV = ('build_done');
ExtUtils::Command::touch();
$self->add_to_cleanup('build_done');
}
sub clean_build_done_marker {
my $self = shift;
unlink 'build_done' if (-e 'build_done');
}
sub check_sha1sum {
my( $self, $file, $sha1sum ) = @_;
my $alg = length $sha1sum == 64 ? 'SHA-256' : 'SHA-1';
my $sha1 = Digest::SHA->new($alg);
my $fh;
open($fh, $file) or die "###ERROR## Cannot check checksum for '$file'\n";
binmode($fh);
$sha1->addfile($fh);
close($fh);
return ($sha1->hexdigest eq $sha1sum) ? 1 : 0
}
sub patch_command {
my( $self, $base_dir, $patch_file ) = @_;
print("patch_command: $base_dir, $patch_file\n");
my $devnull = File::Spec->devnull();
my $patch_rv = system("patch -v > $devnull 2>&1");
if ($patch_rv == 0) {
$patch_file = File::Spec->abs2rel( $patch_file, $base_dir );
# the patches are expected with UNIX newlines
# the following command works on both UNIX+Windows
return qq("$^X" -pe0 -- "$patch_file" | patch -p1); # paths of files to patch should be relative to build_src
}
warn "###WARN### patch not available";
return '';
}
1;
( run in 0.716 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )