| 1 | package Module::Build::My; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use base 'Module::Build'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Config; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | sub new { | ||||||||||
| 13 | 0 | ▶ | my ($class, @args) = @_; | ||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||
| 14 | 0 | my $self = $class->SUPER::new(@args); | |||||||||
| 15 | 0 | ▶ | $self->config(cc => $ENV{CC}) if defined $ENV{CC}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 0 | ▶ | $self->config(ld => $ENV{LD}) if defined $ENV{LD}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 0 | ▶ | $self->config(lddl => $ENV{LD}) if defined $ENV{LD}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 0 | ▶ | $self->extra_compiler_flags(grep { $_ ne '' } split /\s/, $ENV{CFLAGS}) if defined $ENV{CFLAGS}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 0 | ▶ | $self->extra_linker_flags( grep { $_ ne '' } split /\s/, $ENV{LDFLAGS}) if defined $ENV{LDFLAGS}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | return $self; | |||||||||
| 21 | }; | ||||||||||
| 22 | |||||||||||
| 23 | sub ACTION_xs_config { | ||||||||||
| 24 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
ACTION_xs_config: called CC=10 SCAR=40.8
Pod
undocumented
| |||||||||||
| 25 | 1 | ▶ | return if $self->args('pp'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | |||||||||||
| 27 | 1 | my $config_h = 'xs/xs_config.h'; | |||||||||
| 28 | 1 | $self->add_to_cleanup($config_h); | |||||||||
| 29 | |||||||||||
| 30 | 1 | ▶ | return if $self->up_to_date('Build', $config_h); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | |||||||||||
| 32 | 0 | require ExtUtils::CChecker; | |||||||||
| 33 | 0 | my $chk = ExtUtils::CChecker->new( | |||||||||
| 34 | defines_to => $config_h, | ||||||||||
| 35 | ); | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | $chk->define('HAVE_MKTIME 1') if $Config{d_mktime}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | ▶ | $chk->define('HAVE_TM_GMTOFF 1') if $Config{d_tm_tm_gmtoff}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | ▶ | $chk->define('HAVE_TM_ZONE 1') if $Config{d_tm_tm_zone}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | ▶ | $chk->define('HAVE_TZNAME 1') if $Config{d_tzname}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | |||||||||||
| 42 | 0 | foreach my $kw (qw( __restrict __restrict__ _Restrict restrict )) { | |||||||||
| 43 | 0 | ▶ | last if $chk->try_compile_run( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | define => "restrict $kw", | ||||||||||
| 45 | source => << "EOF" ); | ||||||||||
| 46 | typedef int * int_ptr; | ||||||||||
| 47 | int foo (int_ptr $kw ip) { | ||||||||||
| 48 | return ip[0]; | ||||||||||
| 49 | } | ||||||||||
| 50 | int | ||||||||||
| 51 | main () | ||||||||||
| 52 | { | ||||||||||
| 53 | int s[1]; | ||||||||||
| 54 | int * $kw t = s; | ||||||||||
| 55 | t[0] = 0; | ||||||||||
| 56 | return foo(t); | ||||||||||
| 57 | return 0; | ||||||||||
| 58 | } | ||||||||||
| 59 | EOF | ||||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | $chk->try_compile_run( | ||||||||||
| 63 | 0 | define => 'HAVE_DECL_TZNAME 1', | |||||||||
| 64 | source => << "EOF" ); | ||||||||||
| 65 | #include <time.h> | ||||||||||
| 66 | int main () { | ||||||||||
| 67 | #ifndef tzname | ||||||||||
| 68 | (void) tzname; | ||||||||||
| 69 | #endif | ||||||||||
| 70 | return 0; | ||||||||||
| 71 | } | ||||||||||
| 72 | EOF | ||||||||||
| 73 | |||||||||||
| 74 | 0 | foreach my $m (qw( E O 1 )) { | |||||||||
| 75 | 0 | $chk->try_compile_run( | |||||||||
| 76 | define => "HAVE_STRFTIME_${m}_MODIFIER 1", | ||||||||||
| 77 | source => << "EOF" ); | ||||||||||
| 78 | #include <time.h> | ||||||||||
| 79 | #include <stdio.h> | ||||||||||
| 80 | #include <stdlib.h> | ||||||||||
| 81 | #include <string.h> | ||||||||||
| 82 | |||||||||||
| 83 | int | ||||||||||
| 84 | main() | ||||||||||
| 85 | { | ||||||||||
| 86 | char outstr[200]; | ||||||||||
| 87 | time_t t; | ||||||||||
| 88 | struct tm *tmp; | ||||||||||
| 89 | |||||||||||
| 90 | t = time(NULL); | ||||||||||
| 91 | tmp = localtime(&t); | ||||||||||
| 92 | if (tmp == NULL) | ||||||||||
| 93 | exit(1); | ||||||||||
| 94 | if (strftime(outstr, sizeof(outstr), "%${m}y", tmp) == 0) | ||||||||||
| 95 | exit(1); | ||||||||||
| 96 | if (strncmp(outstr, "%${m}y", 4) == 0 || strncmp(outstr, "y", 4) == 0) | ||||||||||
| 97 | exit(1); | ||||||||||
| 98 | return 0; | ||||||||||
| 99 | } | ||||||||||
| 100 | EOF | ||||||||||
| 101 | }; | ||||||||||
| 102 | |||||||||||
| 103 | 0 | $chk->try_compile_run( | |||||||||
| 104 | define => 'HAVE_STDBOOL_H 1', | ||||||||||
| 105 | source => << "EOF" ); | ||||||||||
| 106 | #include <stdbool.h> | ||||||||||
| 107 | int main () { | ||||||||||
| 108 | return false; | ||||||||||
| 109 | } | ||||||||||
| 110 | EOF | ||||||||||
| 111 | |||||||||||
| 112 | 0 | $chk->try_compile_run( | |||||||||
| 113 | define => 'HAVE__BOOL 1', | ||||||||||
| 114 | source => << "EOF" ); | ||||||||||
| 115 | int main () { | ||||||||||
| 116 | _Bool b = 0; | ||||||||||
| 117 | return b; | ||||||||||
| 118 | } | ||||||||||
| 119 | EOF | ||||||||||
| 120 | |||||||||||
| 121 | 0 | return 1; | |||||||||
| 122 | }; | ||||||||||
| 123 | |||||||||||
| 124 | sub ACTION_gnulib { | ||||||||||
| 125 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
ACTION_gnulib: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||
| 126 | 1 | ▶ | return if $self->args('pp'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 127 | |||||||||||
| 128 | 1 | $self->depends_on('xs_config'); | |||||||||
| 129 | |||||||||||
| 130 | 1 | ▶ | if (my $o = $self->cbuilder->object_file(my $c = 'xs/time_r.c')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 131 | 1 | $self->add_to_cleanup($o); | |||||||||
| 132 | 1 | ▶ | $self->cbuilder->compile(source => $c, object_file => $o, include_dirs => ['xs'], extra_compiler_flags => $self->extra_compiler_flags) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 133 | unless $self->up_to_date($c, $o); | ||||||||||
| 134 | 1 | push @{$self->{properties}{objects}}, $o; | |||||||||
| 135 | } | ||||||||||
| 136 | |||||||||||
| 137 | 1 | ▶ | if (my $o = $self->cbuilder->object_file(my $c = 'xs/gnu_strftime.c')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 138 | 1 | $self->add_to_cleanup($o); | |||||||||
| 139 | 1 | ▶ | $self->cbuilder->compile(source => $c, object_file => $o, include_dirs => ['xs'], extra_compiler_flags => $self->extra_compiler_flags) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 140 | unless $self->up_to_date($c, $o); | ||||||||||
| 141 | 1 | push @{$self->{properties}{objects}}, $o; | |||||||||
| 142 | } | ||||||||||
| 143 | |||||||||||
| 144 | 1 | return 1; | |||||||||
| 145 | }; | ||||||||||
| 146 | |||||||||||
| 147 | sub ACTION_code { | ||||||||||
| 148 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
ACTION_code: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 149 | 1 | $self->depends_on('gnulib'); | |||||||||
| 150 | 1 | return $self->SUPER::ACTION_code(@_); | |||||||||
| 151 | }; | ||||||||||
| 152 | |||||||||||
| 153 | sub ACTION_test_core { | ||||||||||
| 154 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
ACTION_test_core: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 155 | 0 | $self->log_info("Testing CORE (ignoring results)\n"); | |||||||||
| 156 | 0 | $ENV{PERL_POSIX_STRFTIME_GNU_XS} = 0; | |||||||||
| 157 | 0 | $ENV{PERL_POSIX_STRFTIME_GNU_PP} = 0; | |||||||||
| 158 | 0 | return eval { $self->SUPER::ACTION_test(@_) }; | |||||||||
| 159 | }; | ||||||||||
| 160 | |||||||||||
| 161 | sub ACTION_test_pp { | ||||||||||
| 162 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
ACTION_test_pp: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 163 | 1 | $self->log_info("Testing PP\n"); | |||||||||
| 164 | 1 | $ENV{PERL_POSIX_STRFTIME_GNU_XS} = 0; | |||||||||
| 165 | 1 | $ENV{PERL_POSIX_STRFTIME_GNU_PP} = 1; | |||||||||
| 166 | 1 | return $self->SUPER::ACTION_test(@_); | |||||||||
| 167 | }; | ||||||||||
| 168 | |||||||||||
| 169 | sub ACTION_test_xs { | ||||||||||
| 170 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
ACTION_test_xs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 171 | 1 | $self->log_info("Testing XS\n"); | |||||||||
| 172 | 1 | $ENV{PERL_POSIX_STRFTIME_GNU_XS} = 1; | |||||||||
| 173 | 1 | $ENV{PERL_POSIX_STRFTIME_GNU_PP} = 0; | |||||||||
| 174 | 1 | return $self->SUPER::ACTION_test(@_); | |||||||||
| 175 | }; | ||||||||||
| 176 | |||||||||||
| 177 | sub ACTION_test { | ||||||||||
| 178 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
ACTION_test: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||
| 179 | 1 | ▶ | $self->depends_on('test_core') if $ENV{TEST_CORE}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 180 | 1 | ▶ | $self->depends_on('test_xs') unless $self->args('pp'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 181 | 1 | $self->depends_on('test_pp'); | |||||||||
| 182 | }; | ||||||||||
| 183 | |||||||||||
| 184 | 1 | 1; | |||||||||