File Coverage

inc/ILCPPConfig/CompilerGuess.pm
Criterion Covered Total %
statement 30 34 88.2
branch 3 8 37.5
condition 2 6 33.3
subroutine 7 7 100.0
pod 0 1 0.0
total 42 56 75.0


line stmt bran cond sub pod time code
1             package ILCPPConfig::CompilerGuess;
2              
3 1     1   75047 use strict;
  1         13  
  1         28  
4 1     1   6 use warnings;
  1         1  
  1         33  
5 1     1   446 use ExtUtils::CppGuess;
  1         31838  
  1         37  
6 1     1   7 use Exporter;
  1         2  
  1         42  
7 1     1   6 use Config;
  1         3  
  1         353  
8              
9             our @ISA = 'Exporter';
10             our @EXPORT_OK = 'guess_compiler';
11             our $VERSION = '0.01';
12              
13             # Repackage results from ExtUtils::CppGuess into a form that is most useful
14             # to Inline::CPP's Makefile.PL.
15              
16             sub guess_compiler {
17              
18 1     1 0 6 my( $cc_guess, $libs_guess, $guesser, %configuration );
19              
20 1 50 33     9 if( $Config::Config{osname} eq 'freebsd'
      33        
21             && $Config::Config{osvers} =~ /^(\d+)/
22             && $1 >= 10
23             ){
24 0         0 $cc_guess = 'clang++';
25 0         0 $libs_guess = '-lc++';
26             }
27             else {
28 1         8 $guesser = ExtUtils::CppGuess->new;
29 1         51 %configuration = $guesser->module_build_options;
30 1 50       33378 if( $guesser->is_gcc ) {
    0          
31 1 50       56 if( $Config{cc} eq 'clang' ) {
32 0         0 $cc_guess = 'clang++';
33             } else {
34 1         10 $cc_guess = 'g++';
35             }
36             }
37             elsif ( $guesser->is_msvc ) {
38 0         0 $cc_guess = 'cl';
39             }
40              
41 1         19 $cc_guess .= $configuration{extra_compiler_flags};
42 1         11 $libs_guess = $configuration{extra_linker_flags};
43              
44             ( $cc_guess, $libs_guess )
45 1         6 = map { _trim_whitespace($_) } ( $cc_guess, $libs_guess );
  2         18  
46             }
47 1         62 return ( $cc_guess, $libs_guess );
48             }
49              
50             sub _trim_whitespace {
51 2     2   22 my $string = shift;
52 2         31 $string =~ s/^\s+|\s+$//g;
53 2         9 return $string;
54             }
55              
56             1;