Alien-SWIProlog
view release on metacpan or search on metacpan
my $prop = Alien::SWIProlog::Util::plvars_to_props($PL_path, $PLVARS);
eval {
require ExtUtils::CBuilder;
my $b = ExtUtils::CBuilder->new();
my $src = Path::Tiny->tempfile( SUFFIX => '.c' );
$src->spew_utf8($test_program);
$build->log('Compiling/linking test program');
my $obj = $b->compile(
source => "$src",
extra_compiler_flags => $prop->{cflags},
);
my $exe = $b->link_executable(
objects => $obj,
extra_linker_flags => $prop->{libs},
);
$build->log('Compiling/linking successful');
1;
} and return 'system';
$build->log('Compiling/linking unsuccessful');
return 'share';
};
sys {
# https://www.swi-prolog.org/download/devel/src/
url => "https://www.swi-prolog.org/download/$release_type/src/",
version => qr/swipl-([\d\.]+)\.tar\.gz/,
);
plugin Extract => 'tar.gz';
plugin 'Build::CMake';
patch sub {
my @files = qw( src/SWI-Prolog.h src/os/pl-prologflag.c src/pl-fli.c );
system( $^X, qw(-pi -e), q{ s/\bPL_version\b/Swi$&/ }, @files );
};
my $threads = $Config{useithreads} ? '-DMULTI_THREADED=ON' : '-DMULTI_THREADED=OFF';
my @other_cmake_args = ();
my $is_msys2_mingw = $^O eq 'MSWin32' && exists $ENV{MSYSTEM} && $ENV{MSYSTEM} =~ /^mingw(32|64)$/i;
if( $is_msys2_mingw && File::Which::which('cygpath') ) {
# Running under MSYS2
chomp( my $MINGW_ROOT = `cygpath -m /$ENV{MSYSTEM}` );
push @lib_paths, $prefix->child(qw(bin)) if $is_windows;
my $lib_home_path = Path::Tiny::path(@home_parts, 'lib');
if( -d $lib_home_path ) {
push @lib_paths, map { $prefix->child($_) }
grep { $_->is_dir && $_ !~ /swiplserver/ }
$lib_home_path->children;
}
my @ldlibs = "-lswipl";
my $cflags = "-I$inc_path";
my $libs = join " ",
( map "-L$_", @lib_paths ) ,
@ldlibs;
my @rpaths = map { "" . $_->relative($prefix) }
@lib_paths;
$build->runtime_prop->{'swipl-bin'} = "$swipl_bin";
$build->runtime_prop->{home} = "$home_path";
$build->runtime_prop->{cflags} = $cflags;
$build->runtime_prop->{libs} = $libs;
$build->runtime_prop->{rpath} = \@rpaths;
};
};
lib/Alien/SWIProlog/Util.pm view on Meta::CPAN
if( ! exists $plvars->{PLLIBDIR} ) {
$gen_PLLIBDIR = File::Spec->catfile(
$plvars->{PLBASE},
'lib',
$plvars->{PLARCH}, )
}
return +{
'swipl-bin' => $pl,
home => $plvars->{PLBASE},
cflags => "-I$plvars->{PLBASE}/include",
libs => ( exists $plvars->{PLLIBDIR}
? join(' ', "-L$plvars->{PLLIBDIR}", $plvars->{PLLIB})
: join(' ', "-L$gen_PLLIBDIR", $plvars->{PLLDFLAGS}, $plvars->{PLLIB}),
),
rpath => [
( exists $plvars->{PLLIBDIR}
? $plvars->{PLLIBDIR}
: $gen_PLLIBDIR
)
],
( run in 0.548 second using v1.01-cache-2.11-cpan-94b05bcf43c )