| 1 | package ExtUtils::CppGuess; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ExtUtils::CppGuess - guess C++ compiler and flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | With L<Extutils::MakeMaker>: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | use ExtUtils::CppGuess; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | my $guess = ExtUtils::CppGuess->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | WriteMakefile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ( # MakeMaker args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | $guess->makemaker_options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | With L<Module::Build>: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | my $guess = ExtUtils::CppGuess->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | my $build = Module::Build->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ( # Module::Build arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | $guess->module_build_options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | $build->create_build_script; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | C<ExtUtils::CppGuess> attempts to guess the system's C++ compiler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | that is compatible with the C compiler that your perl was built with. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | It can generate the necessary options to the L<Module::Build> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | constructor or to L<ExtUtils::MakeMaker>'s C<WriteMakefile> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | function. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | =head1 ENVIRONMENT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | As of 0.24, the environment variable C<CXX> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | defines the obvious value, and will be used instead of any detection. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | Supplied arguments to L</new> will still win. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | Creates a new C<ExtUtils::CppGuess> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | Takes the path to the C compiler as the C<cc> argument, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | but falls back to the value of C<$Config{cc}>, which should | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | be what you want anyway. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | You can specify C<extra_compiler_flags> and C<extra_linker_flags> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | (as strings) which will be merged in with the auto-detected ones. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | =head2 module_build_options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | Returns the correct options to the constructor of C<Module::Build>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | These are: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | extra_compiler_flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | extra_linker_flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | config => { cc => ... }, # as of 0.15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | Please note the above may have problems on Perl <= 5.8 with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | L<ExtUtils::CBuilder> <= 0.280230 due to a Perl RE issue. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | =head2 makemaker_options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | Returns the correct options to the C<WriteMakefile> function of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | C<ExtUtils::MakeMaker>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | These are: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | CCFLAGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | dynamic_lib => { OTHERLDFLAGS => ... } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | CC # as of 0.15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | If you specify the extra compiler or linker flags in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | constructor, they'll be merged into C<CCFLAGS> or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | C<OTHERLDFLAGS> respectively. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | =head2 is_gcc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | Returns true if the detected compiler is in the gcc family. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | =head2 is_msvc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | Returns true if the detected compiler is in the MS VC family. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | =head2 is_clang | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | Returns true if the detected compiler is in the Clang family. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | =head2 is_sunstudio | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | Returns true if the detected compiler is in the Sun Studio family. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | =head2 add_extra_compiler_flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | Takes a string as argument that is added to the string of extra compiler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | flags. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | =head2 add_extra_linker_flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | Takes a string as argument that is added to the string of extra linker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | flags. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | =head2 compiler_command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | Returns the string that can be passed to C<system> to execute the compiler. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | Will include the flags returned as the Module::Build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | C<extra_compiler_flags>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | Added in 0.13. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | =head2 linker_flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | The same as returned as the Module::Build C<extra_linker_flags>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | Added in 0.13. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | =head2 iostream_fname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | Returns the filename to C<#include> to get iostream capability. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | This can be used a bit creatively to be portable in one's XS files, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | as the tests for this module need to be: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # in Makefile.PL: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | $guess->add_extra_compiler_flags( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | '-DINCLUDE_DOT=' . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ($guess->iostream_fname =~ /\./ ? 1 : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | // in your .xs file: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | #if INCLUDE_DOT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | #include <string.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | #else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | #include <string> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | Added in 0.15. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | =head2 cpp_flavor_defs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | Returns the text for a header that C<#define>s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | C<__INLINE_CPP_STANDARD_HEADERS> and C<__INLINE_CPP_NAMESPACE_STD> if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | the standard headers and namespace are available. This is determined by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | trying to compile C++ with C<< #define <iostream> >> - if it succeeds, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | the symbols will be defined, else commented. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | Added in 0.15. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | =head2 cpp_standard_flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | $guess->cpp_standard_flag( $standard_name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | Given a string C<$standard_name> that is currently one of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | =item * C<< C++98 >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | =item * C<< C++11 >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | =item * C<< C++14 >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | =item * C<< C++17 >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | =item * C<< C++20 >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | =item * C<< C++23 >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | returns a string with a flag that can be used to tell the compiler to support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | that version of the C++ standard or dies if version is not supported. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | Added in version v0.22. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | Mattia Barbon <mbarbon@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | Steffen Mueller <smueller@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | Tobias Leich <froggs@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | Copyright 2010, 2011 by Mattia Barbon. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 6 | ▶ | use Config (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 6 | ▶ | use File::Basename qw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 6 | ▶ | use Capture::Tiny 'capture_merged'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 6 | ▶ | use File::Spec::Functions qw(catfile); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 6 | ▶ | use File::Temp qw(tempdir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 6 | our $VERSION = '0.271'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 17 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 17 | my( $class, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 17 | my $self = bless \%args, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # Allow override of default %Config::Config; useful in testing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 17 | ▶ | if( !defined $self->{config} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 5 | ▶ | if ($ExtUtils::MakeMaker::Config::VERSION) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # tricksy hobbitses are overriding Config, go with it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | $self->{config} = \%ExtUtils::MakeMaker::Config::Config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 4 | $self->{config} = \%Config::Config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 17 | for (['cc','cc',$Config::Config{cc}], ['os','osname',$^O], ['osvers','osvers','']) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 51 | my ($key, $confkey, $fallback) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 51 | ▶ | next if defined $self->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | $self->{$key} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 28 | ▶ | defined $self->{config}{$confkey} ? $self->{config}{$confkey} : $fallback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 17 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # Thus saith the law: All references to %Config::Config shall come through | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # $self->_config. Accessors shall provide access to key components thereof. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # Testing shall thus grow stronger, verifying performance for platforms diverse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # to which access we have not. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 46 | ▶ | sub _config { shift->{config} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_config: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 17 | ▶ | sub _cc { shift->{cc} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cc: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 18 | ▶ | sub _os { shift->{os} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_os: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub _osvers { shift->{osvers} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_osvers: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 6 | our %ENV2VAL = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | CXX => 'compiler_command', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # This is IBM's "how to compile on" list with lots of compilers: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # https://www.ibm.com/support/knowledgecenter/en/SS4PJT_5.2.0/com.ibm.help.cd52.unix.doc/com.ibm.help.cdunix_user.doc/CDU_Compiling_Custom_Programs.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 149 | ▶ | sub guess_compiler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
guess_compiler: called CC=16 SCAR=28.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 149 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 149 | ▶ | return $self->{guess} if $self->{guess}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 17 | my $c_compiler = $self->_cc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # $c_compiler = $Config::Config{cc} if not defined $c_compiler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 17 | my %guess; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 17 | ▶ | if ($self->{os} eq 'freebsd' && $self->{osvers} =~ /^(\d+)/ && $1 >= 10) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition83%5/6
$self->{"os"} eq "freebsd" and $self->{"osvers"} =~ /^(\d+)/ and $1 >= 10
$self->{"os"} eq "freebsd" and $self->{"osvers"} =~ /^(\d+)/
MC/DC66%2/3
$self->{"os"} eq "freebsd" and $self->{"osvers"} =~ /^(\d+)/ and $1 >= 10
$self->{"os"} eq "freebsd"
$self->{"osvers"} =~ /^(\d+)/
$1 >= 10
Truth table75%3/4
A and B and C
A= $self->{"os"} eq "freebsd"B= $self->{"osvers"} =~ /^(\d+)/C= $1 >= 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | $self->{is_clang} = 1; # special-case override | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | %guess = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | compiler_command => 'clang++', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | extra_lflags => '-lc++', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } elsif( $self->_cc_is_sunstudio( $c_compiler ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 1 | %guess = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | compiler_command => 'CC', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | extra_cflags => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | extra_lflags => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } elsif( $self->_cc_is_clang( $c_compiler ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 3 | %guess = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | compiler_command => 'clang++', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | extra_cflags => '-xc++', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | extra_lflags => '-lstdc++', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } elsif( $self->_cc_is_gcc( $c_compiler ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 11 | %guess = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | compiler_command => 'g++', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | extra_cflags => '-xc++', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # Don't use -lstdc++ if Perl was linked with -static-libstdc++ (ActivePerl 5.18+ on Windows) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | $guess{extra_lflags} = '-lstdc++' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 11 | ▶ | unless ($self->_config->{ldflags} || '') =~ /static-libstdc\+\+/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->_config->{'ldflags'} || ''
MC/DC100%1/1
$self->_config->{'ldflags'} || ''
$self->_config->{'ldflags'}
Truth table100%2/2
A
A= $self->_config->{'ldflags'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } elsif ( $self->_cc_is_msvc( $c_compiler ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1 | %guess = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | compiler_command => 'cl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | extra_cflags => '-TP -EHsc', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | extra_lflags => 'msvcprt.lib', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 17 | $guess{$ENV2VAL{$_}} = $ENV{$_} for grep defined $ENV{$_}, keys %ENV2VAL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 17 | ▶ | if (!%guess) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my $v1 = `$c_compiler -v`; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $v2 = `$c_compiler -V`; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $v3 = `$c_compiler --version`; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $os = $self->_os; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | die <<EOF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | Unable to determine a C++ compiler for '$c_compiler' on $os | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | Version attempts: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | -v: '$v1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | -V: '$v2' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | --version: '$v3' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | $guess{extra_lflags} .= ' -lgcc_s' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | if $self->_os eq 'netbsd' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | $guess{compiler_command} =~ /g\+\+/i and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 17 | ▶ | $guess{extra_lflags} !~ /-lgcc_s/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->_os eq "netbsd" and $guess{"compiler_command"} =~ /g\+\+/i and not $guess{"extra_lflags"} =~ /-lgcc_s/
$self->_os eq "netbsd" and $guess{"compiler_command"} =~ /g\+\+/i
MC/DC33%1/3
$self->_os eq "netbsd" and $guess{"compiler_command"} =~ /g\+\+/i and not $guess{"extra_lflags"} =~ /-lgcc_s/
$self->_os eq "netbsd"
$guess{"compiler_command"} =~ /g\+\+/i
not $guess{"extra_lflags"} =~ /-lgcc_s/
Truth table50%2/4
A and B and not(C)
A= $self->_os eq "netbsd"B= $guess{"compiler_command"} =~ /g\+\+/iC= not $guess{"extra_lflags"} =~ /-lgcc_s/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 17 | $self->{guess} = \%guess; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 24 | ▶ | sub _get_cflags { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_cflags: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 24 | my ($self, $omit_ccflags) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 24 | ▶ | $self->guess_compiler or die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | join ' ', '', map _trim_whitespace($_), grep defined && length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | ($omit_ccflags ? '' : $self->_config->{ccflags}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | $self->{guess}{extra_cflags}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | $self->{extra_compiler_flags}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 24 | ▶ | ($self->is_clang ? '-Wno-reserved-user-defined-literal' : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $_ && length $_
MC/DC100%2/2
defined $_ && length $_
defined $_
length $_
Truth table100%3/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 18 | ▶ | sub _get_lflags { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_lflags: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 18 | ▶ | $self->guess_compiler || die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | join ' ', '', map _trim_whitespace($_), grep defined && length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | $self->{guess}{extra_lflags}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | $self->{extra_linker_flags}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 18 | ▶ | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $_ && length $_
MC/DC100%2/2
defined $_ && length $_
defined $_
length $_
Truth table100%3/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 3 | ▶ | sub makemaker_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makemaker_options: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 3 | my $lflags = $self->_get_lflags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 3 | my $cflags = $self->_get_cflags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | CCFLAGS => $cflags, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | dynamic_lib => { OTHERLDFLAGS => $lflags }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | CC => $self->{guess}{compiler_command}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 2 | ▶ | sub module_build_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
module_build_options: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 2 | my $lflags = $self->_get_lflags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # We're omitting ccflags to avoid duplication of flags, because unlike | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # makemaker, we're appending to the compiler flags, not overriding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # them. They already contain $Config{ccflags}. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 2 | my $cflags = $self->_get_cflags(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | extra_compiler_flags => $cflags, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | extra_linker_flags => $lflags, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | config => { cc => $self->{guess}{compiler_command} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # originally from Alien::wxWidgets::Utility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | # Why was this hanging around outside of all functions, and without any other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | # use of $quotes? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # my $quotes = $self->_os =~ /MSWin32/ ? '"' : "'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 46 | ▶ | sub _capture { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_capture: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 46 | my @cmd = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 46 | ▶ | my $out = capture_merged { system(@cmd) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 46 | ▶ | $out = '' if not defined $out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 46 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # capture the output of a command that is run with piping | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # to stdin of the command. We immediately close the pipe. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 6 | ▶ | sub _capture_empty_stdin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_capture_empty_stdin: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 6 | my $cmd = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 6 | ▶ | my $out = capture_merged { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 6 | ▶ | if ( open my $fh, '|-', $cmd ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 5 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 6 | ▶ | $out = '' if not defined $out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 6 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 1 | ▶ | sub _cc_is_msvc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cc_is_msvc: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | my( $self, $cc ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | $self->{is_msvc} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 1 | ▶ | = ($self->_os =~ /MSWin32/ and File::Basename::basename($cc) =~ /^cl/i); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->_os =~ /MSWin32/ && File::Basename::basename($cc) =~ /^cl/i
MC/DC0%0/2
$self->_os =~ /MSWin32/ && File::Basename::basename($cc) =~ /^cl/i
$self->_os =~ /MSWin32/
File::Basename::basename($cc) =~ /^cl/i
Truth table33%1/3
A && B
A= $self->_os =~ /MSWin32/B= File::Basename::basename($cc) =~ /^cl/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 1 | return $self->{is_msvc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 12 | ▶ | sub _cc_is_gcc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cc_is_gcc: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 12 | my( $self, $cc ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 12 | $self->{is_gcc} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 12 | my $cc_version = _capture( "$cc --version" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 12 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$cc_version =~ /\bg(?:cc|\+\+)/i or scalar _capture("$cc") =~ /\bgcc\b/i or scalar _capture_empty_stdin("$cc -dM -E -") =~ /__GNUC__/ or scalar $cc_version =~ /\bcc\b.*Free Software Foundation/is or $cc eq "gcc"
$cc_version =~ /\bg(?:cc|\+\+)/i or scalar _capture("$cc") =~ /\bgcc\b/i or scalar _capture_empty_stdin("$cc -dM -E -") =~ /__GNUC__/ or scalar $cc_version =~ /\bcc\b.*Free Software Foundation/is
$cc_version =~ /\bg(?:cc|\+\+)/i or scalar _capture("$cc") =~ /\bgcc\b/i or scalar _capture_empty_stdin("$cc -dM -E -") =~ /__GNUC__/
$cc_version =~ /\bg(?:cc|\+\+)/i or scalar _capture("$cc") =~ /\bgcc\b/i
MC/DC50%1/2
$cc_version =~ /\bg(?:cc|\+\+)/i or scalar _capture("$cc") =~ /\bgcc\b/i or scalar _capture_empty_stdin("$cc -dM -E -") =~ /__GNUC__/ or scalar $cc_version =~ /\bcc\b.*Free Software Foundation/is or $cc eq "gcc"
$cc_version =~ /\bg(?:cc|\+\+)/i
$cc eq "gcc"
Truth table66%2/3
A or B
A= $cc_version =~ /\bg(?:cc|\+\+)/iB= $cc eq "gcc"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | $cc_version =~ m/\bg(?:cc|\+\+)/i # 3.x, some 4.x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | || scalar( _capture( "$cc" ) =~ m/\bgcc\b/i ) # 2.95 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | || scalar(_capture_empty_stdin("$cc -dM -E -") =~ /__GNUC__/) # more or less universal? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | || scalar($cc_version =~ m/\bcc\b.*Free Software Foundation/si) # some 4.x? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | || $cc eq 'gcc' # because why would they lie? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 11 | $self->{is_gcc} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 12 | return $self->{is_gcc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 15 | ▶ | sub _cc_is_clang { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cc_is_clang: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 15 | my( $self, $cc ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 15 | $self->{is_clang} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 15 | my $cc_version = _capture( "$cc --version" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 15 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition87%7/8
$cc_version =~ /\A(?:(?:\S+ )?clang version|apple llvm)/i or $cc eq "clang" or ($self->_config->{"gccversion"} || "") =~ /Clang|Apple LLVM/
$cc_version =~ /\A(?:(?:\S+ )?clang version|apple llvm)/i or $cc eq "clang"
$self->_config->{'gccversion'} || ''
MC/DC100%3/3
$cc_version =~ /\A(?:(?:\S+ )?clang version|apple llvm)/i or $cc eq "clang" or ($self->_config->{"gccversion"} || "") =~ /Clang|Apple LLVM/
$cc_version =~ /\A(?:(?:\S+ )?clang version|apple llvm)/i
$cc eq "clang"
$self->_config->{'gccversion'}
Truth table100%4/4
A or B or C
A= $cc_version =~ /\A(?:(?:\S+ )?clang version|apple llvm)/iB= $cc eq "clang"C= $self->_config->{'gccversion'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | $cc_version =~ m/\A(?:(?:\S+ )?clang version|apple llvm)/i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | || $cc eq 'clang' # because why would they lie? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | || (($self->_config->{gccversion} || '') =~ /Clang|Apple LLVM/), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 3 | $self->{is_clang} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 15 | return $self->{is_clang}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 16 | ▶ | sub _cc_is_sunstudio { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cc_is_sunstudio: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 16 | my( $self, $cc ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 16 | $self->{is_sunstudio} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 16 | my $cc_version = _capture( "$cc -V" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 16 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cc_version =~ /Sun C/i or $cc =~ /SUNWspro/
MC/DC50%1/2
$cc_version =~ /Sun C/i or $cc =~ /SUNWspro/
$cc_version =~ /Sun C/i
$cc =~ /SUNWspro/
Truth table66%2/3
A or B
A= $cc_version =~ /Sun C/iB= $cc =~ /SUNWspro/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | $cc_version =~ m/Sun C/i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | || $cc =~ /SUNWspro/ # because why would they lie? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | $self->{is_sunstudio} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 16 | return $self->{is_sunstudio}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 14 | ▶ | sub is_gcc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_gcc: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 14 | ▶ | $self->guess_compiler || die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 14 | return $self->{is_gcc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 18 | ▶ | sub is_msvc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_msvc: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 18 | ▶ | $self->guess_compiler || die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 18 | return $self->{is_msvc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 37 | ▶ | sub is_clang { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_clang: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 37 | ▶ | $self->guess_compiler || die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 37 | return $self->{is_clang}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 13 | ▶ | sub is_sunstudio { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_sunstudio: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 13 | ▶ | $self->guess_compiler || die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 13 | return $self->{is_sunstudio}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 2 | ▶ | sub add_extra_compiler_flags { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_extra_compiler_flags: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 2 | my( $self, $string ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | $self->{extra_compiler_flags} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | = join ' ', map _trim_whitespace($_), grep defined && length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 2 | ▶ | $self->{extra_compiler_flags}, $string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $_ && length $_
MC/DC50%1/2
defined $_ && length $_
defined $_
length $_
Truth table66%2/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | sub add_extra_linker_flags { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_extra_linker_flags: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my( $self, $string ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | $self->{extra_linker_flags} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | = join ' ', map _trim_whitespace($_), grep defined && length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | $self->{extra_linker_flags}, $string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $_ && length $_
MC/DC0%0/2
defined $_ && length $_
defined $_
length $_
Truth table0%0/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 19 | ▶ | sub compiler_command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compiler_command: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 19 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 19 | ▶ | $self->guess_compiler || die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 19 | my $cc = $self->{guess}{compiler_command}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 19 | my $cflags = $self->_get_cflags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 19 | ▶ | join ' ', map _trim_whitespace($_), grep defined && length, $cc, $cflags; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $_ && length $_
MC/DC50%1/2
defined $_ && length $_
defined $_
length $_
Truth table66%2/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 106 | ▶ | sub _trim_whitespace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trim_whitespace: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 106 | my $string = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 106 | $string =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 106 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 13 | ▶ | sub linker_flags { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
linker_flags: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 13 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 13 | _trim_whitespace($self->_get_lflags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 5 | ▶ | sub _to_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_to_file: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 5 | my ($file, @data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 5 | ▶ | open my $fh, '>', $file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | or die "open $file: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 5 | ▶ | print $fh @data or die "write $file: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 5 | ▶ | close $fh or die "close $file: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 6 | my $test_cpp_filename = 'ilcpptest'; # '.cpp' appended via open. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 6 | my $test_cpp = <<'END_TEST_CPP'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | #include <iostream> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | int main(){ return 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | END_TEST_CPP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # Compile the given code and returns true on success. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # Can optionally be given compiler flags. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 5 | ▶ | sub _can_compile_code { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_can_compile_code: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 5 | my( $self, $cpp_code, $compiler_flags ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 5 | my $dir = tempdir( CLEANUP => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 5 | my $file = catfile( $dir, qq{$test_cpp_filename.cpp} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 5 | my $exe = catfile( $dir, qq{$test_cpp_filename.exe} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 5 | _to_file $file, $cpp_code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | my $command = join ' ', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | $self->compiler_command, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 5 | ▶ | @{ defined $compiler_flags ? $compiler_flags : [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | ($self->is_msvc ? qq{-Fe:} : qq{-o }) . $exe, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 5 | return 0 == system $command; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # returns true if compile succeeded, false if failed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 4 | ▶ | sub _compile_no_h { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compile_no_h: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 4 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 4 | ▶ | return $self->{no_h_status} if defined $self->{no_h_status}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 3 | ▶ | $self->guess_compiler || die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 3 | $self->{no_h_status} = $self->_can_compile_code( $test_cpp ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 3 | ▶ | sub iostream_fname { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iostream_fname: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 3 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 3 | ▶ | 'iostream' . ($self->_compile_no_h ? '' : '.h'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 1 | ▶ | sub cpp_flavor_defs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpp_flavor_defs: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 1 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 1 | ▶ | my $comment = ($self->_compile_no_h ? '' : '//'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 1 | sprintf <<'END_FLAVOR_DEFINITIONS', $comment, $comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | %s#define __INLINE_CPP_STANDARD_HEADERS 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | %s#define __INLINE_CPP_NAMESPACE_STD 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | END_FLAVOR_DEFINITIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | # Listed in order by year. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 6 | our @CPP_STANDARDS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 'C++98', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 'C++11', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 'C++14', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 'C++17', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | # Hash of flags for each compiler: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # Structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | # Hash: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # - key: <detected compiler name string> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # - value: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # Hash: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | # - key: <C++ standard name string> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # - value: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | # ArrayRef[Str] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # <list of alternative flags, in preferred order> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 6 | our $CPP_STANDARD_FLAGS = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | is_gcc => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 'C++98' => [ "-std=c++98" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 'C++11' => [ "-std=c++11", "-std=c++0x" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 'C++14' => [ "-std=c++14", "-std=c++1y" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 'C++17' => [ "-std=c++17", "-std=c++1z" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 'C++20' => [ "-std=c++20", "-std=c++2a" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 'C++23' => [ "-std=c++23", "-std=c++2b" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | is_clang => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 'C++98' => [ "-std=c++98", ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 'C++11' => [ "-std=c++11", ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 'C++14' => [ "-std=c++14", "-std=c++1y" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 'C++17' => [ "-std=c++17", "-std=c++1z" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 'C++20' => [ "-std=c++20", "-std=c++2a" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 'C++23' => [ "-std=c++23", "-std=c++2b" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | is_msvc => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # Newer MSVC set C++14 as minimum version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 'C++98' => [ "" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 'C++11' => [ "" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 'C++14' => [ "-std:c++14" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 'C++17' => [ "-std:c++17" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 'C++20' => [ "-std:c++20" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | # no C++23 specific option as of Visual Studio 2020 17.3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | is_sunstudio => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 'C++98' => [ "" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 'C++11' => [ "-std=c++11", "-std=c++0x" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 'C++14' => [ "-std=c++14" ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | # No mention of C++17 for Oracle Developer Studio 12.6. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 3 | ▶ | sub cpp_standard_flag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpp_standard_flag: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 3 | my ($self, $standard_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 3 | ▶ | $self->guess_compiler || die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 3 | my ($detected_compiler) = grep { $self->{$_} } keys %$CPP_STANDARD_FLAGS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | die "Unknown standard '$standard_name' for compiler '$detected_compiler'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 3 | ▶ | unless exists $CPP_STANDARD_FLAGS->{$detected_compiler}{$standard_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 2 | my $test_flags = $CPP_STANDARD_FLAGS->{$detected_compiler}{$standard_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 2 | for my $flag (@$test_flags) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 2 | ▶ | return $flag if $self->_can_compile_code( <<EOF, [ $flag ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | int main(){ return 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 1 | die "Compiler '$detected_compiler' does not support any flags for standard '$standard_name'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||