Xrepo/MB.pm

filter: Statementstmt 50.0% 2 / 4 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 66.6% 4 / 6 CC 1 SCAR 4.1
CC
1
Cov
50%
BEGIN
2.0
BEGIN
1.0
CRAP 1.5
« Xrepo/Runtime/Alt.pm ↑ Summary Xrepo.pm »
1 1 ▶use v5.40;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package Alien::Xrepo::MB v1.0.10 {
4 0 ▶ use Alien::Xrepo::Build;
Subroutine BEGIN: called CC=1 SCAR=6.9
5 use Alien::Xrepo::Build::Dist;
6 use Path::Tiny;
7 use parent 'Module::Build';
8 __PACKAGE__->add_property( xrepo_snapshot => undef ); # JSON to (re)write, auto-derived when undef
9 __PACKAGE__->add_property( xrepo_share_dir => undef ); # shallow-install root, defaults to the snapshot's dir
10 __PACKAGE__->add_property( xrepo_cache => 0 ); # bypass Alien::Xrepo's on-disk cache by default
11 __PACKAGE__->add_property( xrepo_update_repo => 0 ); # refresh xrepo repositories once when an install fails
12 __PACKAGE__->add_property( xrepo_verbose => 0 ); # forward Alien::Xrepo->verbose (adds xmake's -v on installs)
13 __PACKAGE__->add_property( xrepo_diagnosis => 0 ); # forward Alien::Xrepo->diagnosis (adds xmake's -D on installs)
14  
15 sub ACTION_code($self) {
16 my $dist = $self->_dist;
17 my $snapshot = path( defined $self->xrepo_snapshot ? $self->xrepo_snapshot : $dist->snapshot_path );
18 if ( $dist->snapshot_stale( $snapshot, $self->_engine_mods ) ) {
19 my $share = defined $self->xrepo_share_dir ? path( $self->xrepo_share_dir ) : $snapshot->parent;
20 $share->mkpath;
21 say '=> xrepo: writing ' . $snapshot;
22 my $build = Alien::Xrepo::Build->new(
23 recipe => $dist->recipe,
24 snapshot => $snapshot,
25 share_dir => $share->stringify,
26 cache => $self->xrepo_cache,
27 update_repo => $self->xrepo_update_repo,
28 verbose => $self->xrepo_verbose,
29 diagnosis => $self->xrepo_diagnosis
30 );
31 $build->run;
32 $build->assert_installed;
33 }
34 else {
35 $self->log_verbose("=> xrepo: $snapshot is up to date\n");
36 }
37 return $self->SUPER::ACTION_code;
38 }
39  
40 # The record of facts the two builders share: this dist root, the module, and the build script whose mtime counts as a freshness input.
41 sub _dist ($self) {
42 my $class = $self->module_name or die 'Alien::Xrepo::MB: module_name is required';
43 return Alien::Xrepo::Build::Dist->new( base_dir => $self->base_dir, module_name => $class, script => 'Build.PL', );
44 }
45  
46 # Engine modules that count as recipe inputs when loaded into this process.
47 sub _engine_mods {qw[Alien/Xrepo/MB.pm Alien/Xrepo/Build.pm Alien/Xrepo/Runtime.pm Alien/Xrepo/Build/Recipe.pm]}
48  
49 # Kept for interface stability with existing `./Build` consumers and tests; the real work delegates to Alien::Xrepo::Build::Dist
50 sub _recipe ($self) { $self->_dist->recipe }
51 sub _xrepo_snapshot ($self) { defined $self->xrepo_snapshot ? $self->xrepo_snapshot : $self->_dist->snapshot_path }
52 sub _xrepo_inputs ($self) { $self->_dist->inputs( $self->_engine_mods ) }
53 sub _snapshot_stale ( $self, $snapshot ) { $self->_dist->snapshot_stale( $snapshot, $self->_engine_mods ) }
54 };
55 #
56 1;
« Xrepo/Runtime/Alt.pm ↑ Summary Xrepo.pm »