Alien-CMake
view release on metacpan or search on metacpan
inc/My/Utility.pm view on Meta::CPAN
($Config{archname} =~ $b->{arch_re}) ) {
$b->{buildtype} = 'use_prebuilt_binaries';
push @good, $b;
}
}
#returning ARRAY of HASHREFs (sometimes more than one value)
return \@good;
}
sub check_src_build
{
print "Gonna check possibility for building from sources ...\n";
print "(os=$^O cc=$Config{cc})\n";
foreach my $p (@{$source_packs}) {
$p->{buildtype} = 'build_from_sources';
}
return $source_packs;
}
sub find_file {
my ($dir, $re) = @_;
my @files;
$re ||= qr/.*/;
find({ wanted => sub { push @files, rel2abs($_) if /$re/ }, follow => 1, no_chdir => 1 , follow_skip => 2}, $dir);
return @files;
}
sub find_CMake_dir {
my $root = shift;
my ($prefix, $incdir, $libdir);
return unless $root;
# try to find
my ($found) = find_file($root, qr/[\\\/]bin[\\\/]cmake(\.exe)?$/i ); # take just the first one
return unless $found;
# get prefix dir
my ($v, $d, $f) = splitpath($found);
my @pp = reverse splitdir($d);
shift(@pp) if(defined($pp[0]) && $pp[0] eq '');
if(defined($pp[0]) && $pp[0] eq 'bin') {
shift(@pp);
@pp = reverse @pp;
return (
catpath($v, catdir(@pp), ''),
catpath($v, catdir(@pp, 'bin'), ''),
catpath($v, catdir(@pp, 'share'), ''),
);
}
}
sub sed_inplace {
# we expect to be called like this:
# sed_inplace("filename.txt", 's/0x([0-9]*)/n=$1/g');
my ($file, $re) = @_;
if (-e $file) {
cp($file, "$file.bak") or die "###ERROR### cp: $!";
open INPF, "<", "$file.bak" or die "###ERROR### open<: $!";
open OUTF, ">", $file or die "###ERROR### open>: $!";
binmode OUTF; # we do not want Windows newlines
while (<INPF>) {
eval( "$re" );
print OUTF $_;
}
close INPF;
close OUTF;
}
}
1;
( run in 0.448 second using v1.01-cache-2.11-cpan-787462296c9 )