| 1 | # Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||||||||||||||||||||||
| 2 | # contributor license agreements. See the NOTICE file distributed with | ||||||||||||||||||||||||||||
| 3 | # this work for additional information regarding copyright ownership. | ||||||||||||||||||||||||||||
| 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 | ||||||||||||||||||||||||||||
| 5 | # (the "License"); you may not use this file except in compliance with | ||||||||||||||||||||||||||||
| 6 | # the License. You may obtain a copy of the License at | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||
| 13 | # See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||
| 14 | # limitations under the License. | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | package Clownfish::CFC::Perl::Build; | ||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use base qw( Module::Build ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | our $VERSION = '0.008000'; | |||||||||||||||||||||||||||
| 22 | 1 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use File::Spec::Functions qw( catdir catfile curdir updir abs2rel rel2abs ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use File::Path qw( mkpath ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # Add a custom Module::Build hashref property to pass additional build | ||||||||||||||||||||||||||||
| 30 | # parameters | ||||||||||||||||||||||||||||
| 31 | 1 | ▶ | if ( $Module::Build::VERSION <= 0.30 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 0 | __PACKAGE__->add_property( clownfish_params => {} ); | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | else { | ||||||||||||||||||||||||||||
| 35 | # TODO: add sub for property check | ||||||||||||||||||||||||||||
| 36 | 1 | __PACKAGE__->add_property( | |||||||||||||||||||||||||||
| 37 | 'clownfish_params', | ||||||||||||||||||||||||||||
| 38 | default => {}, | ||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # Rationale | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # When the distribution tarball for the Perl bindings is built, core/, and any | ||||||||||||||||||||||||||||
| 45 | # other needed files/directories are copied into the perl/ directory within the | ||||||||||||||||||||||||||||
| 46 | # main source directory. Then the distro is built from the contents of the | ||||||||||||||||||||||||||||
| 47 | # perl/ directory, leaving out all the files in ruby/, etc. However, during | ||||||||||||||||||||||||||||
| 48 | # development, the files are accessed from their original locations. | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 1 | ▶ | my $IS_CPAN_DIST = -d 'core' || -d 'cfcore'; | ||||||||||||||||||||||||||
|
Condition33%1/3
-d 'core' || -d 'cfcore'
MC/DC0%0/2
-d 'core' || -d 'cfcore'
-d 'core'
-d 'cfcore'
Truth table33%1/3
A || B
A= -d 'core'B= -d 'cfcore'
| |||||||||||||||||||||||||||||
| 51 | 1 | my @BASE_PATH; | |||||||||||||||||||||||||||
| 52 | 1 | ▶ | push(@BASE_PATH, updir()) unless $IS_CPAN_DIST; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 1 | my $AUTOGEN_DIR = 'autogen'; | |||||||||||||||||||||||||||
| 55 | 1 | my $LIB_DIR = 'lib'; | |||||||||||||||||||||||||||
| 56 | 1 | my $BUILDLIB_DIR = 'buildlib'; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 59 | 0 | my $self = shift->SUPER::new( @_ ); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | # TODO: use Charmonizer to determine whether pthreads are userland. | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ( $Config{osname} =~ /openbsd/i && $Config{usethreads} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Clownfish::CFC::Perl::Build::Config{"osname"} =~ /openbsd/i and $Clownfish::CFC::Perl::Build::Config{"usethreads"}
MC/DC0%0/2
$Clownfish::CFC::Perl::Build::Config{"osname"} =~ /openbsd/i and $Clownfish::CFC::Perl::Build::Config{"usethreads"}
$Clownfish::CFC::Perl::Build::Config{"osname"} =~ /openbsd/i
$Clownfish::CFC::Perl::Build::Config{"usethreads"}
Truth table0%0/3
A and B
A= $Clownfish::CFC::Perl::Build::Config{"osname"} =~ /openbsd/iB= $Clownfish::CFC::Perl::Build::Config{"usethreads"}
| |||||||||||||||||||||||||||||
| 63 | 0 | my $extra_ldflags = $self->extra_linker_flags; | |||||||||||||||||||||||||||
| 64 | 0 | push @$extra_ldflags, '-lpthread'; | |||||||||||||||||||||||||||
| 65 | 0 | $self->extra_linker_flags(@$extra_ldflags); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | my $autogen_header = $self->clownfish_params('autogen_header'); | |||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ( !defined($autogen_header) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | $self->clownfish_params( autogen_header => <<'END_AUTOGEN' ); | |||||||||||||||||||||||||||
| 71 | *********************************************** | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | !!!! DO NOT EDIT !!!! | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | This file was auto-generated by Build.PL. | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | *********************************************** | ||||||||||||||||||||||||||||
| 78 | END_AUTOGEN | ||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | return $self; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | # Return the list of Clownfish include dirs. Uses directories from | ||||||||||||||||||||||||||||
| 85 | # - Module::Build parameter | ||||||||||||||||||||||||||||
| 86 | # - Environment variable CLOWNFISH_INCLUDE | ||||||||||||||||||||||||||||
| 87 | # - Clownfish include directories found in @INC | ||||||||||||||||||||||||||||
| 88 | # Note that this function must be called at build time because dependencies | ||||||||||||||||||||||||||||
| 89 | # might not be installed yet at configure time. | ||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub cf_include_dirs { | ||||||||||||||||||||||||||
|
Subroutine
cf_include_dirs: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | my $cf_include = $self->clownfish_params('include'); | |||||||||||||||||||||||||||
| 94 | 0 | my @dirs; | |||||||||||||||||||||||||||
| 95 | 0 | ▶ | @dirs = ref($cf_include) ? @$cf_include : ( $cf_include ) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 96 | if defined($cf_include); | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | # Add include dirs from CLOWNFISH_INCLUDE environment variable. | ||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ($ENV{CLOWNFISH_INCLUDE}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 0 | push( @dirs, split( /:/, $ENV{CLOWNFISH_INCLUDE} ) ); | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | # Add include dirs from @INC. | ||||||||||||||||||||||||||||
| 104 | 0 | for my $dir (@INC) { | |||||||||||||||||||||||||||
| 105 | 0 | my $cf_incdir = catdir( $dir, 'Clownfish', '_include' ); | |||||||||||||||||||||||||||
| 106 | 0 | ▶ | push( @dirs, $cf_incdir ) if -d $cf_incdir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | return @dirs; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | # Return the list of Clownfish C include dirs. | ||||||||||||||||||||||||||||
| 113 | # Note that this function must be called at build time because dependencies | ||||||||||||||||||||||||||||
| 114 | # might not be installed yet at configure time. | ||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub cf_c_include_dirs { | ||||||||||||||||||||||||||
|
Subroutine
cf_c_include_dirs: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 116 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | my $include_dirs = $self->include_dirs; | |||||||||||||||||||||||||||
| 119 | 0 | my @dirs; | |||||||||||||||||||||||||||
| 120 | 0 | ▶ | @dirs = ref($include_dirs) ? @$include_dirs : ( $include_dirs ) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 121 | if defined($include_dirs); | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 0 | push( @dirs, | |||||||||||||||||||||||||||
| 124 | curdir(), # for ppport.h | ||||||||||||||||||||||||||||
| 125 | catdir( $AUTOGEN_DIR, 'include' ), | ||||||||||||||||||||||||||||
| 126 | $self->cf_include_dirs, | ||||||||||||||||||||||||||||
| 127 | ); | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | return @dirs; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub cf_base_path { | ||||||||||||||||||||||||||
|
Subroutine
cf_base_path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 133 | 0 | my $self_or_class = shift; | |||||||||||||||||||||||||||
| 134 | 0 | return @BASE_PATH; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub cf_linker_flags { | ||||||||||||||||||||||||||
|
Subroutine
cf_linker_flags: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 138 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | my $dlext = $Config{dlext}; | |||||||||||||||||||||||||||
| 141 | # Only needed on Windows | ||||||||||||||||||||||||||||
| 142 | 0 | ▶ | return () if $dlext !~ /dll$/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | # Link against import library on MSVC | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | my $ext = $Config{cc} =~ /^cl\b/ ? 'lib' : $dlext; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 0 | my @linker_flags; | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | for my $module_name (@_) { | |||||||||||||||||||||||||||
| 150 | # Find library to link against | ||||||||||||||||||||||||||||
| 151 | 0 | my @module_parts = split( '::', $module_name ); | |||||||||||||||||||||||||||
| 152 | 0 | my $class_name = $module_parts[-1]; | |||||||||||||||||||||||||||
| 153 | 0 | my $lib_file; | |||||||||||||||||||||||||||
| 154 | my $found; | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 0 | for my $dir ( catdir( $self->blib, 'arch' ), @INC ) { | |||||||||||||||||||||||||||
| 157 | 0 | $lib_file = catfile( | |||||||||||||||||||||||||||
| 158 | $dir, 'auto', @module_parts, "$class_name.$ext", | ||||||||||||||||||||||||||||
| 159 | ); | ||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if ( -f $lib_file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 0 | $found = 1; | |||||||||||||||||||||||||||
| 162 | 0 | last; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 0 | ▶ | die("No Clownfish library file found for module $module_name") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | if !$found; | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | push( @linker_flags, $lib_file ); | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | return @linker_flags; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub _cfh_filepaths { | ||||||||||||||||||||||||||
|
Subroutine
_cfh_filepaths: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 176 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 177 | 0 | my @paths; | |||||||||||||||||||||||||||
| 178 | 0 | my $source_dirs = $self->clownfish_params('source'); | |||||||||||||||||||||||||||
| 179 | 0 | for my $source_dir (@$source_dirs) { | |||||||||||||||||||||||||||
| 180 | 0 | ▶ | next unless -e $source_dir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 0 | push @paths, @{ $self->rscan_dir( $source_dir, qr/\.cf[hp]$/ ) }; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | 0 | return \@paths; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub cf_copy_include_file { | ||||||||||||||||||||||||||
|
Subroutine
cf_copy_include_file: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 187 | 0 | my ($self, @path) = @_; | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 0 | my $dest_dir = catdir( $self->blib, 'arch', 'Clownfish', '_include' ); | |||||||||||||||||||||||||||
| 190 | 0 | for my $include_dir ($self->cf_c_include_dirs) { | |||||||||||||||||||||||||||
| 191 | 0 | my $file = catfile ( $include_dir, @path ); | |||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ( -e $file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 0 | $self->copy_if_modified( | |||||||||||||||||||||||||||
| 194 | from => $file, | ||||||||||||||||||||||||||||
| 195 | to => catfile( $dest_dir, @path ), | ||||||||||||||||||||||||||||
| 196 | ); | ||||||||||||||||||||||||||||
| 197 | 0 | return; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | 0 | die( "Clownfish include file " . catfile(@path) . " not found" ); | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 1 | my %hierarchy_cache; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub _compile_clownfish { | ||||||||||||||||||||||||||
|
Subroutine
_compile_clownfish: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 206 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | require Clownfish::CFC::Model::Hierarchy; | |||||||||||||||||||||||||||
| 209 | 0 | require Clownfish::CFC::Binding::Perl; | |||||||||||||||||||||||||||
| 210 | 0 | require Clownfish::CFC::Binding::Perl::Class; | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 0 | ▶ | return @hierarchy_cache{ qw( hierarchy binding ) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | if %hierarchy_cache; | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | # Compile Clownfish. | ||||||||||||||||||||||||||||
| 216 | 0 | my $hierarchy = Clownfish::CFC::Model::Hierarchy->new( | |||||||||||||||||||||||||||
| 217 | dest => $AUTOGEN_DIR, | ||||||||||||||||||||||||||||
| 218 | ); | ||||||||||||||||||||||||||||
| 219 | 0 | my $source_dirs = $self->clownfish_params('source'); | |||||||||||||||||||||||||||
| 220 | 0 | for my $source_dir (@$source_dirs) { | |||||||||||||||||||||||||||
| 221 | 0 | $hierarchy->add_source_dir($source_dir); | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | 0 | for my $include_dir ($self->cf_include_dirs) { | |||||||||||||||||||||||||||
| 224 | 0 | $hierarchy->add_include_dir($include_dir); | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | 0 | $hierarchy->build; | |||||||||||||||||||||||||||
| 227 | 0 | $hierarchy->read_host_data_json; | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | # Process all Binding classes in buildlib. | ||||||||||||||||||||||||||||
| 230 | 0 | local @INC = ( @INC, '.' ); | |||||||||||||||||||||||||||
| 231 | 0 | my $pm_filepaths = $self->rscan_dir( $BUILDLIB_DIR, qr/\.pm$/ ); | |||||||||||||||||||||||||||
| 232 | 0 | for my $pm_filepath (@$pm_filepaths) { | |||||||||||||||||||||||||||
| 233 | 0 | ▶ | next unless $pm_filepath =~ /Binding/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 0 | require $pm_filepath; | |||||||||||||||||||||||||||
| 235 | 0 | my $package_name = $pm_filepath; | |||||||||||||||||||||||||||
| 236 | 0 | $package_name =~ s/buildlib\/(.*)\.pm$/$1/; | |||||||||||||||||||||||||||
| 237 | 0 | $package_name =~ s/\//::/g; | |||||||||||||||||||||||||||
| 238 | 0 | $package_name->bind_all($hierarchy); | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | my $binding = Clownfish::CFC::Binding::Perl->new( | |||||||||||||||||||||||||||
| 242 | hierarchy => $hierarchy, | ||||||||||||||||||||||||||||
| 243 | lib_dir => $LIB_DIR, | ||||||||||||||||||||||||||||
| 244 | header => $self->clownfish_params('autogen_header'), | ||||||||||||||||||||||||||||
| 245 | footer => '', | ||||||||||||||||||||||||||||
| 246 | ); | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | @hierarchy_cache{ qw( hierarchy binding ) } = ( $hierarchy, $binding ); | |||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 0 | return ( $hierarchy, $binding ); | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | # Deprecated. | ||||||||||||||||||||||||||||
| 254 | 0 | ▶ | sub ACTION_pod { | ||||||||||||||||||||||||||
|
Subroutine
ACTION_pod: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 255 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 256 | 0 | $self->depends_on('clownfish'); | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub ACTION_clownfish { | ||||||||||||||||||||||||||
|
Subroutine
ACTION_clownfish: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 260 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | $self->add_to_cleanup($AUTOGEN_DIR); | |||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 0 | my $modules = $self->clownfish_params('modules'); | |||||||||||||||||||||||||||
| 265 | 0 | my @xs_filepaths; | |||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | for my $module (@$modules) { | |||||||||||||||||||||||||||
| 268 | 0 | my @module_dir = split( '::', $module->{name} ); | |||||||||||||||||||||||||||
| 269 | 0 | my $class_name = pop(@module_dir); | |||||||||||||||||||||||||||
| 270 | 0 | push @xs_filepaths, catfile( $LIB_DIR, @module_dir, "$class_name.xs" ); | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 0 | my $buildlib_pm_filepaths = $self->rscan_dir( $BUILDLIB_DIR, qr/\.pm$/ ); | |||||||||||||||||||||||||||
| 274 | 0 | my $cfh_filepaths = $self->_cfh_filepaths; | |||||||||||||||||||||||||||
| 275 | 0 | my $log_filepath = catfile( $AUTOGEN_DIR, 'hierarchy.json' ); | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | # Don't bother parsing Clownfish files if everything's up to date. | ||||||||||||||||||||||||||||
| 278 | return | ||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if $self->up_to_date( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | [ @$cfh_filepaths, @$buildlib_pm_filepaths ], | ||||||||||||||||||||||||||||
| 281 | [ @xs_filepaths, $log_filepath, ] | ||||||||||||||||||||||||||||
| 282 | ); | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | # Write out all autogenerated files. | ||||||||||||||||||||||||||||
| 285 | 0 | print "Parsing Clownfish files...\n"; | |||||||||||||||||||||||||||
| 286 | 0 | my ( $hierarchy, $perl_binding ) = $self->_compile_clownfish; | |||||||||||||||||||||||||||
| 287 | 0 | require Clownfish::CFC::Binding::Core; | |||||||||||||||||||||||||||
| 288 | 0 | my $core_binding = Clownfish::CFC::Binding::Core->new( | |||||||||||||||||||||||||||
| 289 | hierarchy => $hierarchy, | ||||||||||||||||||||||||||||
| 290 | header => $self->clownfish_params('autogen_header'), | ||||||||||||||||||||||||||||
| 291 | footer => '', | ||||||||||||||||||||||||||||
| 292 | ); | ||||||||||||||||||||||||||||
| 293 | 0 | print "Writing Clownfish autogenerated files...\n"; | |||||||||||||||||||||||||||
| 294 | 0 | my $inc_dir = catdir( $self->blib, 'arch', 'Clownfish', '_include' ); | |||||||||||||||||||||||||||
| 295 | 0 | my $cfh_modified = $core_binding->write_all_modified; | |||||||||||||||||||||||||||
| 296 | 0 | ▶ | if ($cfh_modified) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 297 | 0 | unlink('typemap'); | |||||||||||||||||||||||||||
| 298 | 0 | print "Writing typemap...\n"; | |||||||||||||||||||||||||||
| 299 | 0 | $self->add_to_cleanup('typemap'); | |||||||||||||||||||||||||||
| 300 | 0 | $perl_binding->write_xs_typemap; | |||||||||||||||||||||||||||
| 301 | 0 | $core_binding->copy_headers($inc_dir); | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | # Rewrite XS if either any .cfh files or relevant .pm files were modified. | ||||||||||||||||||||||||||||
| 305 | 0 | my $buildlib_modified = ! $self->up_to_date( | |||||||||||||||||||||||||||
| 306 | \@$buildlib_pm_filepaths, [ @xs_filepaths, $log_filepath ] | ||||||||||||||||||||||||||||
| 307 | ); | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if ( $cfh_modified || $buildlib_modified ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$cfh_modified or $buildlib_modified
MC/DC0%0/2
$cfh_modified or $buildlib_modified
$cfh_modified
$buildlib_modified
Truth table0%0/3
A or B
A= $cfh_modifiedB= $buildlib_modified
| |||||||||||||||||||||||||||||
| 310 | 0 | $self->add_to_cleanup(@xs_filepaths); | |||||||||||||||||||||||||||
| 311 | 0 | $perl_binding->write_host_code; | |||||||||||||||||||||||||||
| 312 | 0 | $perl_binding->write_hostdefs; | |||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 0 | for my $module (@$modules) { | |||||||||||||||||||||||||||
| 315 | $perl_binding->write_bindings( | ||||||||||||||||||||||||||||
| 316 | boot_class => $module->{name}, | ||||||||||||||||||||||||||||
| 317 | parcels => $module->{parcels}, | ||||||||||||||||||||||||||||
| 318 | 0 | ); | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 0 | $core_binding->write_host_data_json($inc_dir); | |||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 0 | ▶ | unless ($IS_CPAN_DIST) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | 0 | print "Writing POD...\n"; | |||||||||||||||||||||||||||
| 325 | 0 | my $pod_files = $perl_binding->write_pod; | |||||||||||||||||||||||||||
| 326 | 0 | $self->add_to_cleanup($_) for @$pod_files; | |||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | # Touch autogenerated files in case the modifications were inconsequential | ||||||||||||||||||||||||||||
| 331 | # and didn't trigger a rewrite, so that we won't have to check them again | ||||||||||||||||||||||||||||
| 332 | # next pass. | ||||||||||||||||||||||||||||
| 333 | 0 | for my $xs_filepath (@xs_filepaths) { | |||||||||||||||||||||||||||
| 334 | 0 | ▶ | if (!$self->up_to_date( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 335 | [ @$cfh_filepaths, @$buildlib_pm_filepaths ], $xs_filepath | ||||||||||||||||||||||||||||
| 336 | ) | ||||||||||||||||||||||||||||
| 337 | ) | ||||||||||||||||||||||||||||
| 338 | { | ||||||||||||||||||||||||||||
| 339 | 0 | utime( time, time, $xs_filepath ); # touch | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 0 | $hierarchy->write_log; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | # Write ppport.h, which supplies some XS routines not found in older Perls and | ||||||||||||||||||||||||||||
| 347 | # allows us to use more up-to-date XS API while still supporting Perls back to | ||||||||||||||||||||||||||||
| 348 | # 5.8.3. | ||||||||||||||||||||||||||||
| 349 | # | ||||||||||||||||||||||||||||
| 350 | # The Devel::PPPort docs recommend that we distribute ppport.h rather than | ||||||||||||||||||||||||||||
| 351 | # require Devel::PPPort itself, but ppport.h isn't compatible with the Apache | ||||||||||||||||||||||||||||
| 352 | # license. | ||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub ACTION_ppport { | ||||||||||||||||||||||||||
|
Subroutine
ACTION_ppport: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 354 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 355 | 0 | ▶ | if ( !-e 'ppport.h' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 356 | 0 | require Devel::PPPort; | |||||||||||||||||||||||||||
| 357 | 0 | $self->add_to_cleanup('ppport.h'); | |||||||||||||||||||||||||||
| 358 | 0 | Devel::PPPort::WriteFile(); | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 0 | ▶ | sub ACTION_compile_custom_xs { | ||||||||||||||||||||||||||
|
Subroutine
ACTION_compile_custom_xs: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 363 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 0 | $self->depends_on('ppport'); | |||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | # Make sure all parcels are read and registered. | ||||||||||||||||||||||||||||
| 368 | 0 | $self->_compile_clownfish(); | |||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | 0 | my $modules = $self->clownfish_params('modules'); | |||||||||||||||||||||||||||
| 371 | 0 | for my $module (@$modules) { | |||||||||||||||||||||||||||
| 372 | 0 | $self->_compile_custom_xs($module); | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 0 | ▶ | sub _compile_custom_xs { | ||||||||||||||||||||||||||
|
Subroutine
_compile_custom_xs: not called CC=19 SCAR=59.4
| |||||||||||||||||||||||||||||
| 377 | 0 | my ( $self, $module ) = @_; | |||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 0 | require ExtUtils::CBuilder; | |||||||||||||||||||||||||||
| 380 | 0 | require ExtUtils::ParseXS; | |||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 0 | my $module_name = $module->{name}; | |||||||||||||||||||||||||||
| 383 | 0 | my @module_parts = split( '::', $module_name ); | |||||||||||||||||||||||||||
| 384 | 0 | my @module_dir = @module_parts; | |||||||||||||||||||||||||||
| 385 | 0 | my $class_name = pop(@module_dir); | |||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 0 | my $cbuilder = ExtUtils::CBuilder->new( config => $self->config ); | |||||||||||||||||||||||||||
| 388 | 0 | my $libdir = catdir( $LIB_DIR, @module_dir ); | |||||||||||||||||||||||||||
| 389 | 0 | my $archdir = catdir( $self->blib, 'arch', 'auto', @module_parts ); | |||||||||||||||||||||||||||
| 390 | 0 | ▶ | mkpath( $archdir, 0, 0777 ) unless -d $archdir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 391 | 0 | my @objects; | |||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | # Make objects. | ||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if ($module->{make_target}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 395 | 0 | my $make_objects = $self->cf_make_objects($module->{make_target}); | |||||||||||||||||||||||||||
| 396 | 0 | push @objects, @$make_objects; | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | # Compile C source files. | ||||||||||||||||||||||||||||
| 400 | 0 | my $c_files = []; | |||||||||||||||||||||||||||
| 401 | 0 | ▶ | my $source_dirs = $module->{c_source_dirs} || []; | ||||||||||||||||||||||||||
|
Condition0%0/2
$module->{'c_source_dirs'} || []
MC/DC0%0/1
$module->{'c_source_dirs'} || []
$module->{'c_source_dirs'}
Truth table0%0/2
A
A= $module->{'c_source_dirs'}
| |||||||||||||||||||||||||||||
| 402 | 0 | for my $source_dir (@$source_dirs) { | |||||||||||||||||||||||||||
| 403 | 0 | push @$c_files, @{ $self->rscan_dir( $source_dir, qr/\.c$/ ) }; | |||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | 0 | my $autogen_src_dir = catdir( $AUTOGEN_DIR, 'source' ); | |||||||||||||||||||||||||||
| 406 | 0 | for my $parcel_name ( @{ $module->{parcels} } ) { | |||||||||||||||||||||||||||
| 407 | 0 | my $parcel = Clownfish::CFC::Model::Parcel->acquire($parcel_name); | |||||||||||||||||||||||||||
| 408 | 0 | my $prefix = $parcel->get_prefix; | |||||||||||||||||||||||||||
| 409 | # Assume *_parcel.c is built with make. | ||||||||||||||||||||||||||||
| 410 | push @$c_files, catfile( $autogen_src_dir, "${prefix}parcel.c" ) | ||||||||||||||||||||||||||||
| 411 | 0 | ▶ | if !$module->{make_target}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 412 | 0 | push @$c_files, catfile( $autogen_src_dir, "${prefix}perl.c" ); | |||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | 0 | my $extra_cflags = $self->clownfish_params('cflags'); | |||||||||||||||||||||||||||
| 415 | 0 | ▶ | if ( $ENV{CFISH_EXTRA_CFLAGS} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 416 | 0 | $extra_cflags = "$extra_cflags $ENV{CFISH_EXTRA_CFLAGS}"; | |||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | 0 | for my $c_file (@$c_files) { | |||||||||||||||||||||||||||
| 419 | 0 | my $o_file = $c_file; | |||||||||||||||||||||||||||
| 420 | 0 | my $ccs_file = $c_file; | |||||||||||||||||||||||||||
| 421 | 0 | ▶ | $o_file =~ s/\.c$/$Config{_o}/ or die "no match"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 422 | 0 | ▶ | $ccs_file =~ s/\.c$/.ccs/ or die "no match"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 423 | 0 | push @objects, $o_file; | |||||||||||||||||||||||||||
| 424 | 0 | ▶ | next if $self->up_to_date( $c_file, $o_file ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 425 | 0 | $self->add_to_cleanup($o_file); | |||||||||||||||||||||||||||
| 426 | 0 | $self->add_to_cleanup($ccs_file); | |||||||||||||||||||||||||||
| 427 | 0 | $cbuilder->compile( | |||||||||||||||||||||||||||
| 428 | source => $c_file, | ||||||||||||||||||||||||||||
| 429 | extra_compiler_flags => $extra_cflags, | ||||||||||||||||||||||||||||
| 430 | include_dirs => [ $self->cf_c_include_dirs ], | ||||||||||||||||||||||||||||
| 431 | object_file => $o_file, | ||||||||||||||||||||||||||||
| 432 | ); | ||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | # .xs => .c | ||||||||||||||||||||||||||||
| 436 | 0 | my $xs_filepath = catfile( $libdir, "$class_name.xs" ); | |||||||||||||||||||||||||||
| 437 | 0 | my $perl_binding_c_file = catfile( $libdir, "$class_name.c" ); | |||||||||||||||||||||||||||
| 438 | 0 | $self->add_to_cleanup($perl_binding_c_file); | |||||||||||||||||||||||||||
| 439 | 0 | ▶ | if ( !$self->up_to_date( $xs_filepath, $perl_binding_c_file ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 440 | 0 | ExtUtils::ParseXS::process_file( | |||||||||||||||||||||||||||
| 441 | filename => $xs_filepath, | ||||||||||||||||||||||||||||
| 442 | prototypes => 0, | ||||||||||||||||||||||||||||
| 443 | output => $perl_binding_c_file, | ||||||||||||||||||||||||||||
| 444 | ); | ||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | # .c => .o | ||||||||||||||||||||||||||||
| 448 | 0 | my $version = $self->dist_version; | |||||||||||||||||||||||||||
| 449 | 0 | my $perl_binding_o_file = catfile( $libdir, "$class_name$Config{_o}" ); | |||||||||||||||||||||||||||
| 450 | 0 | unshift @objects, $perl_binding_o_file; | |||||||||||||||||||||||||||
| 451 | 0 | $self->add_to_cleanup($perl_binding_o_file); | |||||||||||||||||||||||||||
| 452 | 0 | ▶ | if ( !$self->up_to_date( $perl_binding_c_file, $perl_binding_o_file ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 453 | # Don't use Clownfish compiler flags for XS | ||||||||||||||||||||||||||||
| 454 | 0 | $cbuilder->compile( | |||||||||||||||||||||||||||
| 455 | source => $perl_binding_c_file, | ||||||||||||||||||||||||||||
| 456 | extra_compiler_flags => $self->extra_compiler_flags, | ||||||||||||||||||||||||||||
| 457 | include_dirs => [ $self->cf_c_include_dirs ], | ||||||||||||||||||||||||||||
| 458 | object_file => $perl_binding_o_file, | ||||||||||||||||||||||||||||
| 459 | # 'defines' is an undocumented parameter to compile(), so we | ||||||||||||||||||||||||||||
| 460 | # should officially roll our own variant and generate compiler | ||||||||||||||||||||||||||||
| 461 | # flags. However, that involves writing a bunch of | ||||||||||||||||||||||||||||
| 462 | # platform-dependent code, so we'll just take the chance that this | ||||||||||||||||||||||||||||
| 463 | # will break. | ||||||||||||||||||||||||||||
| 464 | defines => { | ||||||||||||||||||||||||||||
| 465 | VERSION => qq|"$version"|, | ||||||||||||||||||||||||||||
| 466 | XS_VERSION => qq|"$version"|, | ||||||||||||||||||||||||||||
| 467 | }, | ||||||||||||||||||||||||||||
| 468 | ); | ||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | # Create .bs bootstrap file, needed by Dynaloader. | ||||||||||||||||||||||||||||
| 472 | 0 | my $bs_file = catfile( $archdir, "$class_name.bs" ); | |||||||||||||||||||||||||||
| 473 | 0 | $self->add_to_cleanup($bs_file); | |||||||||||||||||||||||||||
| 474 | 0 | ▶ | if ( !$self->up_to_date( $perl_binding_o_file, $bs_file ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 475 | 0 | require ExtUtils::Mkbootstrap; | |||||||||||||||||||||||||||
| 476 | 0 | ExtUtils::Mkbootstrap::Mkbootstrap($bs_file); | |||||||||||||||||||||||||||
| 477 | 0 | ▶ | if ( !-f $bs_file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 478 | # Create file in case Mkbootstrap didn't do anything. | ||||||||||||||||||||||||||||
| 479 | 0 | ▶ | open( my $fh, '>', $bs_file ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 480 | or confess "Can't open $bs_file: $!"; | ||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | 0 | utime( (time) x 2, $bs_file ); # touch | |||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | # Clean up after CBuilder under MSVC. | ||||||||||||||||||||||||||||
| 486 | 0 | $self->add_to_cleanup('compilet*'); | |||||||||||||||||||||||||||
| 487 | 0 | $self->add_to_cleanup('*.ccs'); | |||||||||||||||||||||||||||
| 488 | 0 | $self->add_to_cleanup( catfile( $libdir, "$class_name.ccs" ) ); | |||||||||||||||||||||||||||
| 489 | 0 | $self->add_to_cleanup( catfile( $libdir, "$class_name.def" ) ); | |||||||||||||||||||||||||||
| 490 | 0 | $self->add_to_cleanup( catfile( $libdir, "${class_name}_def.old" ) ); | |||||||||||||||||||||||||||
| 491 | 0 | $self->add_to_cleanup( catfile( $libdir, "$class_name.exp" ) ); | |||||||||||||||||||||||||||
| 492 | 0 | $self->add_to_cleanup( catfile( $libdir, "$class_name.lib" ) ); | |||||||||||||||||||||||||||
| 493 | 0 | $self->add_to_cleanup( catfile( $libdir, "$class_name.lds" ) ); | |||||||||||||||||||||||||||
| 494 | 0 | $self->add_to_cleanup( catfile( $libdir, "$class_name.base" ) ); | |||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | # .o => .(a|bundle) | ||||||||||||||||||||||||||||
| 497 | 0 | my $lib_file = catfile( $archdir, "$class_name.$Config{dlext}" ); | |||||||||||||||||||||||||||
| 498 | 0 | ▶ | if ( !$self->up_to_date( [ @objects, $AUTOGEN_DIR ], $lib_file ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 499 | 0 | my $linker_flags = $self->extra_linker_flags; | |||||||||||||||||||||||||||
| 500 | 0 | my @xs_prereqs = $self->_cf_find_xs_prereqs($module); | |||||||||||||||||||||||||||
| 501 | 0 | push @$linker_flags, $self->cf_linker_flags(@xs_prereqs); | |||||||||||||||||||||||||||
| 502 | 0 | $cbuilder->link( | |||||||||||||||||||||||||||
| 503 | module_name => $module_name, | ||||||||||||||||||||||||||||
| 504 | objects => \@objects, | ||||||||||||||||||||||||||||
| 505 | lib_file => $lib_file, | ||||||||||||||||||||||||||||
| 506 | extra_linker_flags => $linker_flags, | ||||||||||||||||||||||||||||
| 507 | ); | ||||||||||||||||||||||||||||
| 508 | # Install .lib file on Windows | ||||||||||||||||||||||||||||
| 509 | # TODO: Install .dll.a when building with GCC on Windows? | ||||||||||||||||||||||||||||
| 510 | 0 | my $implib_file = catfile( $libdir, "$class_name.lib" ); | |||||||||||||||||||||||||||
| 511 | 0 | ▶ | if ( -e $implib_file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 512 | 0 | $self->copy_if_modified( | |||||||||||||||||||||||||||
| 513 | from => $implib_file, | ||||||||||||||||||||||||||||
| 514 | to => catfile( $archdir, "$class_name.lib" ), | ||||||||||||||||||||||||||||
| 515 | ); | ||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | 0 | ▶ | sub _cf_find_xs_prereqs { | ||||||||||||||||||||||||||
|
Subroutine
_cf_find_xs_prereqs: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||
| 521 | 0 | my ( $self, $module ) = @_; | |||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | 0 | my $modules = $self->clownfish_params('modules'); | |||||||||||||||||||||||||||
| 524 | 0 | my @xs_prereqs; | |||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | 0 | for my $parcel_name ( @{ $module->{parcels} } ) { | |||||||||||||||||||||||||||
| 527 | 0 | my $parcel = Clownfish::CFC::Model::Parcel->acquire($parcel_name); | |||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | 0 | for my $prereq_parcel ( @{ $parcel->prereq_parcels } ) { | |||||||||||||||||||||||||||
| 530 | 0 | my $prereq_module; | |||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | 0 | ▶ | if ($prereq_parcel->included) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 533 | 0 | $prereq_module = $prereq_parcel->get_xs_module; | |||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||
| 535 | else { | ||||||||||||||||||||||||||||
| 536 | 0 | my $prereq_parcel_name = $prereq_parcel->get_name; | |||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | 0 | for my $candidate (@$modules) { | |||||||||||||||||||||||||||
| 539 | my @matches = grep { | ||||||||||||||||||||||||||||
| 540 | 0 | $_ eq $prereq_parcel_name | |||||||||||||||||||||||||||
| 541 | 0 | } @{ $candidate->{parcels} }; | |||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | 0 | ▶ | if (@matches) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 544 | 0 | $prereq_module = $candidate->{name}; | |||||||||||||||||||||||||||
| 545 | 0 | last; | |||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | 0 | ▶ | die("No XS module found for parcel $parcel_name") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 551 | if !defined($prereq_module); | ||||||||||||||||||||||||||||
| 552 | push @xs_prereqs, $prereq_module | ||||||||||||||||||||||||||||
| 553 | if $prereq_module ne $module->{name} | ||||||||||||||||||||||||||||
| 554 | 0 | ▶ | && !grep { $_ eq $prereq_module } @xs_prereqs; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$prereq_module ne $module->{"name"} and not grep({$_ eq $prereq_module;} @xs_prereqs)
MC/DC0%0/2
$prereq_module ne $module->{"name"} and not grep({$_ eq $prereq_module;} @xs_prereqs)
$prereq_module ne $module->{"name"}
not grep({$_ eq $prereq_module;} @xs_prereqs)
Truth table0%0/3
A and not(B)
A= $prereq_module ne $module->{"name"}B= not grep({$_ eq $prereq_module;} @xs_prereqs)
| |||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | 0 | return @xs_prereqs; | |||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | 0 | ▶ | sub ACTION_code { | ||||||||||||||||||||||||||
|
Subroutine
ACTION_code: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 562 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | 0 | $self->depends_on(qw( | |||||||||||||||||||||||||||
| 565 | clownfish | ||||||||||||||||||||||||||||
| 566 | compile_custom_xs | ||||||||||||||||||||||||||||
| 567 | )); | ||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||
| 569 | 0 | $self->SUPER::ACTION_code; | |||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | 0 | ▶ | sub ACTION_clean { | ||||||||||||||||||||||||||
|
Subroutine
ACTION_clean: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 573 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | 0 | ▶ | if ( $self->can('cf_make_clean') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 576 | 0 | $self->cf_make_clean(); | |||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | 0 | $self->SUPER::ACTION_clean; | |||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||
| 582 | # Monkey patch ExtUtils::CBuilder::Platform::Windows::GCC::format_linker_cmd | ||||||||||||||||||||||||||||
| 583 | # to make extensions work on MinGW. | ||||||||||||||||||||||||||||
| 584 | # | ||||||||||||||||||||||||||||
| 585 | # nwellnhof: The original ExtUtils::CBuilder implementation uses dlltool and a | ||||||||||||||||||||||||||||
| 586 | # strange incremental linking scheme. I think this is only needed for ancient | ||||||||||||||||||||||||||||
| 587 | # versions of GNU ld. It somehow breaks exporting of symbols via | ||||||||||||||||||||||||||||
| 588 | # __declspec(dllexport). Starting with version 2.17, one can pass .def files | ||||||||||||||||||||||||||||
| 589 | # to GNU ld directly, which requires only a single command and gets the | ||||||||||||||||||||||||||||
| 590 | # exports right. | ||||||||||||||||||||||||||||
| 591 | { | ||||||||||||||||||||||||||||
| 592 | 1 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 593 | 1 | require ExtUtils::CBuilder::Platform::Windows::GCC; | |||||||||||||||||||||||||||
| 594 | 0 | ▶ | *ExtUtils::CBuilder::Platform::Windows::GCC::format_linker_cmd = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 595 | 0 | my ($self, %spec) = @_; | |||||||||||||||||||||||||||
| 596 | 0 | my $cf = $self->{config}; | |||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||
| 598 | # The Config.pm variable 'libperl' is hardcoded to the full name | ||||||||||||||||||||||||||||
| 599 | # of the perl import library (i.e. 'libperl56.a'). GCC will not | ||||||||||||||||||||||||||||
| 600 | # find it unless the 'lib' prefix & the extension are stripped. | ||||||||||||||||||||||||||||
| 601 | 0 | $spec{libperl} =~ s/^(?:lib)?([^.]+).*$/-l$1/; | |||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||
| 603 | 0 | unshift( @{$spec{other_ldflags}}, '-nostartfiles' ) | |||||||||||||||||||||||||||
| 604 | 0 | ▶ | if ( $spec{startup} && @{$spec{startup}} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$spec{"startup"} and @{$spec{"startup"};}
MC/DC0%0/2
$spec{"startup"} and @{$spec{"startup"};}
$spec{"startup"}
@{$spec{"startup"};}
Truth table0%0/3
A and B
A= $spec{"startup"}B= @{$spec{"startup"};}
| |||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||
| 606 | # From ExtUtils::MM_Win32: | ||||||||||||||||||||||||||||
| 607 | # | ||||||||||||||||||||||||||||
| 608 | ## one thing for GCC/Mingw32: | ||||||||||||||||||||||||||||
| 609 | ## we try to overcome non-relocateable-DLL problems by generating | ||||||||||||||||||||||||||||
| 610 | ## a (hopefully unique) image-base from the dll's name | ||||||||||||||||||||||||||||
| 611 | ## -- BKS, 10-19-1999 | ||||||||||||||||||||||||||||
| 612 | 0 | File::Basename::basename( $spec{output} ) =~ /(....)(.{0,4})/; | |||||||||||||||||||||||||||
| 613 | 0 | $spec{image_base} = sprintf( "0x%x0000", unpack('n', $1 ^ $2) ); | |||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||
| 615 | %spec = $self->write_linker_script(%spec) | ||||||||||||||||||||||||||||
| 616 | 0 | ▶ | if $spec{use_scripts}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | 0 | foreach my $path ( @{$spec{libpath}} ) { | |||||||||||||||||||||||||||
| 619 | 0 | $path = "-L$path"; | |||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | 0 | my @cmds; # Stores the series of commands needed to build the module. | |||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||
| 624 | # split off any -arguments included in ld | ||||||||||||||||||||||||||||
| 625 | 0 | my @ld = split / (?=-)/, $spec{ld}; | |||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||
| 627 | 0 | ▶ | push @cmds, [ grep {defined && length} ( | ||||||||||||||||||||||||||
|
Condition0%0/3
defined $_ && length $_
MC/DC0%0/2
defined $_ && length $_
defined $_
length $_
Truth table0%0/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||
| 628 | @ld , | ||||||||||||||||||||||||||||
| 629 | '-o', $spec{output} , | ||||||||||||||||||||||||||||
| 630 | "-Wl,--image-base,$spec{image_base}" , | ||||||||||||||||||||||||||||
| 631 | 0 | @{$spec{lddlflags}} , | |||||||||||||||||||||||||||
| 632 | 0 | @{$spec{libpath}} , | |||||||||||||||||||||||||||
| 633 | 0 | @{$spec{startup}} , | |||||||||||||||||||||||||||
| 634 | 0 | @{$spec{objects}} , | |||||||||||||||||||||||||||
| 635 | 0 | @{$spec{other_ldflags}} , | |||||||||||||||||||||||||||
| 636 | $spec{libperl} , | ||||||||||||||||||||||||||||
| 637 | 0 | ▶ | @{$spec{perllibs}} , | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 638 | $spec{def_file} , | ||||||||||||||||||||||||||||
| 639 | 0 | $spec{map_file} ? ('-Map', $spec{map_file}) : '' | |||||||||||||||||||||||||||
| 640 | ) ]; | ||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||
| 642 | 0 | return @cmds; | |||||||||||||||||||||||||||
| 643 | 1 | }; | |||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||
| 646 | 1 | 1; | |||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | __END__ | ||||||||||||||||||||||||||||