| 1 | package Alien::Build::MB; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use Path::Tiny (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use Alien::Build; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use base qw( Module::Build ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | # ABSTRACT: Alien::Build installer class for Module::Build | ||||||||||||
| 10 | 1 | our $VERSION = '0.09'; # VERSION | |||||||||||
| 11 | |||||||||||||
| 12 | |||||||||||||
| 13 | sub new | ||||||||||||
| 14 | 4 | ▶ | { | ||||||||||
|
Subroutine
new: called CC=13 SCAR=26.0
Pod
documented
| |||||||||||||
| 15 | 4 | my($class, %args) = @_; | |||||||||||
| 16 | |||||||||||||
| 17 | 4 | ▶ | if(! -f 'alienfile') | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 18 | { | ||||||||||||
| 19 | 0 | die "unable to find alienfile"; | |||||||||||
| 20 | } | ||||||||||||
| 21 | else | ||||||||||||
| 22 | { | ||||||||||||
| 23 | 4 | my $build = Alien::Build->load('alienfile', root => '_alien'); | |||||||||||
| 24 | 4 | $build->load_requires('configure'); | |||||||||||
| 25 | 4 | $build->root; | |||||||||||
| 26 | 4 | $build->checkpoint; | |||||||||||
| 27 | } | ||||||||||||
| 28 | |||||||||||||
| 29 | 4 | my $self = $class->SUPER::new(%args); | |||||||||||
| 30 | |||||||||||||
| 31 | 4 | my $build = $self->alien_build(1); | |||||||||||
| 32 | |||||||||||||
| 33 | 4 | $self->_add_prereq( "${_}_requires", 'Module::Build' => '0.36' ) for qw( configure build ); | |||||||||||
| 34 | 4 | $self->_add_prereq( "${_}_requires", 'Alien::Build::MB' => '0.01' ) for qw( configure build ); | |||||||||||
| 35 | 4 | $self->add_to_cleanup("_alien"); | |||||||||||
| 36 | |||||||||||||
| 37 | 4 | foreach my $hook_name (qw( test_ffi test_share test_system )) | |||||||||||
| 38 | { | ||||||||||||
| 39 | 12 | ▶ | if($build->meta->has_hook($hook_name)) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 40 | { | ||||||||||||
| 41 | 2 | $self->_add_prereq( "configure_requires", 'Alien::Build::MB' => '0.05'); | |||||||||||
| 42 | 2 | last; | |||||||||||
| 43 | } | ||||||||||||
| 44 | } | ||||||||||||
| 45 | |||||||||||||
| 46 | 4 | my %config_requires = %{ $build->requires('configure') }; | |||||||||||
| 47 | 4 | foreach my $module (keys %config_requires) | |||||||||||
| 48 | { | ||||||||||||
| 49 | 5 | my $version = $config_requires{$module}; | |||||||||||
| 50 | 5 | $self->_add_prereq( 'configure_requires', $module => $version ); | |||||||||||
| 51 | } | ||||||||||||
| 52 | |||||||||||||
| 53 | 4 | ▶ | unless($build->install_type =~ /^(share|system)$/) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 54 | { | ||||||||||||
| 55 | 0 | die "unknown install type: @{[ $build->install_type ]}"; | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | 4 | my %build_requires = %{ $build->requires($build->install_type) }; | |||||||||||
| 59 | 4 | foreach my $module (keys %build_requires) | |||||||||||
| 60 | { | ||||||||||||
| 61 | 2 | my $version = $build_requires{$module}; | |||||||||||
| 62 | 2 | $self->_add_prereq( 'build_requires', $module => $version ); | |||||||||||
| 63 | } | ||||||||||||
| 64 | |||||||||||||
| 65 | 4 | ▶ | my $final_dest = $self->install_destination($build->meta_prop->{arch} ? 'arch' : 'lib'); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 66 | |||||||||||||
| 67 | 4 | my $prefix = Path::Tiny->new($final_dest) | |||||||||||
| 68 | ->child("auto/share/dist") | ||||||||||||
| 69 | ->child($self->dist_name) | ||||||||||||
| 70 | ->absolute; | ||||||||||||
| 71 | 4 | my $stage = Path::Tiny->new("blib/lib/auto/share/dist") | |||||||||||
| 72 | ->child($self->dist_name) | ||||||||||||
| 73 | ->absolute; | ||||||||||||
| 74 | |||||||||||||
| 75 | 4 | $build->set_stage ($stage->stringify ); | |||||||||||
| 76 | 4 | $build->set_prefix($prefix->stringify); | |||||||||||
| 77 | 4 | $build->runtime_prop->{perl_module_version} = $self->dist_version; | |||||||||||
| 78 | |||||||||||||
| 79 | 4 | $build->checkpoint; | |||||||||||
| 80 | |||||||||||||
| 81 | 4 | ▶ | if($self->alien_alienfile_meta) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 82 | { | ||||||||||||
| 83 | $self->meta_merge->{x_alienfile} = { | ||||||||||||
| 84 | 4 | ▶ | generated_by => "@{[ __PACKAGE__ ]} version @{[ __PACKAGE__->VERSION || 'dev' ]}", | ||||||||||
|
Condition50%1/2
__PACKAGE__->VERSION || 'dev'
MC/DC0%0/1
__PACKAGE__->VERSION || 'dev'
__PACKAGE__->VERSION
Truth table50%1/2
A
A= __PACKAGE__->VERSION
| |||||||||||||
| 85 | requires => { | ||||||||||||
| 86 | map { | ||||||||||||
| 87 | 4 | my %reqs = %{ $build->requires($_) }; | |||||||||||
| 88 | 8 | $reqs{$_} = "$reqs{$_}" for keys %reqs; | |||||||||||
| 89 | 8 | $_ => \%reqs; | |||||||||||
| 90 | } qw( share system ) | ||||||||||||
| 91 | }, | ||||||||||||
| 92 | }; | ||||||||||||
| 93 | } | ||||||||||||
| 94 | |||||||||||||
| 95 | 4 | $self; | |||||||||||
| 96 | } | ||||||||||||
| 97 | |||||||||||||
| 98 | |||||||||||||
| 99 | 1 | __PACKAGE__->add_property( alien_alienfile_meta => 1 ); | |||||||||||
| 100 | |||||||||||||
| 101 | |||||||||||||
| 102 | sub alien_build | ||||||||||||
| 103 | 19 | ▶ | { | ||||||||||
|
Subroutine
alien_build: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 104 | 19 | my($self, $noload) = @_; | |||||||||||
| 105 | 19 | my $build = Alien::Build->resume('alienfile', '_alien'); | |||||||||||
| 106 | 19 | $build->load_requires('configure'); | |||||||||||
| 107 | 19 | ▶ | $build->load_requires($build->install_type) unless $noload; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 108 | 19 | $build; | |||||||||||
| 109 | } | ||||||||||||
| 110 | |||||||||||||
| 111 | sub _alien_already_done ($) | ||||||||||||
| 112 | 11 | ▶ | { | ||||||||||
|
Subroutine
_alien_already_done: called CC=1 SCAR=0.0
| |||||||||||||
| 113 | 11 | my($name) = @_; | |||||||||||
| 114 | 11 | my $path = Path::Tiny->new("_alien/mb/$name"); | |||||||||||
| 115 | 11 | return -f $path; | |||||||||||
| 116 | } | ||||||||||||
| 117 | |||||||||||||
| 118 | sub _alien_touch ($) | ||||||||||||
| 119 | 8 | ▶ | { | ||||||||||
|
Subroutine
_alien_touch: called CC=1 SCAR=0.0
| |||||||||||||
| 120 | 8 | my($name) = @_; | |||||||||||
| 121 | 8 | my $path = Path::Tiny->new("_alien/mb/$name"); | |||||||||||
| 122 | 8 | $path->parent->mkpath; | |||||||||||
| 123 | 8 | $path->touch; | |||||||||||
| 124 | } | ||||||||||||
| 125 | |||||||||||||
| 126 | |||||||||||||
| 127 | sub ACTION_alien_download | ||||||||||||
| 128 | 5 | ▶ | { | ||||||||||
|
Subroutine
ACTION_alien_download: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 129 | 5 | my($self) = @_; | |||||||||||
| 130 | 5 | ▶ | return $self if _alien_already_done 'download'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 131 | 4 | my $build = $self->alien_build; | |||||||||||
| 132 | 4 | $build->download; | |||||||||||
| 133 | 4 | $build->checkpoint; | |||||||||||
| 134 | 4 | _alien_touch 'download'; | |||||||||||
| 135 | 4 | $self; | |||||||||||
| 136 | } | ||||||||||||
| 137 | |||||||||||||
| 138 | |||||||||||||
| 139 | sub ACTION_alien_build | ||||||||||||
| 140 | 6 | ▶ | { | ||||||||||
|
Subroutine
ACTION_alien_build: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||
| 141 | 6 | my($self) = @_; | |||||||||||
| 142 | 6 | ▶ | return $self if _alien_already_done 'build'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 143 | 4 | $self->depends_on('alien_download'); | |||||||||||
| 144 | |||||||||||||
| 145 | 4 | my $build = $self->alien_build; | |||||||||||
| 146 | 4 | $build->build; | |||||||||||
| 147 | |||||||||||||
| 148 | 4 | ▶ | if($build->meta_prop->{arch}) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 149 | { | ||||||||||||
| 150 | 4 | my $archdir = Path::Tiny->new("./blib/arch/auto/@{[ join '/', split /-/, $self->dist_name ]}"); | |||||||||||
| 151 | 4 | $archdir->mkpath; | |||||||||||
| 152 | 4 | my $archfile = $archdir->child($archdir->basename . ".txt"); | |||||||||||
| 153 | 4 | $archfile->spew('Alien based distribution with architecture specific file in share'); | |||||||||||
| 154 | } | ||||||||||||
| 155 | |||||||||||||
| 156 | { | ||||||||||||
| 157 | 4 | my @parts = split /-/, $self->dist_name; | |||||||||||
| 158 | 4 | my $package = join '::', @parts; | |||||||||||
| 159 | 4 | my $install_files = Path::Tiny->new("./blib/lib")->child( @parts, 'Install', 'Files.pm' ); | |||||||||||
| 160 | 4 | $install_files->parent->mkpath; | |||||||||||
| 161 | 4 | $install_files->spew_utf8( | |||||||||||
| 162 | "package ${package}::Install::Files;\n", | ||||||||||||
| 163 | "use strict;\n", | ||||||||||||
| 164 | "use warnings;\n", | ||||||||||||
| 165 | "require ${package};\n", | ||||||||||||
| 166 | "sub Inline { shift; ${package}->Inline(\@_) }\n", | ||||||||||||
| 167 | "1;\n", | ||||||||||||
| 168 | "\n", | ||||||||||||
| 169 | "=begin Pod::Coverage\n", | ||||||||||||
| 170 | "\n", | ||||||||||||
| 171 | " Inline\n", | ||||||||||||
| 172 | "\n", | ||||||||||||
| 173 | "=cut\n", | ||||||||||||
| 174 | ); | ||||||||||||
| 175 | }; | ||||||||||||
| 176 | |||||||||||||
| 177 | 4 | $build->checkpoint; | |||||||||||
| 178 | |||||||||||||
| 179 | 4 | _alien_touch 'build'; | |||||||||||
| 180 | 4 | $self; | |||||||||||
| 181 | } | ||||||||||||
| 182 | |||||||||||||
| 183 | |||||||||||||
| 184 | sub ACTION_alien_test | ||||||||||||
| 185 | 2 | ▶ | { | ||||||||||
|
Subroutine
ACTION_alien_test: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 186 | 2 | my($self) = @_; | |||||||||||
| 187 | 2 | $self->depends_on('alien_build'); | |||||||||||
| 188 | |||||||||||||
| 189 | 2 | my $build = $self->alien_build; | |||||||||||
| 190 | 2 | ▶ | if($build->can('test')) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 191 | { | ||||||||||||
| 192 | 2 | $build->test; | |||||||||||
| 193 | 1 | $build->checkpoint; | |||||||||||
| 194 | } | ||||||||||||
| 195 | 1 | $self; | |||||||||||
| 196 | } | ||||||||||||
| 197 | |||||||||||||
| 198 | sub ACTION_test | ||||||||||||
| 199 | 0 | ▶ | { | ||||||||||
|
Subroutine
ACTION_test: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 200 | 0 | my($self) = @_; | |||||||||||
| 201 | 0 | $self->depends_on('alien_test'); | |||||||||||
| 202 | 0 | $self->SUPER::ACTION_test; | |||||||||||
| 203 | } | ||||||||||||
| 204 | |||||||||||||
| 205 | sub ACTION_code | ||||||||||||
| 206 | 0 | ▶ | { | ||||||||||
|
Subroutine
ACTION_code: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 207 | 0 | my($self) = @_; | |||||||||||
| 208 | 0 | $self->depends_on('alien_build'); | |||||||||||
| 209 | 0 | $self->SUPER::ACTION_code; | |||||||||||
| 210 | } | ||||||||||||
| 211 | |||||||||||||
| 212 | 1 | 1; | |||||||||||
| 213 | |||||||||||||
| 214 | __END__ | ||||||||||||