| 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 | Affix::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::Path qw[make_path remove_tree]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use File::Spec::Functions qw[catfile catdir rel2abs abs2rel splitdir curdir]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use JSON::PP 2 qw[encode_json decode_json]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use File::Temp qw[tempfile]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # Not in CORE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Path::Tiny qw[path cwd]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
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 | # infix and Affix stuff | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Config qw[%Config]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | field $force : param //= 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | field $debug : param //= 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | field $libver; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | field $cflags; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | field $ldflags; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | field $cppver = 'c++17'; # https://en.wikipedia.org/wiki/C%2B%2B20#Compiler_support | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | field $cver = 'c17'; # https://en.wikipedia.org/wiki/C17_(C_standard_revision) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | field $make : param //= $Config{make} || 'dmake'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | field $action : param //= 'build'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | field $meta : reader = CPAN::Meta->load_file('META.json'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # Params to Build script | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | field $install_base : param //= ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | field $installdirs : param //= ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | field $uninst : param //= 0; # Make more sense to have a ./Build uninstall command but... | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | field $install_paths : param //= ExtUtils::InstallPaths->new( dist_name => $meta->name ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | field $verbose : param(v) //= 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | field $dry_run : param //= 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | field $pureperl : param //= 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | field $jobs : param //= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | field $destdir : param //= ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | field $prefix : param //= ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | ▶ | ADJUST { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=15 SCAR=34.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | die "No META information provided\n" unless -e 'META.json'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | die "OS unsupported: Affix requires a 64-bit architecture\n" if $Config{ptrsize} < 8; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # Configure Flags | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | my $is_bsd = $^O =~ /bsd/i; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | my $is_win = $^O =~ /MSWin32/i; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | my $is_sun = $^O =~ /(solaris|sunos)/i; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | $cflags = ( $is_bsd || $is_sun ) ? '' : '-fPIC '; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$is_bsd or $is_sun
MC/DC0%0/2
$is_bsd or $is_sun
$is_bsd
$is_sun
Truth table33%1/3
A or B
A= $is_bsdB= $is_sun
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | $ldflags = ( $is_bsd || $is_sun ) ? '' : ' -flto=auto '; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$is_bsd or $is_sun
MC/DC0%0/2
$is_bsd or $is_sun
$is_bsd
$is_sun
Truth table33%1/3
A or B
A= $is_bsdB= $is_sun
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | $cflags .= ' -D__EXTENSIONS__ -D_LARGEFILE64_SOURCE' if $is_sun; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | if ( $debug > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $cflags | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | .= '-DDEBUG=' . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $debug . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ' -g3 -gdwarf-4 ' . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ' -Wno-deprecated -pipe ' . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ' -Wall -Wextra -Wpedantic -Wvla -Wnull-dereference ' . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ' -Wswitch-enum -Wduplicated-cond ' . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ' -Wduplicated-branches'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $cflags .= ' -fvar-tracking-assignments' unless $Config{osname} eq 'darwin'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | elsif ( !$is_win ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | $cflags .= ' -DNDEBUG -DBOOST_DISABLE_ASSERTS -O3 -ftree-vectorize -ffast-math -fno-align-functions -fno-omit-frame-pointer'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | $cflags .= ' -flto' unless ( $is_bsd || $is_sun ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$is_bsd or $is_sun
MC/DC0%0/2
$is_bsd or $is_sun
$is_bsd
$is_sun
Truth table33%1/3
A or B
A= $is_bsdB= $is_sun
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # Threading support (Critical for shm_open/librt on Linux) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | ▶ | if ( !$is_win ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | $cflags .= ' -pthread'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | $ldflags .= ' -pthread'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | $ldflags .= ' -Wl,-z,nobtcfi' if $^O eq 'openbsd'; # XXX - Temp BTI/IBT workaround https://www.openbsd.org/innovations.html | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | method step_build() { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
step_build: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $self->step_affix; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my %modules = map { $_ => catfile( 'blib', $_ ) } find( qr/\.pm$/, 'lib' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my %docs = map { $_ => catfile( 'blib', $_ ) } find( qr/\.pod$/, 'lib' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my %scripts = map { $_ => catfile( 'blib', $_ ) } find( qr/(?:)/, 'script' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my %sdocs = map { $_ => delete $scripts{$_} } grep {/.pod$/} keys %scripts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my %dist_shared = map { $_ => catfile( qw[blib lib auto share dist], $meta->name, abs2rel( $_, 'share' ) ) } find( qr/(?:)/, 'share' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my %module_shared = map { $_ => catfile( qw[blib lib auto share module], abs2rel( $_, 'module-share' ) ) } find( qr/(?:)/, 'module-share' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | pm_to_blib( { %modules, %docs, %scripts, %dist_shared, %module_shared }, catdir(qw[blib lib auto]) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | make_executable($_) for values %scripts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | make_path( catdir(qw[blib arch]), { chmod => 0755, verbose => $verbose } ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | method _clean_objects() { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean_objects: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $lib_dir = path('lib'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my @objs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | $lib_dir->visit( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub ( $path, $state ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | push @objs, $path if $path->is_file && $path =~ /\.(?:o|obj)\z/i; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$path->is_file and $path =~ /\.(?:o|obj)\z/iu
MC/DC0%0/2
$path->is_file and $path =~ /\.(?:o|obj)\z/iu
$path->is_file
$path =~ /\.(?:o|obj)\z/iu
Truth table0%0/3
A and B
A= $path->is_fileB= $path =~ /\.(?:o|obj)\z/iu
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | { recurse => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | remove_tree( $_, { verbose => $verbose } ) for @objs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | method step_clean() { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
step_clean: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | remove_tree( $_, { verbose => $verbose } ) for qw[blib temp]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $self->_clean_objects; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | method step_install() { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
step_install: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | $self->step_build() unless -d 'blib'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my %res; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | install( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | [ from_to => $install_paths->install_map, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | verbose => $verbose, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | always_copy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | dry_run => $dry_run, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | uninst => $uninst, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | result => \%res | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # In the future, I might check the values of %res according to https://metacpan.org/pod/ExtUtils::Install#install | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | method step_realclean () { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
step_realclean: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | remove_tree( $_, { verbose => $verbose } ) for qw[blib temp Build _build_params MYMETA.yml MYMETA.json]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | remove_tree( 'infix/build_lib', { verbose => $verbose } ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $self->_clean_objects; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | ▶ | method step_test(%args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
step_test: called CC=5 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | ▶ | $jobs = $args{j} // $args{jobs} // $jobs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
($args{"j"} // $args{"jobs"}) // $jobs
$args{"j"} // $args{"jobs"}
MC/DC0%0/3
($args{"j"} // $args{"jobs"}) // $jobs
$args{"j"}
$args{"jobs"}
$jobs
Truth table25%1/4
A // B // C
A= $args{"j"}B= $args{"jobs"}C= $jobs
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | ▶ | $self->step_build() unless -d 'blib'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | require TAP::Harness::Env; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | my %test_args = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ( verbosity => $verbose ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ( $jobs ? ( jobs => $jobs ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ( color => -t STDOUT ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | lib => [ map { rel2abs( catdir( 'blib', $_ ) ) } qw[arch lib] ], | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | TAP::Harness::Env->create( \%test_args )->runtests( sort map { $_->stringify } find( qr/\.t$/, 't' ) )->has_errors; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | method step_fuzz(@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
step_fuzz: not called CC=27 SCAR=66.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my %args = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $self->step_build() unless -d 'blib'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # Fuzz config via env vars (or caller can pass %args) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | my $max_iter = $ENV{FUZZ_MAX_ITER} // $args{iter} // 10000; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($ENV{"FUZZ_MAX_ITER"} // $args{"iter"}) // 10000
$ENV{"FUZZ_MAX_ITER"} // $args{"iter"}
MC/DC0%0/2
($ENV{"FUZZ_MAX_ITER"} // $args{"iter"}) // 10000
$ENV{"FUZZ_MAX_ITER"}
$args{"iter"}
Truth table0%0/3
A // B
A= $ENV{"FUZZ_MAX_ITER"}B= $args{"iter"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my $timeout = $ENV{FUZZ_TIMEOUT} // $args{timeout} // 5; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($ENV{"FUZZ_TIMEOUT"} // $args{"timeout"}) // 5
$ENV{"FUZZ_TIMEOUT"} // $args{"timeout"}
MC/DC0%0/2
($ENV{"FUZZ_TIMEOUT"} // $args{"timeout"}) // 5
$ENV{"FUZZ_TIMEOUT"}
$args{"timeout"}
Truth table0%0/3
A // B
A= $ENV{"FUZZ_TIMEOUT"}B= $args{"timeout"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | my $verbose_fuzz = $ENV{FUZZ_VERBOSE} // $args{verbose} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($ENV{"FUZZ_VERBOSE"} // $args{"verbose"}) // 0
$ENV{"FUZZ_VERBOSE"} // $args{"verbose"}
MC/DC0%0/2
($ENV{"FUZZ_VERBOSE"} // $args{"verbose"}) // 0
$ENV{"FUZZ_VERBOSE"}
$args{"verbose"}
Truth table0%0/3
A // B
A= $ENV{"FUZZ_VERBOSE"}B= $args{"verbose"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # Determine which Perl targets to run | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my @targets; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if ( $args{all} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | @targets = qw[wrap grammar register cross compile]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | elsif ( $args{smoke} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | @targets = qw[wrap grammar register cross]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | elsif ( $args{target} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | @targets = ref $args{target} ? @{ $args{target} } : ( $args{target} ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | @targets = qw[wrap grammar register cross]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # Perl fuzz target metadata | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my %perl_targets = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | wrap => { script => 'fuzz_wrap_type_sig.pl', desc => 'Affix::Wrap::Type->parse()', needs_lib => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | grammar => { script => 'fuzz_grammar_mutate.pl', desc => 'Grammar-aware C sig mutations', needs_lib => 1, extra_inc => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | register => { script => 'fuzz_register_types.pl', desc => 'Affix::_typedef() — C parser direct', needs_lib => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | cross => { script => 'fuzz_cross_boundary.pl', desc => 'Cross-boundary Perl->C->JIT', needs_lib => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | compile => { script => 'fuzz_compile_ok.pl', desc => 'compile_ok() C compilation', needs_lib => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | shared => { script => 'fuzz_shared_lib.pl', desc => 'Compile→load→affix→call→verify ABI', needs_lib => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # C fuzz targets (delegate to infix/build.pl) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my %c_targets = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | signature => 'Parser crashes + arena stress', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | abi => 'ABI classification', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | types => 'Type generator bugs', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | roundtrip => 'Type->String->Type consistency', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | trampoline => 'JIT trampoline creation', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | direct => 'Direct marshalling JIT', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $fuzz_dir = path('fuzz'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | die "fuzz/ directory not found\n" unless -d $fuzz_dir; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $failures = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | my $iters = $args{smoke} ? 100 : $max_iter; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my $to = $args{smoke} ? 3 : $timeout; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # Run Perl fuzz targets via TAP::Harness for proper TAP output | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | require TAP::Harness::Env; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my @fuzz_scripts; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | for my $name (@targets) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | my $target = $perl_targets{$name} // do { warn "Unknown Perl fuzz target: $name\n"; $failures++; next }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$perl_targets{$name} // do {
warn "Unknown Perl fuzz target: $name\n";
++$failures;
next
}
MC/DC0%0/2
$perl_targets{$name} // do {
warn "Unknown Perl fuzz target: $name\n";
++$failures;
next
}
$perl_targets{$name}
do {
warn "Unknown Perl fuzz target: $name\n";
++$failures;
next
}
Truth table0%0/3
A // B
A= $perl_targets{$name}B= do {
warn "Unknown Perl fuzz target: $name\n";
++$failures;
next
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $script = $fuzz_dir->child( $target->{script} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | unless ( -f $script ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | warn "Fuzz script not found: $script\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $failures++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | say "=" x 60; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | say "Fuzzing: $target->{desc}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | say " Script: $target->{script}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | say " Iterations: $iters, Timeout: ${to}s"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | say "=" x 60; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | push @fuzz_scripts, $script->stringify; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if (@fuzz_scripts) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | local $ENV{FUZZ_MAX_ITER} = $iters; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | local $ENV{FUZZ_TIMEOUT} = $to; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | local $ENV{FUZZ_VERBOSE} = $verbose_fuzz; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | my %harness_args | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | = ( ( verbosity => $verbose ), ( color => -t STDOUT ), lib => [ map { rel2abs( catdir( 'blib', $_ ) ) } qw[arch lib] ], ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $harness = TAP::Harness::Env->create( \%harness_args ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my $aggr = $harness->runtests( sort @fuzz_scripts ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | $failures++ if $aggr->has_errors; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | say ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # Smoke test: also quick-build C targets if available | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if ( $args{smoke} || $args{all} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"smoke"} or $args{"all"}
MC/DC0%0/2
$args{"smoke"} or $args{"all"}
$args{"smoke"}
$args{"all"}
Truth table0%0/3
A or B
A= $args{"smoke"}B= $args{"all"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $build_pl = path('infix/build.pl'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if ( -f $build_pl ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | for my $name ( sort keys %c_targets ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | say "=" x 60; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | say "Building C fuzz target: fuzz:$name"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | say " $c_targets{$name}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | say "=" x 60; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $exit = system( $^X, $build_pl->stringify, "fuzz:$name" ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $failures++ if $exit != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | say ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | say "Skipping C fuzz targets (infix/build.pl not found)"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | say "=" x 60; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if ($failures) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | say "FAILED: $failures target(s) reported crashes or build errors"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | say "All fuzz targets clean."; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | return $failures > 0 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | method get_arguments (@sources) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_arguments: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $_ = detildefy($_) for grep {defined} $install_base, $destdir, $prefix, values %{$install_paths}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $install_paths = ExtUtils::InstallPaths->new( dist_name => $meta->name ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | ▶ | method Build(@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Build: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 1 | my $method = $self->can( 'step_' . $action ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | ▶ | $method // die "No such action '$action'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$method // die("No such action '${action}'\n")
MC/DC0%0/1
$method // die("No such action '${action}'\n")
$method
Truth table50%1/2
A
A= $method
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 1 | exit $method->( $self, @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | method Build_PL() { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Build_PL: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | die "Pure perl Affix? Ha! You wish.\n" if $pureperl; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | say sprintf 'Creating new Build script for %s %s', $meta->name, $meta->version; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $self->write_file( 'Build', sprintf <<'', $^X, __PACKAGE__, __PACKAGE__ ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | #!%s | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | use lib 'builder'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | use %s; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | my $action = @ARGV && $ARGV[0] =~ /\A\w+\z/ ? shift @ARGV : 'build'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | my $opts = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | while ( @ARGV ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | my $a = shift @ARGV; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | if ( $a =~ /^-(\w+)$/ ) { $opts->{$1} = shift @ARGV // 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | elsif ( $a =~ /^-(\w+)=(.+)$/ ) { $opts->{$1} = $2; } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | %s->new( action => $action )->Build( %%$opts ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | make_executable('Build'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | my @env = defined $ENV{PERL_MB_OPT} ? split_like_shell( $ENV{PERL_MB_OPT} ) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $self->write_file( '_build_params', encode_json( [ \@env, \@ARGV ] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if ( my $dynamic = $meta->custom('x_dynamic_prereqs') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my %meta = ( %{ $meta->as_struct }, dynamic_config => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $self->get_arguments( \@env, \@ARGV ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | require CPAN::Requirements::Dynamic; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $dynamic_parser = CPAN::Requirements::Dynamic->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $prereq = $dynamic_parser->evaluate($dynamic); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $meta{prereqs} = $meta->effective_prereqs->with_merged_prereqs($prereq)->as_string_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $meta = CPAN::Meta->new( \%meta ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $meta->save(@$_) for ['MYMETA.json']; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | ▶ | sub find ( $pattern, $base ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | ▶ | $base = path($base) unless builtin::blessed $base; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | my $blah = $base->visit( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 60 | ▶ | sub ( $path, $state ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 60 | ▶ | $state->{$path} = $path if $path =~ $pattern; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | { recurse => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | values %$blah; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # infix builder | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | method step_clone_infix() { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
step_clone_infix: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | return if cwd->absolute->child('infix')->exists; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $clone_dir = cwd->absolute->child('infix'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | die 'Failed to clone infix' if system( 'git', 'clone', '--depth', '1', 'https://github.com/sanko/infix.git', $clone_dir->stringify ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | method step_infix () { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
step_infix: not called CC=27 SCAR=66.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $self->step_clone_infix(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $cwd = cwd->absolute; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my $infix_dir = $cwd->child('infix'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # Use architecture-specific directory to avoid collision on shared filesystems (WSL vs Windows) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $build_lib = $infix_dir->child( 'build_lib', $Config{archname} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | # If library already exists and is newer than source, we are good. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my $is_msvc = ( $Config{cc} =~ /cl(\.exe)?$/i ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | my $lib_ext = $is_msvc ? '.lib' : '.a'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | my $lib_pre = $is_msvc ? '' : 'lib'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my $lib_file = $build_lib->child( $lib_pre . 'infix' . $lib_ext ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my $src_file = $infix_dir->child( 'src', 'infix.c' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ( -e $lib_file && !$force ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $lib_file and not $force
MC/DC0%0/2
-e $lib_file and not $force
-e $lib_file
not $force
Truth table0%0/3
A and not(B)
A= -e $lib_fileB= not $force
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # Check timestamps to ensure we rebuild if source changed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if ( $src_file->stat->mtime <= $lib_file->stat->mtime ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | warn "Building infix static library for $Config{archname}..." if $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | $build_lib->mkpath unless -d $build_lib; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my @include_dirs = ( $infix_dir->child('include'), $infix_dir->child('src') ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # Detect Compiler settings using Perl's Config as base | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | my $cc_cmd = $Config{cc} || 'cc'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Affix::Builder::Config{'cc'} || 'cc'
MC/DC0%0/1
$Affix::Builder::Config{'cc'} || 'cc'
$Affix::Builder::Config{'cc'}
Truth table0%0/2
A
A= $Affix::Builder::Config{'cc'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $cc_type = 'gcc'; # Default flavor | |||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | if ( $cc_cmd =~ /cl(\.exe)?$/i ) { $cc_type = 'msvc'; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | elsif ( $cc_cmd =~ /clang/i ) { $cc_type = 'clang'; } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | elsif ( $cc_cmd =~ /gcc/i ) { $cc_type = 'gcc'; } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | elsif ( $cc_cmd =~ /egcc/i ) { $cc_type = 'gcc'; } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # Setup Flags | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my ( $ar_cmd, @cflags, @arflags, $out_flag_cc, $out_flag_ar ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | my @includes = map { ( $cc_type eq 'msvc' ? '/I' : '-I' ) . $_ } @include_dirs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if ( $cc_type eq 'msvc' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $ar_cmd = 'lib'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | @cflags = ( '/nologo', '/c', '/std:c11', '/W3', '/GS', '/MD', '/O2', @includes ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | @cflags = ( @cflags, '/DINFIX_DEBUG_ENABLED=1' ) if $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | @arflags = ('/nologo'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $out_flag_cc = '/Fo'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $out_flag_ar = '/OUT:'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # GCC / Clang | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $ar_cmd = 'ar'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | @cflags = ( '-std=c11', '-Wall', '-Wextra', '-O2', '-fPIC', @includes ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | @cflags = ( @cflags, '-DINFIX_DEBUG_ENABLED=1' ) if $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | @arflags = ('rcs'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $out_flag_cc = '-o'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $out_flag_ar = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # Pass pthread to compilation of static lib too (safe practice) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | push @cflags, '-pthread' unless $^O eq 'MSWin32'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | push @cflags, '-D__EXTENSIONS__', '-D_LARGEFILE64_SOURCE' if $^O =~ /(solaris|sunos)/i; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # Compile infix.c -> infix.o | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | my $obj_ext = $cc_type eq 'msvc' ? '.obj' : '.o'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my $obj_file = $build_lib->child( 'infix' . $obj_ext ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my @compile_cmd; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | if ( $cc_type eq 'msvc' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | @compile_cmd = ( $cc_cmd, @cflags, $out_flag_cc . $obj_file, $src_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | @compile_cmd = ( $cc_cmd, @cflags, '-c', $src_file, $out_flag_cc, $obj_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | warn " Compiling: @compile_cmd\n" if $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if ( system(@compile_cmd) != 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | die "Failed to compile infix.c"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # Archive infix.o -> libinfix.a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my @archive_cmd; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | if ( $cc_type eq 'msvc' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | @archive_cmd = ( $ar_cmd, @arflags, $out_flag_ar . $lib_file, $obj_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | @archive_cmd = ( $ar_cmd, @arflags, $lib_file, $obj_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | warn " Archiving: @archive_cmd\n" if $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if ( system(@archive_cmd) != 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | die "Failed to create infix static library"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | warn "Infix library built: $lib_file\n" if $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | # Detects if linking against librt is required (common on Linux/BSD/Solaris for shm_open) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | method check_for_lrt() { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_for_lrt: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | return '' if $^O eq 'MSWin32' || $^O eq 'android'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O eq "MSWin32" or $^O eq "android"
MC/DC0%0/2
$^O eq "MSWin32" or $^O eq "android"
$^O eq "MSWin32"
$^O eq "android"
Truth table0%0/3
A or B
A= $^O eq "MSWin32"B= $^O eq "android"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | warn "Checking if -lrt is required...\n" if $verbose; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | my $cc = $Config{cc} || 'cc'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Affix::Builder::Config{'cc'} || 'cc'
MC/DC0%0/1
$Affix::Builder::Config{'cc'} || 'cc'
$Affix::Builder::Config{'cc'}
Truth table0%0/2
A
A= $Affix::Builder::Config{'cc'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my $test_code = <<'END_C'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | #include <sys/mman.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | #include <fcntl.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | int main(void) { shm_open("/test", O_RDONLY, 0); return 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | END_C | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my ( $fh, $src ) = tempfile( SUFFIX => '.c', UNLINK => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | print $fh $test_code; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my ( $ofh, $out ) = tempfile( UNLINK => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | close $ofh; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # Try without -lrt (list-form system to avoid shell injection) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | open( my $devnull, '>', '/dev/null' ) if $^O ne 'MSWin32'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | my $old_stdout = select $devnull if $devnull; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | system( $cc, '-o', $out, $src ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | select $old_stdout if $old_stdout; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | close $devnull if $devnull; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | return '' if $? == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # Try with -lrt | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | open( $devnull, '>', '/dev/null' ) if $^O ne 'MSWin32'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | $old_stdout = select $devnull if $devnull; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | system( $cc, '-o', $out, $src, '-lrt' ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | select $old_stdout if $old_stdout; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | close $devnull if $devnull; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | return '-lrt' if $? == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | sub command_exists { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command_exists: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | my ($cmd) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | if ( $Config{osname} eq 'MSWin32' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | return system( 'where', $cmd ) == 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | return system( 'command', '-v', $cmd ) == 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | method step_affix { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
step_affix: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | $self->step_infix; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my $cwd = cwd->absolute; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my @objs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | require ExtUtils::CBuilder; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my %config = %Config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | # ExtUtils::CBuilder only uses $Config{ccflags} and silently drops | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # ccflags_uselargefiles, which Configure keeps separate on Solaris/ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # illumos (and a few other platforms). Without those defines the system | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # headers do not expose off64_t, sigjmp_buf, alloca or fileno, so the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | # same source that perl itself builds fails to compile here. Merge them | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # in (harmless duplication when ccflags already contains them). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $config{ccflags} = join ' ', grep {length} $config{ccflags}, $config{ccflags_uselargefiles}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | if ($debug) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | $config{ldflags} =~ s/-s //g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $config{ldflags} =~ s/ -s//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $config{lddlflags} =~ s/-s //g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $config{lddlflags} =~ s/ -s//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my $builder = ExtUtils::CBuilder->new( quiet => !$verbose, config => \%config ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my $pre = $cwd->child(qw[blib arch auto])->absolute; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | require DynaLoader; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | my $mod2fname = defined &DynaLoader::mod2fname ? \&DynaLoader::mod2fname : sub { return $_[0][-1] }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my @parts = ('Affix'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my $archdir = rel2abs catdir( curdir, qw[. blib arch auto], @parts ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my $err; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | make_path( $archdir, { chmod => 0755, error => \$err, verbose => $verbose } ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | my $lib_file = catfile( $archdir, $mod2fname->( \@parts ) . '.' . $Config{dlext} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my @dirs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | push @dirs, '../'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | my $has_cxx = !1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | my $recompiled = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my @sources = $cwd->child('lib/Affix.c'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | #~ warn "Sources to process: @sources\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | for my $source (@sources) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | #~ warn "Processing source: $source\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my $cxx = $source =~ /cx+$/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my $file_base = $source->basename(qr[.c$]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | my $tempdir = path('lib'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $tempdir->mkdir( { verbose => $verbose, mode => oct '755' } ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | my $version = $meta->version; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | my $obj = $builder->object_file($source); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | #~ warn "Checking obj: $obj\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | # Check mtimes of all .c and .h files under lib/ (includes Affix.c, marshal.c, Affix.h) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $newest_dep = $source->stat->mtime; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | my $iter = path('lib')->iterator; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | while ( my $entry = $iter->() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | next unless $entry->is_file; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | next unless $entry =~ /\.[ch]$/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $dep_mtime = $entry->stat->mtime; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | $newest_dep = $dep_mtime if $dep_mtime > $newest_dep; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | my $should_compile | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$force || !(-f $obj) || $newest_dep >= path($obj)->stat->mtime || path(__FILE__)->stat->mtime > path($obj)->stat->mtime
$force or not -f $obj or $newest_dep >= path($obj)->stat->mtime
$force or not -f $obj
MC/DC0%0/4
$force || !(-f $obj) || $newest_dep >= path($obj)->stat->mtime || path(__FILE__)->stat->mtime > path($obj)->stat->mtime
$force
not -f $obj
$newest_dep >= path($obj)->stat->mtime
path(__FILE__)->stat->mtime > path($obj)->stat->mtime
Truth table0%0/5
A or not(B) or C || D
A= $forceB= not -f $objC= $newest_dep >= path($obj)->stat->mtimeD= path(__FILE__)->stat->mtime > path($obj)->stat->mtime
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | = ( $force || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | ( !-f $obj ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | ( $newest_dep >= path($obj)->stat->mtime ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | ( path(__FILE__)->stat->mtime > path($obj)->stat->mtime ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | if ($should_compile) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | my $reason | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | = !-f $obj ? 'object file missing' : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | $newest_dep >= path($obj)->stat->mtime ? 'source newer than object' : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | path(__FILE__)->stat->mtime > path($obj)->stat->mtime ? 'builder changed' : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 'forced'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | warn "Compiling $source ($reason)\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | $recompiled = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | push @dirs, $source->dirname(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | $has_cxx = 1 if $cxx; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | push @objs, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | $should_compile ? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | $builder->compile( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | quiet => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 'C++' => $cxx, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | source => $source->stringify, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | defines => { VERSION => qq/"$version"/, XS_VERSION => qq/"$version"/ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | include_dirs => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | cwd->stringify, cwd->child('infix')->realpath->stringify, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | cwd->child('infix')->child('include')->realpath->stringify, cwd->child('infix')->child('src')->realpath->stringify, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | $source->dirname, $pre->child( $meta->name, 'include' )->stringify | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | extra_compiler_flags => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | ( '-fPIC -std=' . ( $cxx ? $cppver : $cver ) . ' ' . $cflags . ( $debug ? ' -ggdb3 -g -Wall -Wextra -pedantic' : '' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | $obj; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | # Point to the Architecture-specific build lib | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my $infix_build_lib = cwd->absolute->child('infix')->child( 'build_lib', $Config{archname} )->stringify; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | # Check for -lrt requirement | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my $lrt_flag = $self->check_for_lrt(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | my $data = { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | # Removed incorrect -lstdc++ logic. Added -lm for math. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | # -pthread is already in $ldflags via ADJUST | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | extra_linker_flags => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | [ split( ' ', $ldflags ), "-L$infix_build_lib", '-linfix', ( $lrt_flag ? ( split( ' ', $lrt_flag ) ) : () ), '-lm' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | objects => [@objs], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | lib_file => $lib_file, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | module_name => join '::', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | @parts | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | warn "Linking $lib_file\n" if $recompiled; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | return $builder->link(%$data); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||