Alien-Build-Plugin-Build-Xrepo
view release on metacpan or search on metacpan
lib/Alien/Build/Plugin/Build/Xrepo.pm view on Meta::CPAN
delete $packages{$name};
$errors{$name} = 'export failed: ' . ( $@ || 'unknown error' );
}
}
# A failed sibling does not sink the surviving packages (partial installs are by
# design), but it must never be silent: prune export-failures from the success set,
# flag every failure in the returned install/runtime prop so consumers can see what
# is missing, and warn loudly.
my $spared = Path::Tiny->new($src)->child('xrepo.manifest');
$spared->spew_utf8( join "\n", grep { exists $packages{$_} } $recipe->packages );
if (%errors) {
$build->runtime_prop->{errors} = { map { $_ => $errors{$_} } sort keys %errors };
my $failed = join ', ', sort keys %errors;
warn "Alien::Build::Plugin::Build::Xrepo: partial failure - these packages failed to install or export: $failed\n";
my ( $ok, $bad ) = ( scalar( keys %packages ), scalar( keys %errors ) );
warn "[xrepo] $ok packages installed, $bad failed (see install_prop->{xrepo}{errors} / runtime_prop->{errors} for details)\n"
if $verbose;
}
my $xrepo = $build->install_prop->{xrepo} ||= {};
$xrepo->{packages} = \%packages;
t/001_build_plugin.t view on Meta::CPAN
my $t = Path::Tiny->new( $opts{packagedir} // return 0 );
$t->child('include')->mkpath;
$t->child('lib')->mkpath;
$t->child('bin')->mkpath;
if ($main::NESTED) {
$t = $t->child('z')->child($name)->child( $version // 'v1' )->child('deadbeef');
$t->child('include')->mkpath;
$t->child('lib')->mkpath;
$t->child('bin')->mkpath;
}
$t->child('include')->child("$name.h")->spew_utf8("#define $name 1\n");
$t->child('lib')->child("$name.lib")->spew_utf8("LIB\n");
$t->child('bin')->child("$name.dll")->spew_utf8("BIN\n");
return 1;
}
method add_repo ( $name, $url ) {
push @$calls, { action => 'add_repo', name => $name, url => $url };
push @main::ALL_CALLS, { action => 'add_repo', name => $name, url => $url };
}
method _pkg ( $name, $version ) {
Alien::Xrepo::PackageInfo->new(
t/001_build_plugin.t view on Meta::CPAN
my $errors = $build->install_prop->{xrepo}{errors};
like $errors->{libsdl3}, qr/boom/, 'failed sibling recorded in errors';
like $rp->{errors}{libsdl3}, qr/boom/, 'failure flagged in the returned runtime_prop';
ok !exists $rp->{errors}{zstd}, 'successful packages are not flagged';
like winslash( $rp->{cflags} ), qr/-I[^\s]*zstd\/include/, 'primary package still gathered';
ok exists $rp->{alt}{ninja}, 'sibling after the failure gathered in alt';
ok !exists $rp->{alt}{libsdl3}, 'failed sibling omitted from alt';
is $build->install_type, 'share', 'a partial success is still a share install';
my $mf = path( $build->install_prop->{xrepo}{download_dir} )->child('xrepo.manifest');
ok -e $mf, 'xrepo.manifest written';
my $m = $mf->slurp_utf8;
like $m, qr[^zstd$]m, 'manifest lists the installed package';
like $m, qr[^ninja$]m, 'manifest lists the surviving sibling';
unlike $m, qr[^libsdl3$]m, 'manifest omits the failed package';
};
subtest 'ffi gathers a name and dynamic libs' => sub {
my $r = driven_build( sf( "['zstd']", ffi => 1 ) );
my $build = $r->{build};
my $rp = $build->runtime_prop;
is $rp->{ffi_name}, 'zstd', 'ffi_name from the primary links';
ok scalar @{ $rp->{dynamic_libs} } >= 1, 'dynamic libs listed';
( run in 3.248 seconds using v1.01-cache-2.11-cpan-364913b4093 )