| 1 | # Based on Module::Build::Tiny which is copyright (c) 2011 by Leon Timmermans, David Golden. | ||||||||||||||||||||||||||||
| 2 | # Module::Build::Tiny is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 3 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use v5.40; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | class # | ||||||||||||||||||||||||||||
| 8 | 1 | SDL3::Builder { | |||||||||||||||||||||||||||
| 9 | 1 | ▶ | use CPAN::Meta; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use ExtUtils::Install qw[pm_to_blib install]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use ExtUtils::InstallPaths 0.002; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use File::Basename qw[basename dirname]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use File::Find (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use File::Path qw[mkpath rmtree]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use File::Spec::Functions qw[catfile catdir rel2abs abs2rel splitdir curdir]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use JSON::PP 2 qw[encode_json decode_json]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # Not in CORE | ||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Path::Tiny qw[path]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use ExtUtils::Helpers 0.028 qw[make_executable split_like_shell detildefy]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||
| 22 | 1 | field $action : param //= 'build'; | |||||||||||||||||||||||||||
| 23 | 1 | field $meta : reader = CPAN::Meta->load_file('META.json'); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # Params to Build script | ||||||||||||||||||||||||||||
| 26 | 1 | field $install_base : param //= ''; | |||||||||||||||||||||||||||
| 27 | 1 | field $installdirs : param //= ''; | |||||||||||||||||||||||||||
| 28 | 1 | field $uninst : param //= 0; # Make more sense to have a ./Build uninstall command but... | |||||||||||||||||||||||||||
| 29 | 1 | field $install_paths : param //= ExtUtils::InstallPaths->new( dist_name => $meta->name ); | |||||||||||||||||||||||||||
| 30 | 1 | field $verbose : param //= 0; | |||||||||||||||||||||||||||
| 31 | 1 | field $dry_run : param //= 0; | |||||||||||||||||||||||||||
| 32 | 1 | field $pureperl : param //= 0; | |||||||||||||||||||||||||||
| 33 | 1 | field $jobs : param //= 1; | |||||||||||||||||||||||||||
| 34 | 1 | field $destdir : param //= ''; | |||||||||||||||||||||||||||
| 35 | 1 | field $prefix : param //= ''; | |||||||||||||||||||||||||||
| 36 | # | ||||||||||||||||||||||||||||
| 37 | 1 | ▶ | ADJUST { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | -e 'META.json' or die "No META information provided\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | method write_file( $filename, $content ) { path($filename)->spew_raw($content) or die "Could not open $filename: $!\n" } | ||||||||||||||||||||||||||
|
Subroutine
write_file: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | method read_file ($filename) { path($filename)->slurp_utf8 or die "Could not open $filename: $!\n" } | ||||||||||||||||||||||||||
|
Subroutine
read_file: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | method step_build() { | ||||||||||||||||||||||||||
|
Subroutine
step_build: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 0 | for my $pl_file ( find( qr/\.PL$/, 'lib' ) ) { | |||||||||||||||||||||||||||
| 45 | 0 | ( my $pm = $pl_file ) =~ s/\.PL$//; | |||||||||||||||||||||||||||
| 46 | 0 | ▶ | system $^X, $pl_file->stringify, $pm and die "$pl_file returned $?\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | 0 | my %modules = map { $_ => catfile( 'blib', $_ ) } find( qr/\.pm$/, 'lib' ); | |||||||||||||||||||||||||||
| 49 | 0 | my %docs = map { $_ => catfile( 'blib', $_ ) } find( qr/\.pod$/, 'lib' ); | |||||||||||||||||||||||||||
| 50 | 0 | my %scripts = map { $_ => catfile( 'blib', $_ ) } find( qr/(?:)/, 'script' ); | |||||||||||||||||||||||||||
| 51 | 0 | my %sdocs = map { $_ => delete $scripts{$_} } grep {/.pod$/} keys %scripts; | |||||||||||||||||||||||||||
| 52 | 0 | my %dist_shared = map { $_ => catfile( qw[blib lib auto share dist], $meta->name, abs2rel( $_, 'share' ) ) } find( qr/(?:)/, 'share' ); | |||||||||||||||||||||||||||
| 53 | 0 | my %module_shared = map { $_ => catfile( qw[blib lib auto share module], abs2rel( $_, 'module-share' ) ) } find( qr/(?:)/, 'module-share' ); | |||||||||||||||||||||||||||
| 54 | 0 | pm_to_blib( { %modules, %docs, %scripts, %dist_shared, %module_shared }, catdir(qw[blib lib auto]) ); | |||||||||||||||||||||||||||
| 55 | 0 | make_executable($_) for values %scripts; | |||||||||||||||||||||||||||
| 56 | 0 | mkpath( catdir(qw[blib arch]), $verbose ); | |||||||||||||||||||||||||||
| 57 | 0 | 0; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 0 | ▶ | method step_clean() { rmtree( $_, $verbose ) for qw[blib temp]; 0 } | ||||||||||||||||||||||||||
|
Subroutine
step_clean: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | method step_install() { | ||||||||||||||||||||||||||
|
Subroutine
step_install: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | $self->step_build() unless -d 'blib'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | install( | |||||||||||||||||||||||||||
| 64 | [ from_to => $install_paths->install_map, | ||||||||||||||||||||||||||||
| 65 | verbose => $verbose, | ||||||||||||||||||||||||||||
| 66 | dry_run => $dry_run, | ||||||||||||||||||||||||||||
| 67 | uninstall_shadows => $uninst, | ||||||||||||||||||||||||||||
| 68 | skip => undef, | ||||||||||||||||||||||||||||
| 69 | always_copy => 1 | ||||||||||||||||||||||||||||
| 70 | ] | ||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||
| 72 | 0 | 0; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 0 | ▶ | method step_realclean () { rmtree( $_, $verbose ) for qw[blib temp Build _build_params MYMETA.yml MYMETA.json]; 0 } | ||||||||||||||||||||||||||
|
Subroutine
step_realclean: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | method step_test() { | ||||||||||||||||||||||||||
|
Subroutine
step_test: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $self->step_build() unless -d 'blib'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | require TAP::Harness::Env; | |||||||||||||||||||||||||||
| 79 | my %test_args = ( | ||||||||||||||||||||||||||||
| 80 | ( verbosity => $verbose ), | ||||||||||||||||||||||||||||
| 81 | ( jobs => $jobs ), | ||||||||||||||||||||||||||||
| 82 | ( color => -t STDOUT ), | ||||||||||||||||||||||||||||
| 83 | 0 | lib => [ map { rel2abs( catdir( 'blib', $_ ) ) } qw[arch lib] ], | |||||||||||||||||||||||||||
| 84 | ); | ||||||||||||||||||||||||||||
| 85 | 0 | TAP::Harness::Env->create( \%test_args )->runtests( sort map { $_->stringify } find( qr/\.t$/, 't' ) )->has_errors; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | method get_arguments (@sources) { | ||||||||||||||||||||||||||
|
Subroutine
get_arguments: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 89 | 0 | $_ = detildefy($_) for grep {defined} $install_base, $destdir, $prefix, values %{$install_paths}; | |||||||||||||||||||||||||||
| 90 | 0 | $install_paths = ExtUtils::InstallPaths->new( dist_name => $meta->name ); | |||||||||||||||||||||||||||
| 91 | 0 | return; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | method Build(@args) { | ||||||||||||||||||||||||||
|
Subroutine
Build: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 0 | my $method = $self->can( 'step_' . $action ); | |||||||||||||||||||||||||||
| 96 | 0 | ▶ | $method // die "No such action '$action'\n"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$method // die("No such action '${action}'\n")
MC/DC0%0/1
$method // die("No such action '${action}'\n")
$method
Truth table0%0/2
A
A= $method
| |||||||||||||||||||||||||||||
| 97 | 0 | exit $method->($self); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | method Build_PL() { | ||||||||||||||||||||||||||
|
Subroutine
Build_PL: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 0 | say sprintf 'Creating new Build script for %s %s', $meta->name, $meta->version; | |||||||||||||||||||||||||||
| 102 | 0 | $self->write_file( 'Build', sprintf <<'', $^X, __PACKAGE__, __PACKAGE__ ); | |||||||||||||||||||||||||||
| 103 | #!%s | ||||||||||||||||||||||||||||
| 104 | use lib 'builder'; | ||||||||||||||||||||||||||||
| 105 | use %s; | ||||||||||||||||||||||||||||
| 106 | use Getopt::Long qw[GetOptionsFromArray]; | ||||||||||||||||||||||||||||
| 107 | my %%opts = ( @ARGV && $ARGV[0] =~ /\A\w+\z/ ? ( action => shift @ARGV ) : () ); | ||||||||||||||||||||||||||||
| 108 | GetOptionsFromArray \@ARGV, \%%opts, qw[install_base=s install_path=s%% installdirs=s destdir=s prefix=s config=s%% uninst:1 verbose:1 dry_run:1 jobs=i]; | ||||||||||||||||||||||||||||
| 109 | %s->new(%%opts)->Build(); | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | make_executable('Build'); | |||||||||||||||||||||||||||
| 112 | 0 | ▶ | my @env = defined $ENV{PERL_MB_OPT} ? split_like_shell( $ENV{PERL_MB_OPT} ) : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 0 | $self->write_file( '_build_params', encode_json( [ \@env, \@ARGV ] ) ); | |||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( my $dynamic = $meta->custom('x_dynamic_prereqs') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | my %meta = ( %{ $meta->as_struct }, dynamic_config => 0 ); | |||||||||||||||||||||||||||
| 116 | 0 | $self->get_arguments( \@env, \@ARGV ); | |||||||||||||||||||||||||||
| 117 | 0 | require CPAN::Requirements::Dynamic; | |||||||||||||||||||||||||||
| 118 | 0 | my $dynamic_parser = CPAN::Requirements::Dynamic->new(); | |||||||||||||||||||||||||||
| 119 | 0 | my $prereq = $dynamic_parser->evaluate($dynamic); | |||||||||||||||||||||||||||
| 120 | 0 | $meta{prereqs} = $meta->effective_prereqs->with_merged_prereqs($prereq)->as_string_hash; | |||||||||||||||||||||||||||
| 121 | 0 | $meta = CPAN::Meta->new( \%meta ); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | 0 | $meta->save(@$_) for ['MYMETA.json']; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub find ( $pattern, $base ) { | ||||||||||||||||||||||||||
|
Subroutine
find: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | $base = path($base) unless builtin::blessed $base; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | my $blah = $base->visit( | ||||||||||||||||||||||||||||
| 129 | 0 | ▶ | sub ( $path, $state ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $state->{$path} = $path if -f $path && $path =~ $pattern; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $path and $path =~ /$pattern/u
MC/DC0%0/2
-f $path and $path =~ /$pattern/u
-f $path
$path =~ /$pattern/u
Truth table0%0/3
A and B
A= -f $pathB= $path =~ /$pattern/u
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | #~ return \0 if keys %$state == 10; | ||||||||||||||||||||||||||||
| 133 | }, | ||||||||||||||||||||||||||||
| 134 | 0 | { recurse => 1 } | |||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||
| 136 | 0 | values %$blah; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | }; | ||||||||||||||||||||||||||||
| 139 | 1 | 1; | |||||||||||||||||||||||||||