Clownfish
view release on metacpan or search on metacpan
buildlib/Clownfish/Build.pm view on Meta::CPAN
if ($Config{cc} =~ /^cl\b/) {
my $extra_cflags = $self->extra_compiler_flags;
push @$extra_cflags, '/TP';
$self->extra_compiler_flags(@$extra_cflags);
}
$self->charmonizer_params( create_makefile => 1 );
$self->charmonizer_params( charmonizer_c => $CHARMONIZER_C );
return $self;
}
sub _run_make {
my ( $self, %params ) = @_;
my @command = @{ $params{args} };
my $dir = $params{dir};
my $current_directory = getcwd();
chdir $dir if $dir;
unshift @command, 'CC=' . $self->config('cc');
if ( $self->config('cc') =~ /^cl\b/ ) {
unshift @command, "-f", "Makefile.MSVC";
}
elsif ( $^O =~ /mswin/i ) {
unshift @command, "-f", "Makefile.MinGW";
}
unshift @command, "$Config{make}";
system(@command) and confess("$Config{make} failed");
chdir $current_directory if $dir;
}
sub ACTION_cfc {
my $self = shift;
return if $IS_CPAN_DIST;
my $old_dir = getcwd();
chdir($CFC_DIR);
if ( !-f 'Build' ) {
print "\nBuilding Clownfish compiler... \n";
system("$^X Build.PL");
system("$^X Build code");
print "\nFinished building Clownfish compiler.\n\n";
}
chdir($old_dir);
}
sub ACTION_code {
my $self = shift;
$self->SUPER::ACTION_code;
$self->cf_copy_include_file( 'XSBind.h' );
# Check whether 'use Clownfish::Test' succeeds. If this fails, it is
# probably caused by a failure to find symbols from Clownfish.so,
# indicating a build problem. In this case, make the build fail, so
# we get the full build log on CPAN Testers. Also print contents of
# the generated Makefile.
my $error = system("$^X -Mblib -MClownfish::Test -e1");
if ($error) {
print STDERR "Build succeeded, but 'use Clownfish::Test' failed.\n";
if ($ENV{AUTOMATED_TESTING}) {
my $makefile = do { local(@ARGV, $/) = 'Makefile'; <> };
print STDERR "\nContents of Makefile:\n$makefile";
}
die;
}
}
sub ACTION_clownfish {
my $self = shift;
$self->depends_on('cfc');
$self->SUPER::ACTION_clownfish;
# Make sure to remove empty directory.
$self->add_to_cleanup( catdir( $LIB_DIR, 'Clownfish', 'Docs' ) );
}
sub ACTION_compile_custom_xs {
my $self = shift;
$self->depends_on('charmony');
# Add extra compiler flags from Charmonizer.
my $charm_cflags = $self->charmony('EXTRA_CFLAGS');
if ($charm_cflags) {
my $cf_cflags = $self->clownfish_params('cflags');
if ($cf_cflags) {
$cf_cflags .= " $charm_cflags";
}
else {
$cf_cflags = $charm_cflags;
}
$self->clownfish_params( cflags => $cf_cflags );
}
# Add extra linker flags from Charmonizer.
my $charm_ldflags = $self->charmony('EXTRA_LDFLAGS');
if ($charm_ldflags) {
my $extra_ldflags = $self->extra_linker_flags;
push @$extra_ldflags, $self->split_like_shell($charm_ldflags);
$self->extra_linker_flags(@$extra_ldflags);
}
$self->SUPER::ACTION_compile_custom_xs;
}
sub _valgrind_base_command {
return
"PERL_DESTRUCT_LEVEL=2 CLOWNFISH_VALGRIND=1 valgrind "
. "--leak-check=yes "
. "--show-reachable=yes "
. "--dsymutil=yes "
. "--suppressions=../../devel/conf/cfruntime-perl.supp ";
}
# Run the entire test suite under Valgrind.
#
# For this to work, the test suite must be run under a debugging Perl.
#
# A custom suppressions file will probably be needed -- use your judgment.
( run in 2.685 seconds using v1.01-cache-2.11-cpan-364913b4093 )