| 1 | package SPVM::Builder::Config; | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | 493 | ▶ | use parent 'SPVM::Builder::Config::Linker'; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | |||||||||||||||||||||||
| 5 | 493 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | 493 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | 493 | ▶ | use Config; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 8 | 493 | ▶ | use Carp 'confess'; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | 493 | ▶ | use SPVM::Builder::Util; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 10 | 493 | ▶ | use SPVM::Builder::Config::Util; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | |||||||||||||||||||||||
| 12 | 493 | ▶ | use SPVM::Builder::Accessor 'has'; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | # Fields | ||||||||||||||||||||||
| 15 | 5199 | my $cc_fields = [qw( | |||||||||||||||||||||
| 16 | cc | ||||||||||||||||||||||
| 17 | ccflags | ||||||||||||||||||||||
| 18 | defines | ||||||||||||||||||||||
| 19 | optimize | ||||||||||||||||||||||
| 20 | language | ||||||||||||||||||||||
| 21 | dialect | ||||||||||||||||||||||
| 22 | std | ||||||||||||||||||||||
| 23 | ext | ||||||||||||||||||||||
| 24 | include_dirs | ||||||||||||||||||||||
| 25 | source_files | ||||||||||||||||||||||
| 26 | spvm_core_include_dir | ||||||||||||||||||||||
| 27 | resource_include_dirs | ||||||||||||||||||||||
| 28 | cc_output_option_name | ||||||||||||||||||||||
| 29 | copyright_print_ccflags | ||||||||||||||||||||||
| 30 | language_ccflags | ||||||||||||||||||||||
| 31 | arch_ccflags | ||||||||||||||||||||||
| 32 | warn_ccflags | ||||||||||||||||||||||
| 33 | debug_info_ccflags | ||||||||||||||||||||||
| 34 | source_encoding_ccflags | ||||||||||||||||||||||
| 35 | function_level_linking_ccflags | ||||||||||||||||||||||
| 36 | cpp_exception_handling_ccflags | ||||||||||||||||||||||
| 37 | library_linkage_ccflags | ||||||||||||||||||||||
| 38 | position_independent_code_ccflags | ||||||||||||||||||||||
| 39 | thread_ccflags | ||||||||||||||||||||||
| 40 | extra_ccflags | ||||||||||||||||||||||
| 41 | ndebug_ccflags | ||||||||||||||||||||||
| 42 | debug_file_synchronized_write_ccflags | ||||||||||||||||||||||
| 43 | cc_version | ||||||||||||||||||||||
| 44 | )]; | ||||||||||||||||||||||
| 45 | |||||||||||||||||||||||
| 46 | 5199 | has($cc_fields); | |||||||||||||||||||||
| 47 | |||||||||||||||||||||||
| 48 | 44044 | ▶ | sub option_names { | ||||||||||||||||||||
|
Subroutine
option_names: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||
| 49 | 44044 | ▶ | my ($self) = @_; | ||||||||||||||||||||
|
Subroutine
option_names: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||
| 50 | |||||||||||||||||||||||
| 51 | 44044 | return [@{$self->SUPER::option_names}, @$cc_fields]; | |||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||
| 53 | |||||||||||||||||||||||
| 54 | # Class Methods | ||||||||||||||||||||||
| 55 | 4700 | ▶ | sub new { | ||||||||||||||||||||
|
Subroutine
new: called CC=25 SCAR=35.7
Pod
documented
| |||||||||||||||||||||||
| 56 | 4700 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new: called CC=25 SCAR=35.7
Pod
documented
| |||||||||||||||||||||||
| 57 | |||||||||||||||||||||||
| 58 | 4700 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||
| 59 | |||||||||||||||||||||||
| 60 | # ccflags | ||||||||||||||||||||||
| 61 | 4700 | ▶ | unless (exists $self->{ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 62 | 4700 | $self->ccflags([]); | |||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||
| 64 | |||||||||||||||||||||||
| 65 | # defines | ||||||||||||||||||||||
| 66 | 0 | ▶ | unless (exists $self->{defines}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 67 | 4700 | $self->defines([]); | |||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||
| 69 | |||||||||||||||||||||||
| 70 | # position_independent_code_ccflags | ||||||||||||||||||||||
| 71 | 4700 | ▶ | unless (exists $self->{position_independent_code_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 72 | 4700 | ▶ | if (SPVM::Builder::Util::is_windows()) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 73 | 0 | $self->position_independent_code_ccflags([]); | |||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||
| 75 | else { | ||||||||||||||||||||||
| 76 | 4700 | $self->position_independent_code_ccflags(['-fPIC']); | |||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||
| 79 | |||||||||||||||||||||||
| 80 | # thread_ccflags | ||||||||||||||||||||||
| 81 | 4700 | ▶ | unless (exists $self->{thread_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 82 | 4700 | $self->thread_ccflags(['-pthread']); | |||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||
| 84 | |||||||||||||||||||||||
| 85 | # extra_ccflags | ||||||||||||||||||||||
| 86 | 4700 | ▶ | unless (exists $self->{extra_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 87 | 4700 | $self->extra_ccflags([]); | |||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||
| 89 | |||||||||||||||||||||||
| 90 | # ndebug_ccflags | ||||||||||||||||||||||
| 91 | 4700 | ▶ | unless (exists $self->{ndebug_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 92 | 4700 | $self->ndebug_ccflags(['-DNDEBUG']); | |||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||
| 94 | |||||||||||||||||||||||
| 95 | # debug_file_synchronized_write_ccflags | ||||||||||||||||||||||
| 96 | 4700 | ▶ | unless (exists $self->{debug_file_synchronized_write_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 97 | 4700 | $self->debug_file_synchronized_write_ccflags([]); | |||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||
| 99 | |||||||||||||||||||||||
| 100 | # optimize | ||||||||||||||||||||||
| 101 | 4700 | ▶ | unless (exists $self->{optimize}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 102 | 4700 | $self->optimize(''); | |||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||
| 104 | |||||||||||||||||||||||
| 105 | # include_dirs | ||||||||||||||||||||||
| 106 | 4700 | ▶ | unless (exists $self->{include_dirs}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 107 | 4700 | $self->include_dirs([]); | |||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||
| 109 | |||||||||||||||||||||||
| 110 | # spvm_core_include_dir | ||||||||||||||||||||||
| 111 | 4700 | ▶ | unless (exists $self->{spvm_core_include_dir}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 112 | 4700 | my $builder_dir = SPVM::Builder::Util::get_builder_dir(); | |||||||||||||||||||||
| 113 | 4700 | my $spvm_core_include_dir = "$builder_dir/include"; | |||||||||||||||||||||
| 114 | |||||||||||||||||||||||
| 115 | 4700 | $self->spvm_core_include_dir($spvm_core_include_dir); | |||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||
| 117 | |||||||||||||||||||||||
| 118 | # resource_include_dirs | ||||||||||||||||||||||
| 119 | 4700 | ▶ | unless (exists $self->{resource_include_dirs}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 120 | 4700 | $self->resource_include_dirs([]); | |||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||
| 122 | |||||||||||||||||||||||
| 123 | # source_files | ||||||||||||||||||||||
| 124 | 4700 | ▶ | unless (exists $self->{source_files}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 125 | 4700 | $self->source_files([]); | |||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||
| 127 | |||||||||||||||||||||||
| 128 | # copyright_print_ccflags | ||||||||||||||||||||||
| 129 | 4700 | ▶ | unless (exists $self->{copyright_print_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 130 | 4700 | $self->copyright_print_ccflags([]); | |||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||
| 132 | |||||||||||||||||||||||
| 133 | # language_ccflags | ||||||||||||||||||||||
| 134 | 4700 | ▶ | unless (exists $self->{language_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 135 | 4700 | $self->language_ccflags([]); | |||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||
| 137 | |||||||||||||||||||||||
| 138 | # arch_ccflags | ||||||||||||||||||||||
| 139 | 4700 | ▶ | unless (exists $self->{arch_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 140 | 4700 | $self->arch_ccflags([]); | |||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||
| 142 | |||||||||||||||||||||||
| 143 | # warn_ccflags | ||||||||||||||||||||||
| 144 | 4700 | ▶ | unless (exists $self->{warn_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 145 | 4700 | $self->warn_ccflags([]); | |||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||
| 147 | |||||||||||||||||||||||
| 148 | # debug_info_ccflags | ||||||||||||||||||||||
| 149 | 4700 | ▶ | unless (exists $self->{debug_info_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 150 | 4700 | $self->debug_info_ccflags([]); | |||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||
| 152 | |||||||||||||||||||||||
| 153 | # source_encoding_ccflags | ||||||||||||||||||||||
| 154 | 4700 | ▶ | unless (exists $self->{source_encoding_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 155 | 4700 | $self->source_encoding_ccflags([]); | |||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||
| 157 | |||||||||||||||||||||||
| 158 | # function_level_linking_ccflags | ||||||||||||||||||||||
| 159 | 0 | ▶ | unless (exists $self->{function_level_linking_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 160 | 4700 | $self->function_level_linking_ccflags([]); | |||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||
| 162 | |||||||||||||||||||||||
| 163 | # cpp_exception_handling_ccflags | ||||||||||||||||||||||
| 164 | 4700 | ▶ | unless (exists $self->{cpp_exception_handling_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 165 | 4700 | ▶ | if (SPVM::Builder::Util::is_windows()) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 166 | 0 | $self->cpp_exception_handling_ccflags(['-D__USE_MINGW_ANSI_STDIO']); | |||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||
| 168 | else { | ||||||||||||||||||||||
| 169 | 4700 | $self->cpp_exception_handling_ccflags([]); | |||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||
| 172 | |||||||||||||||||||||||
| 173 | # library_linkage_ccflags | ||||||||||||||||||||||
| 174 | 4700 | ▶ | unless (exists $self->{library_linkage_ccflags}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 175 | 4700 | $self->library_linkage_ccflags([]); | |||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||
| 177 | |||||||||||||||||||||||
| 178 | # cc_output_option_name | ||||||||||||||||||||||
| 179 | 4700 | ▶ | unless (exists $self->{cc_output_option_name}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 180 | 4700 | $self->cc_output_option_name("-o"); | |||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||
| 182 | |||||||||||||||||||||||
| 183 | 4700 | return $self; | |||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||
| 185 | |||||||||||||||||||||||
| 186 | 4643 | ▶ | sub new_c { | ||||||||||||||||||||
|
Subroutine
new_c: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||
| 187 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new_c: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||
| 188 | |||||||||||||||||||||||
| 189 | 4643 | my $self = $class->new(@_); | |||||||||||||||||||||
| 190 | |||||||||||||||||||||||
| 191 | # C compiler | ||||||||||||||||||||||
| 192 | 4643 | my $config_gcc_version = $Config{gccversion}; | |||||||||||||||||||||
| 193 | 4643 | ▶ | if ($config_gcc_version =~ /\bclang\b/i) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 194 | 0 | $self->cc('clang'); | |||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||
| 196 | else { | ||||||||||||||||||||||
| 197 | 4643 | $self->cc('gcc'); | |||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||
| 199 | |||||||||||||||||||||||
| 200 | 4643 | $self->language('c'); | |||||||||||||||||||||
| 201 | |||||||||||||||||||||||
| 202 | 4643 | $self->ext('c'); | |||||||||||||||||||||
| 203 | |||||||||||||||||||||||
| 204 | 4643 | ▶ | unless (exists $self->{cc_version}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 205 | 4643 | $self->cc_version($self->create_cc_version); | |||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||
| 207 | |||||||||||||||||||||||
| 208 | 4643 | return $self; | |||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||
| 210 | |||||||||||||||||||||||
| 211 | 4643 | ▶ | sub new_c99 { | ||||||||||||||||||||
|
Subroutine
new_c99: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 212 | 4643 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new_c99: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 213 | |||||||||||||||||||||||
| 214 | 4643 | my $self = $class->new_c(@_); | |||||||||||||||||||||
| 215 | |||||||||||||||||||||||
| 216 | 4643 | $self->std('c99'); | |||||||||||||||||||||
| 217 | |||||||||||||||||||||||
| 218 | 4643 | return $self; | |||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||
| 220 | |||||||||||||||||||||||
| 221 | 0 | ▶ | sub new_c11 { | ||||||||||||||||||||
|
Subroutine
new_c11: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 222 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new_c11: called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 223 | |||||||||||||||||||||||
| 224 | 0 | my $self = $class->new_c(@_); | |||||||||||||||||||||
| 225 | |||||||||||||||||||||||
| 226 | 0 | $self->std('c11'); | |||||||||||||||||||||
| 227 | |||||||||||||||||||||||
| 228 | 0 | return $self; | |||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||
| 230 | |||||||||||||||||||||||
| 231 | 0 | ▶ | sub new_c17 { | ||||||||||||||||||||
|
Subroutine
new_c17: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 232 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new_c17: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 233 | |||||||||||||||||||||||
| 234 | 0 | my $self = $class->new_c(@_); | |||||||||||||||||||||
| 235 | |||||||||||||||||||||||
| 236 | 0 | $self->std('c17'); | |||||||||||||||||||||
| 237 | |||||||||||||||||||||||
| 238 | 0 | return $self; | |||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||
| 240 | |||||||||||||||||||||||
| 241 | 0 | ▶ | sub new_c23 { | ||||||||||||||||||||
|
Subroutine
new_c23: not called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||
| 242 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new_c23: not called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||
| 243 | |||||||||||||||||||||||
| 244 | 0 | my $self = $class->new_c(@_); | |||||||||||||||||||||
| 245 | |||||||||||||||||||||||
| 246 | 0 | $self->std('c23'); | |||||||||||||||||||||
| 247 | |||||||||||||||||||||||
| 248 | 0 | return $self; | |||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||
| 250 | |||||||||||||||||||||||
| 251 | 43 | ▶ | sub new_cpp { | ||||||||||||||||||||
|
Subroutine
new_cpp: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||
| 252 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new_cpp: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||
| 253 | |||||||||||||||||||||||
| 254 | 43 | my $self = $class->new(@_); | |||||||||||||||||||||
| 255 | |||||||||||||||||||||||
| 256 | # C++ compiler | ||||||||||||||||||||||
| 257 | 43 | my $config_gcc_version = $Config{gccversion}; | |||||||||||||||||||||
| 258 | 43 | ▶ | if ($config_gcc_version =~ /\bclang\b/i) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 259 | 0 | $self->cc('clang++'); | |||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||
| 261 | else { | ||||||||||||||||||||||
| 262 | 43 | $self->cc('g++'); | |||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||
| 264 | |||||||||||||||||||||||
| 265 | 43 | $self->language('cpp'); | |||||||||||||||||||||
| 266 | |||||||||||||||||||||||
| 267 | 43 | $self->ext('cpp'); | |||||||||||||||||||||
| 268 | |||||||||||||||||||||||
| 269 | 43 | ▶ | unless (exists $self->{cc_version}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 270 | 43 | $self->cc_version($self->create_cc_version); | |||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||
| 272 | |||||||||||||||||||||||
| 273 | 43 | return $self; | |||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||
| 275 | |||||||||||||||||||||||
| 276 | 41 | ▶ | sub new_cpp11 { | ||||||||||||||||||||
|
Subroutine
new_cpp11: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 277 | 41 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new_cpp11: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 278 | |||||||||||||||||||||||
| 279 | 41 | my $self = $class->new_cpp(@_); | |||||||||||||||||||||
| 280 | |||||||||||||||||||||||
| 281 | 41 | $self->std('c++11'); | |||||||||||||||||||||
| 282 | |||||||||||||||||||||||
| 283 | 41 | return $self; | |||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||
| 285 | |||||||||||||||||||||||
| 286 | 0 | ▶ | sub new_cpp14 { | ||||||||||||||||||||
|
Subroutine
new_cpp14: not called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||
| 287 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new_cpp14: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||
| 288 | |||||||||||||||||||||||
| 289 | 0 | my $self = $class->new_cpp(@_); | |||||||||||||||||||||
| 290 | |||||||||||||||||||||||
| 291 | 0 | $self->std('c++14'); | |||||||||||||||||||||
| 292 | |||||||||||||||||||||||
| 293 | 0 | return $self; | |||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||
| 295 | |||||||||||||||||||||||
| 296 | 0 | ▶ | sub new_cpp17 { | ||||||||||||||||||||
|
Subroutine
new_cpp17: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 297 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new_cpp17: called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 298 | |||||||||||||||||||||||
| 299 | 0 | my $self = $class->new_cpp(@_); | |||||||||||||||||||||
| 300 | |||||||||||||||||||||||
| 301 | 0 | $self->std('c++17'); | |||||||||||||||||||||
| 302 | |||||||||||||||||||||||
| 303 | 0 | return $self; | |||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||
| 305 | |||||||||||||||||||||||
| 306 | 0 | ▶ | sub new_cpp20 { | ||||||||||||||||||||
|
Subroutine
new_cpp20: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 307 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new_cpp20: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 308 | |||||||||||||||||||||||
| 309 | 0 | my $self = $class->new_cpp(@_); | |||||||||||||||||||||
| 310 | |||||||||||||||||||||||
| 311 | 0 | $self->std('c++20'); | |||||||||||||||||||||
| 312 | |||||||||||||||||||||||
| 313 | 0 | return $self; | |||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||
| 315 | |||||||||||||||||||||||
| 316 | 0 | ▶ | sub new_cpp23 { | ||||||||||||||||||||
|
Subroutine
new_cpp23: not called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||
| 317 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new_cpp23: not called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||
| 318 | |||||||||||||||||||||||
| 319 | 0 | my $self = $class->new_cpp(@_); | |||||||||||||||||||||
| 320 | |||||||||||||||||||||||
| 321 | 0 | $self->std('c++23'); | |||||||||||||||||||||
| 322 | |||||||||||||||||||||||
| 323 | 0 | return $self; | |||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||
| 325 | |||||||||||||||||||||||
| 326 | # Instance Methods | ||||||||||||||||||||||
| 327 | 22 | ▶ | sub add_ccflag { | ||||||||||||||||||||
|
Subroutine
add_ccflag: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 328 | 22 | ▶ | my ($self, @ccflags) = @_; | ||||||||||||||||||||
|
Subroutine
add_ccflag: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 329 | |||||||||||||||||||||||
| 330 | 22 | push @{$self->{ccflags}}, @ccflags; | |||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||
| 332 | |||||||||||||||||||||||
| 333 | 334 | ▶ | sub add_define { | ||||||||||||||||||||
|
Subroutine
add_define: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 334 | 36 | ▶ | my ($self, @defines) = @_; | ||||||||||||||||||||
|
Subroutine
add_define: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 335 | |||||||||||||||||||||||
| 336 | 36 | push @{$self->{defines}}, @defines; | |||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||
| 338 | |||||||||||||||||||||||
| 339 | 302 | ▶ | sub add_include_dir { | ||||||||||||||||||||
|
Subroutine
add_include_dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 340 | 4 | ▶ | my ($self, @include_dirs) = @_; | ||||||||||||||||||||
|
Subroutine
add_include_dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 341 | |||||||||||||||||||||||
| 342 | 4 | push @{$self->{include_dirs}}, @include_dirs; | |||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||
| 344 | |||||||||||||||||||||||
| 345 | 542 | ▶ | sub add_source_file { | ||||||||||||||||||||
|
Subroutine
add_source_file: called CC=1 SCAR=0.4
Pod
documented
| |||||||||||||||||||||||
| 346 | 244 | ▶ | my ($self, @source_files) = @_; | ||||||||||||||||||||
|
Subroutine
add_source_file: called CC=1 SCAR=0.4
Pod
documented
| |||||||||||||||||||||||
| 347 | |||||||||||||||||||||||
| 348 | 0 | push @{$self->{source_files}}, @source_files; | |||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||
| 350 | |||||||||||||||||||||||
| 351 | 205835 | ▶ | sub get_cc_system_field_names { | ||||||||||||||||||||
|
Subroutine
get_cc_system_field_names: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||
| 352 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
get_cc_system_field_names: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||
| 353 | |||||||||||||||||||||||
| 354 | 0 | return [qw( | |||||||||||||||||||||
| 355 | position_independent_code_ccflags | ||||||||||||||||||||||
| 356 | thread_ccflags | ||||||||||||||||||||||
| 357 | extra_ccflags | ||||||||||||||||||||||
| 358 | ndebug_ccflags | ||||||||||||||||||||||
| 359 | debug_file_synchronized_write_ccflags | ||||||||||||||||||||||
| 360 | copyright_print_ccflags | ||||||||||||||||||||||
| 361 | language_ccflags | ||||||||||||||||||||||
| 362 | arch_ccflags | ||||||||||||||||||||||
| 363 | warn_ccflags | ||||||||||||||||||||||
| 364 | debug_info_ccflags | ||||||||||||||||||||||
| 365 | source_encoding_ccflags | ||||||||||||||||||||||
| 366 | function_level_linking_ccflags | ||||||||||||||||||||||
| 367 | cpp_exception_handling_ccflags | ||||||||||||||||||||||
| 368 | library_linkage_ccflags | ||||||||||||||||||||||
| 369 | )]; | ||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||
| 371 | |||||||||||||||||||||||
| 372 | 298 | ▶ | sub clear_system_fields { | ||||||||||||||||||||
|
Subroutine
clear_system_fields: called CC=2 SCAR=10.5
Pod
documented
| |||||||||||||||||||||||
| 373 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||
|
Subroutine
clear_system_fields: not called CC=2 SCAR=10.5
Pod
documented
| |||||||||||||||||||||||
| 374 | |||||||||||||||||||||||
| 375 | 0 | $self->SUPER::clear_system_fields; | |||||||||||||||||||||
| 376 | |||||||||||||||||||||||
| 377 | 0 | my $field_names = $self->get_cc_system_field_names; | |||||||||||||||||||||
| 378 | |||||||||||||||||||||||
| 379 | 0 | for my $field_name (@$field_names) { | |||||||||||||||||||||
| 380 | 0 | $self->$field_name([]); | |||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||
| 383 | |||||||||||||||||||||||
| 384 | 5199 | my %CC_VERSION_CACHE; | |||||||||||||||||||||
| 385 | |||||||||||||||||||||||
| 386 | 4984 | ▶ | sub create_cc_version { | ||||||||||||||||||||
|
Subroutine
create_cc_version: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||
| 387 | 4686 | ▶ | my ($self) = @_; | ||||||||||||||||||||
|
Subroutine
create_cc_version: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||
| 388 | |||||||||||||||||||||||
| 389 | 4984 | my $cc = $self->cc; | |||||||||||||||||||||
| 390 | 4984 | ▶ | my $path_env = $ENV{PATH} // ''; | ||||||||||||||||||||
|
Condition50%2/4
$ENV{"PATH"} // ""
$ENV{"PATH"} // ""
MC/DC0%0/1
$ENV{"PATH"} // ""
$ENV{"PATH"}
MC/DC0%0/1
$ENV{"PATH"} // ""
$ENV{"PATH"}
Truth table50%1/2
A
A= $ENV{"PATH"}
Truth table50%1/2
A
A= $ENV{"PATH"}
| |||||||||||||||||||||||
| 391 | |||||||||||||||||||||||
| 392 | 4984 | ▶ | if (exists $CC_VERSION_CACHE{$cc}{$path_env}) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 393 | 4619 | return $CC_VERSION_CACHE{$cc}{$path_env}; | |||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||
| 395 | |||||||||||||||||||||||
| 396 | 663 | ▶ | my $cc_version = `$cc --version 2>&1` // ''; | ||||||||||||||||||||
|
Condition50%2/4
`$cc --version 2>&1` // ""
`$cc --version 2>&1` // ""
MC/DC0%0/1
`$cc --version 2>&1` // ""
`$cc --version 2>&1`
MC/DC0%0/1
`$cc --version 2>&1` // ""
`$cc --version 2>&1`
Truth table50%1/2
A
A= `$cc --version 2>&1`
Truth table50%1/2
A
A= `$cc --version 2>&1`
| |||||||||||||||||||||||
| 397 | |||||||||||||||||||||||
| 398 | 663 | $cc_version =~ s/\n.*//s; | |||||||||||||||||||||
| 399 | |||||||||||||||||||||||
| 400 | 663 | $CC_VERSION_CACHE{$cc}{$path_env} = $cc_version; | |||||||||||||||||||||
| 401 | |||||||||||||||||||||||
| 402 | 663 | return $cc_version; | |||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||
| 404 | |||||||||||||||||||||||
| 405 | 206833 | ▶ | sub native_include_dir { | ||||||||||||||||||||
|
Subroutine
native_include_dir: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 406 | 206833 | ▶ | my ($self) = @_; | ||||||||||||||||||||
|
Subroutine
native_include_dir: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 407 | |||||||||||||||||||||||
| 408 | 206833 | my $config_file = $self->file; | |||||||||||||||||||||
| 409 | |||||||||||||||||||||||
| 410 | 206833 | ▶ | unless (defined $config_file) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 411 | 186014 | return; | |||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||
| 413 | |||||||||||||||||||||||
| 414 | 21117 | my $native_dir = SPVM::Builder::Config::Util::remove_ext_from_config_file($config_file); | |||||||||||||||||||||
| 415 | 21117 | $native_dir .= '.native'; | |||||||||||||||||||||
| 416 | 21117 | my $native_include_dir = "$native_dir/include"; | |||||||||||||||||||||
| 417 | |||||||||||||||||||||||
| 418 | 21117 | return $native_include_dir; | |||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||
| 420 | |||||||||||||||||||||||
| 421 | 898 | ▶ | sub native_src_dir { | ||||||||||||||||||||
|
Subroutine
native_src_dir: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 422 | 898 | ▶ | my ($self) = @_; | ||||||||||||||||||||
|
Subroutine
native_src_dir: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 423 | |||||||||||||||||||||||
| 424 | 898 | my $config_file = $self->file; | |||||||||||||||||||||
| 425 | |||||||||||||||||||||||
| 426 | 898 | ▶ | unless (defined $config_file) { | ||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||
| 427 | 666 | return; | |||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||
| 429 | |||||||||||||||||||||||
| 430 | 530 | my $native_dir = SPVM::Builder::Config::Util::remove_ext_from_config_file($config_file); | |||||||||||||||||||||
| 431 | 530 | $native_dir .= '.native'; | |||||||||||||||||||||
| 432 | 530 | my $native_src_dir = "$native_dir/src"; | |||||||||||||||||||||
| 433 | |||||||||||||||||||||||
| 434 | 530 | return $native_src_dir; | |||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||
| 436 | |||||||||||||||||||||||
| 437 | 1015 | 1; | |||||||||||||||||||||
| 438 | |||||||||||||||||||||||
| 439 | =head1 Name | ||||||||||||||||||||||
| 440 | |||||||||||||||||||||||
| 441 | SPVM::Builder::Config - Config for Compiling and Linking Native Classes | ||||||||||||||||||||||
| 442 | |||||||||||||||||||||||
| 443 | =head1 Description | ||||||||||||||||||||||
| 444 | |||||||||||||||||||||||
| 445 | L<SPVM::Builder::Config> is a class to manage the configurations for compiling and linking native classes (C, C++, etc.). | ||||||||||||||||||||||
| 446 | |||||||||||||||||||||||
| 447 | An instance of this class holds compiler settings (managed by L<SPVM::Builder::Config> itself), linker and resource settings (inherited from L<SPVM::Builder::Config::Linker>), and configuration loading and common settings (inherited from L<SPVM::Builder::Config::Base>). | ||||||||||||||||||||||
| 448 | |||||||||||||||||||||||
| 449 | Within a configuration file (C<.build>), you can customize the build environment by accessing methods from all of these hierarchical levels.=head1 Usage | ||||||||||||||||||||||
| 450 | |||||||||||||||||||||||
| 451 | use SPVM::Builder::Config; | ||||||||||||||||||||||
| 452 | |||||||||||||||||||||||
| 453 | # Create a config | ||||||||||||||||||||||
| 454 | my $config = SPVM::Builder::Config->new; | ||||||||||||||||||||||
| 455 | |||||||||||||||||||||||
| 456 | # C99 | ||||||||||||||||||||||
| 457 | my $config = SPVM::Builder::Config->new_c99; | ||||||||||||||||||||||
| 458 | |||||||||||||||||||||||
| 459 | # C11 | ||||||||||||||||||||||
| 460 | my $config = SPVM::Builder::Config->new_c11; | ||||||||||||||||||||||
| 461 | |||||||||||||||||||||||
| 462 | # C17 | ||||||||||||||||||||||
| 463 | my $config = SPVM::Builder::Config->new_c17; | ||||||||||||||||||||||
| 464 | |||||||||||||||||||||||
| 465 | # C23 | ||||||||||||||||||||||
| 466 | my $config = SPVM::Builder::Config->new_c23; | ||||||||||||||||||||||
| 467 | |||||||||||||||||||||||
| 468 | # C++ | ||||||||||||||||||||||
| 469 | my $config = SPVM::Builder::Config->new_cpp; | ||||||||||||||||||||||
| 470 | |||||||||||||||||||||||
| 471 | # C++11 | ||||||||||||||||||||||
| 472 | my $config = SPVM::Builder::Config->new_cpp11; | ||||||||||||||||||||||
| 473 | |||||||||||||||||||||||
| 474 | # C++17 | ||||||||||||||||||||||
| 475 | my $config = SPVM::Builder::Config->new_cpp17; | ||||||||||||||||||||||
| 476 | |||||||||||||||||||||||
| 477 | # C++20 | ||||||||||||||||||||||
| 478 | my $config = SPVM::Builder::Config->new_cpp20; | ||||||||||||||||||||||
| 479 | |||||||||||||||||||||||
| 480 | # C++23 | ||||||||||||||||||||||
| 481 | my $config = SPVM::Builder::Config->new_cpp23; | ||||||||||||||||||||||
| 482 | |||||||||||||||||||||||
| 483 | # Optimize | ||||||||||||||||||||||
| 484 | $config->optimize("-O2"); | ||||||||||||||||||||||
| 485 | |||||||||||||||||||||||
| 486 | # Optimize with debug mode | ||||||||||||||||||||||
| 487 | $config->optimize("-O0 -g"); | ||||||||||||||||||||||
| 488 | |||||||||||||||||||||||
| 489 | # Add ccflags | ||||||||||||||||||||||
| 490 | $config->add_ccflag("-DFOO"); | ||||||||||||||||||||||
| 491 | |||||||||||||||||||||||
| 492 | $config->add_define("FOO"); | ||||||||||||||||||||||
| 493 | |||||||||||||||||||||||
| 494 | # Add source files | ||||||||||||||||||||||
| 495 | $config->add_source_file("foo.c", "bar.c", "baz/baz.c"); | ||||||||||||||||||||||
| 496 | |||||||||||||||||||||||
| 497 | # Add libraries | ||||||||||||||||||||||
| 498 | $config->add_lib("gdi32", "d2d1", "Dwrite"); | ||||||||||||||||||||||
| 499 | |||||||||||||||||||||||
| 500 | # Add ldflags | ||||||||||||||||||||||
| 501 | $config->add_ldflag("-pthread"); | ||||||||||||||||||||||
| 502 | |||||||||||||||||||||||
| 503 | # Use resource | ||||||||||||||||||||||
| 504 | $config->use_resource("Resource::MyResource"); | ||||||||||||||||||||||
| 505 | |||||||||||||||||||||||
| 506 | =head1 Inheritance | ||||||||||||||||||||||
| 507 | |||||||||||||||||||||||
| 508 | L<SPVM::Builder::Config::Linker> | ||||||||||||||||||||||
| 509 | |||||||||||||||||||||||
| 510 | =head2 Class Hierarchy | ||||||||||||||||||||||
| 511 | |||||||||||||||||||||||
| 512 | =over 2 | ||||||||||||||||||||||
| 513 | |||||||||||||||||||||||
| 514 | =item 1. L<SPVM::Builder::Config::Base> | ||||||||||||||||||||||
| 515 | |||||||||||||||||||||||
| 516 | The base class for all configuration classes. It provides the "loading configuration files" mechanism and manages common settings shared across all build phases, such as C<class_name>, and C<quiet>. | ||||||||||||||||||||||
| 517 | |||||||||||||||||||||||
| 518 | =item 2. L<SPVM::Builder::Config::Linker> | ||||||||||||||||||||||
| 519 | |||||||||||||||||||||||
| 520 | This class manages settings for "linking" (converting object files to shared libraries or executables) and "resource management". Fields like C<ld>, C<libs>, C<ldflags>, and C<resources> are defined in this class. Inherits L<SPVM::Builder::Config::Base>. | ||||||||||||||||||||||
| 521 | |||||||||||||||||||||||
| 522 | =item 3. L<SPVM::Builder::Config> | ||||||||||||||||||||||
| 523 | |||||||||||||||||||||||
| 524 | This class primarily manages settings for "compilation" (converting C/C++ source files to object files). Inherits L<SPVM::Builder::Config::Linker> and L<SPVM::Builder::Config::Base>. | ||||||||||||||||||||||
| 525 | |||||||||||||||||||||||
| 526 | =back | ||||||||||||||||||||||
| 527 | |||||||||||||||||||||||
| 528 | =head1 Fields | ||||||||||||||||||||||
| 529 | |||||||||||||||||||||||
| 530 | =head2 ext | ||||||||||||||||||||||
| 531 | |||||||||||||||||||||||
| 532 | my $ext = $config->ext; | ||||||||||||||||||||||
| 533 | $config->ext($ext); | ||||||||||||||||||||||
| 534 | |||||||||||||||||||||||
| 535 | Gets and sets C<ext> field, the extension of a native class. | ||||||||||||||||||||||
| 536 | |||||||||||||||||||||||
| 537 | Examples: | ||||||||||||||||||||||
| 538 | |||||||||||||||||||||||
| 539 | # MyClass.c | ||||||||||||||||||||||
| 540 | $config->ext('c'); | ||||||||||||||||||||||
| 541 | |||||||||||||||||||||||
| 542 | # MyClass.cpp | ||||||||||||||||||||||
| 543 | $config->ext('cpp'); | ||||||||||||||||||||||
| 544 | |||||||||||||||||||||||
| 545 | # MyClass.cc | ||||||||||||||||||||||
| 546 | $config->ext('cc'); | ||||||||||||||||||||||
| 547 | |||||||||||||||||||||||
| 548 | # MyClass.cu | ||||||||||||||||||||||
| 549 | $config->ext('cu'); | ||||||||||||||||||||||
| 550 | |||||||||||||||||||||||
| 551 | # MyClass.m | ||||||||||||||||||||||
| 552 | $config->ext('m'); | ||||||||||||||||||||||
| 553 | |||||||||||||||||||||||
| 554 | =head2 cc | ||||||||||||||||||||||
| 555 | |||||||||||||||||||||||
| 556 | my $cc = $config->cc; | ||||||||||||||||||||||
| 557 | $config->cc($cc); | ||||||||||||||||||||||
| 558 | |||||||||||||||||||||||
| 559 | Gets and sets C<cc> field, a compiler name. | ||||||||||||||||||||||
| 560 | |||||||||||||||||||||||
| 561 | Examples: | ||||||||||||||||||||||
| 562 | |||||||||||||||||||||||
| 563 | # gcc | ||||||||||||||||||||||
| 564 | $config->cc('gcc'); | ||||||||||||||||||||||
| 565 | |||||||||||||||||||||||
| 566 | # g++ for C++ | ||||||||||||||||||||||
| 567 | $config->cc('g++'); | ||||||||||||||||||||||
| 568 | |||||||||||||||||||||||
| 569 | # nvcc for CUDA/GUP | ||||||||||||||||||||||
| 570 | $config->cc('nvcc'); | ||||||||||||||||||||||
| 571 | |||||||||||||||||||||||
| 572 | =head2 include_dirs | ||||||||||||||||||||||
| 573 | |||||||||||||||||||||||
| 574 | my $include_dirs = $config->include_dirs; | ||||||||||||||||||||||
| 575 | $config->include_dirs($include_dirs); | ||||||||||||||||||||||
| 576 | |||||||||||||||||||||||
| 577 | Gets and sets C<include_dirs> field, an array reference containing header file search directories. | ||||||||||||||||||||||
| 578 | |||||||||||||||||||||||
| 579 | The values of this field are converted to C<-I> options when the arguments of the compiler L</"cc"> are created. | ||||||||||||||||||||||
| 580 | |||||||||||||||||||||||
| 581 | # -I /path1 -I /path2 | ||||||||||||||||||||||
| 582 | $config->include_dirs(['/path1', '/path2']); | ||||||||||||||||||||||
| 583 | |||||||||||||||||||||||
| 584 | =head2 spvm_core_include_dir | ||||||||||||||||||||||
| 585 | |||||||||||||||||||||||
| 586 | my $spvm_core_include_dir = $config->spvm_core_include_dir; | ||||||||||||||||||||||
| 587 | $config->spvm_core_include_dir($spvm_core_include_dir); | ||||||||||||||||||||||
| 588 | |||||||||||||||||||||||
| 589 | Gets and sets C<spvm_core_include_dir> field, an SPVM core header file search directory. | ||||||||||||||||||||||
| 590 | |||||||||||||||||||||||
| 591 | The value of this field is converted to C<-I> option when the arguments of the compiler L</"cc"> are created. | ||||||||||||||||||||||
| 592 | |||||||||||||||||||||||
| 593 | =head2 resource_include_dirs | ||||||||||||||||||||||
| 594 | |||||||||||||||||||||||
| 595 | my $resource_include_dirs = $config->resource_include_dirs; | ||||||||||||||||||||||
| 596 | $config->resource_include_dirs($resource_include_dirs); | ||||||||||||||||||||||
| 597 | |||||||||||||||||||||||
| 598 | Gets and sets C<resource_include_dirs> field, an SPVM resource header files search directory. | ||||||||||||||||||||||
| 599 | |||||||||||||||||||||||
| 600 | The value of this field is converted to C<-I> option when the arguments of the compiler L</"cc"> are created. | ||||||||||||||||||||||
| 601 | |||||||||||||||||||||||
| 602 | =head2 ccflags | ||||||||||||||||||||||
| 603 | |||||||||||||||||||||||
| 604 | my $ccflags = $config->ccflags; | ||||||||||||||||||||||
| 605 | $config->ccflags($ccflags); | ||||||||||||||||||||||
| 606 | |||||||||||||||||||||||
| 607 | Gets and sets C<ccflags> field, an array reference containing arugments of the compiler L</"cc">. | ||||||||||||||||||||||
| 608 | |||||||||||||||||||||||
| 609 | =head2 defines | ||||||||||||||||||||||
| 610 | |||||||||||||||||||||||
| 611 | my $defines = $config->defines; | ||||||||||||||||||||||
| 612 | $config->defines($defines); | ||||||||||||||||||||||
| 613 | |||||||||||||||||||||||
| 614 | Gets and sets C<defines> field, an array reference containing the values of C<-D> arugments of the compiler L</"cc">. | ||||||||||||||||||||||
| 615 | |||||||||||||||||||||||
| 616 | =head2 cc_version | ||||||||||||||||||||||
| 617 | |||||||||||||||||||||||
| 618 | my $cc_version = $config->cc_version; | ||||||||||||||||||||||
| 619 | $config->cc_version($cc_version); | ||||||||||||||||||||||
| 620 | |||||||||||||||||||||||
| 621 | Gets and sets C<cc_version> field, the compiler version to be used for the build cache digest. | ||||||||||||||||||||||
| 622 | |||||||||||||||||||||||
| 623 | =head2 optimize | ||||||||||||||||||||||
| 624 | |||||||||||||||||||||||
| 625 | my $optimize = $config->optimize; | ||||||||||||||||||||||
| 626 | $config->optimize($optimize); | ||||||||||||||||||||||
| 627 | |||||||||||||||||||||||
| 628 | Gets and sets C<optimize> field, an arugment of the compiler L</"cc"> for optimization. | ||||||||||||||||||||||
| 629 | |||||||||||||||||||||||
| 630 | Examples: | ||||||||||||||||||||||
| 631 | |||||||||||||||||||||||
| 632 | $config->optimize('-O3 -DNDEBUG'); | ||||||||||||||||||||||
| 633 | $config->optimize('-O2'); | ||||||||||||||||||||||
| 634 | $config->optimize('-g -O0'); | ||||||||||||||||||||||
| 635 | |||||||||||||||||||||||
| 636 | =head2 position_independent_code_ccflags | ||||||||||||||||||||||
| 637 | |||||||||||||||||||||||
| 638 | my $flags = $config->position_independent_code_ccflags; | ||||||||||||||||||||||
| 639 | $config->position_independent_code_ccflags(['-fPIC']); | ||||||||||||||||||||||
| 640 | |||||||||||||||||||||||
| 641 | Gets or sets the compiler flags required to generate Position Independent Code (PIC). | ||||||||||||||||||||||
| 642 | This is typically an array reference containing flags like C<-fPIC>, which are | ||||||||||||||||||||||
| 643 | necessary for building libraries intended for dynamic linking. | ||||||||||||||||||||||
| 644 | |||||||||||||||||||||||
| 645 | =cut | ||||||||||||||||||||||
| 646 | |||||||||||||||||||||||
| 647 | =head2 thread_ccflags | ||||||||||||||||||||||
| 648 | |||||||||||||||||||||||
| 649 | my $thread_ccflags = $config->thread_ccflags; | ||||||||||||||||||||||
| 650 | $config->thread_ccflags($thread_ccflags); | ||||||||||||||||||||||
| 651 | |||||||||||||||||||||||
| 652 | Gets and sets C<thread_ccflags> field, an array reference containing arugments of the compiler L</"cc"> for threads. | ||||||||||||||||||||||
| 653 | |||||||||||||||||||||||
| 654 | =head2 extra_ccflags | ||||||||||||||||||||||
| 655 | |||||||||||||||||||||||
| 656 | my $extra_ccflags = $config->extra_ccflags; | ||||||||||||||||||||||
| 657 | $config->extra_ccflags(['-Wno-unused-variable']); | ||||||||||||||||||||||
| 658 | |||||||||||||||||||||||
| 659 | Gets and sets C<extra_ccflags> field, an array reference containing extra arguments of the compiler L</"cc">. | ||||||||||||||||||||||
| 660 | |||||||||||||||||||||||
| 661 | =head2 ndebug_ccflags | ||||||||||||||||||||||
| 662 | |||||||||||||||||||||||
| 663 | my $ndebug_ccflags = $config->ndebug_ccflags; | ||||||||||||||||||||||
| 664 | $config->ndebug_ccflags(['-DNDEBUG']); | ||||||||||||||||||||||
| 665 | |||||||||||||||||||||||
| 666 | Gets and sets C<ndebug_ccflags> field, an array reference containing compiler flags to deactivate debug features like C<assert>. | ||||||||||||||||||||||
| 667 | This field is typically used to provide C<-DNDEBUG> for production builds. | ||||||||||||||||||||||
| 668 | |||||||||||||||||||||||
| 669 | =head2 debug_file_synchronized_write_ccflags | ||||||||||||||||||||||
| 670 | |||||||||||||||||||||||
| 671 | my $debug_file_synchronized_write_ccflags = $config->debug_file_synchronized_write_ccflags; | ||||||||||||||||||||||
| 672 | $config->debug_file_synchronized_write_ccflags(['-FS']); | ||||||||||||||||||||||
| 673 | |||||||||||||||||||||||
| 674 | Gets and sets C<debug_file_synchronized_write_ccflags> field, an array reference containing compiler flags to ensure synchronized writing of debug information files. | ||||||||||||||||||||||
| 675 | This field is typically used to provide compiler-specific flags like C<-FS> for MSVC to prevent file access conflicts during parallel builds. | ||||||||||||||||||||||
| 676 | |||||||||||||||||||||||
| 677 | =head2 std | ||||||||||||||||||||||
| 678 | |||||||||||||||||||||||
| 679 | my $std = $config->std; | ||||||||||||||||||||||
| 680 | $config->std($std); | ||||||||||||||||||||||
| 681 | |||||||||||||||||||||||
| 682 | Gets and sets C<std> field, a language standard. | ||||||||||||||||||||||
| 683 | |||||||||||||||||||||||
| 684 | This field is converted to C<-std> option when the arguments of the compiler L</"cc"> are created. | ||||||||||||||||||||||
| 685 | |||||||||||||||||||||||
| 686 | Examples: | ||||||||||||||||||||||
| 687 | |||||||||||||||||||||||
| 688 | # -std=c99 | ||||||||||||||||||||||
| 689 | $config->std('c99'); | ||||||||||||||||||||||
| 690 | |||||||||||||||||||||||
| 691 | # -std=cpp | ||||||||||||||||||||||
| 692 | $config->std('cpp'); | ||||||||||||||||||||||
| 693 | |||||||||||||||||||||||
| 694 | # -std=cpp11 | ||||||||||||||||||||||
| 695 | $config->std('cpp11'); | ||||||||||||||||||||||
| 696 | |||||||||||||||||||||||
| 697 | # -std=cpp17 | ||||||||||||||||||||||
| 698 | $config->std('cpp17'); | ||||||||||||||||||||||
| 699 | |||||||||||||||||||||||
| 700 | =head2 source_files | ||||||||||||||||||||||
| 701 | |||||||||||||||||||||||
| 702 | my $source_files = $config->source_files; | ||||||||||||||||||||||
| 703 | $config->source_files($source_files); | ||||||||||||||||||||||
| 704 | |||||||||||||||||||||||
| 705 | Gets and sets C<source_files> field, an array reference containing relative paths of L<native source file|SPVM::Document::NativeClass/"Native Source Files"> file from C<src> directory. | ||||||||||||||||||||||
| 706 | |||||||||||||||||||||||
| 707 | =head2 language | ||||||||||||||||||||||
| 708 | |||||||||||||||||||||||
| 709 | my $language = $config->language; | ||||||||||||||||||||||
| 710 | $config->language($language); | ||||||||||||||||||||||
| 711 | |||||||||||||||||||||||
| 712 | Gets and sets the C<language> field. | ||||||||||||||||||||||
| 713 | |||||||||||||||||||||||
| 714 | The language of the source files. | ||||||||||||||||||||||
| 715 | |||||||||||||||||||||||
| 716 | One of the following languages can be specified: | ||||||||||||||||||||||
| 717 | |||||||||||||||||||||||
| 718 | =over 2 | ||||||||||||||||||||||
| 719 | |||||||||||||||||||||||
| 720 | =item * C<c> | ||||||||||||||||||||||
| 721 | |||||||||||||||||||||||
| 722 | C language | ||||||||||||||||||||||
| 723 | |||||||||||||||||||||||
| 724 | =item * C<cpp> | ||||||||||||||||||||||
| 725 | |||||||||||||||||||||||
| 726 | C++ language | ||||||||||||||||||||||
| 727 | |||||||||||||||||||||||
| 728 | =back | ||||||||||||||||||||||
| 729 | |||||||||||||||||||||||
| 730 | =head2 dialect | ||||||||||||||||||||||
| 731 | |||||||||||||||||||||||
| 732 | my $dialect = $config->dialect; | ||||||||||||||||||||||
| 733 | $config->dialect($dialect); | ||||||||||||||||||||||
| 734 | |||||||||||||||||||||||
| 735 | Gets and sets the C<dialect> field. | ||||||||||||||||||||||
| 736 | |||||||||||||||||||||||
| 737 | The dialect of the language. | ||||||||||||||||||||||
| 738 | |||||||||||||||||||||||
| 739 | You can specify any dialect name, but the following names are reserved for specific compilers or toolchains: | ||||||||||||||||||||||
| 740 | |||||||||||||||||||||||
| 741 | Each unit of a dialect name must consist of lowercase alphanumeric characters (C<a-z0-9>). | ||||||||||||||||||||||
| 742 | |||||||||||||||||||||||
| 743 | Multiple units can be combined using a hyphen (C<->) to represent sub-dialects, such as C<arduino-avr>, C<esp32-s3>, or C<cuda-sm80>. | ||||||||||||||||||||||
| 744 | |||||||||||||||||||||||
| 745 | You can specify any dialect name, but the following names are reserved for specific compilers or toolchains: | ||||||||||||||||||||||
| 746 | |||||||||||||||||||||||
| 747 | =over 2 | ||||||||||||||||||||||
| 748 | |||||||||||||||||||||||
| 749 | =item * C Based Dialects | ||||||||||||||||||||||
| 750 | |||||||||||||||||||||||
| 751 | =over 4 | ||||||||||||||||||||||
| 752 | |||||||||||||||||||||||
| 753 | =item * Languages | ||||||||||||||||||||||
| 754 | |||||||||||||||||||||||
| 755 | =over 6 | ||||||||||||||||||||||
| 756 | |||||||||||||||||||||||
| 757 | =item * C<objc> | ||||||||||||||||||||||
| 758 | |||||||||||||||||||||||
| 759 | Objective-C language | ||||||||||||||||||||||
| 760 | |||||||||||||||||||||||
| 761 | =back | ||||||||||||||||||||||
| 762 | |||||||||||||||||||||||
| 763 | =item * Shaders | ||||||||||||||||||||||
| 764 | |||||||||||||||||||||||
| 765 | =over 6 | ||||||||||||||||||||||
| 766 | |||||||||||||||||||||||
| 767 | =item * C<glsl> | ||||||||||||||||||||||
| 768 | |||||||||||||||||||||||
| 769 | Vulkan/OpenGL Shading Language. (Requires C<glslc>) | ||||||||||||||||||||||
| 770 | |||||||||||||||||||||||
| 771 | =back | ||||||||||||||||||||||
| 772 | |||||||||||||||||||||||
| 773 | =item * Microcontrollers | ||||||||||||||||||||||
| 774 | |||||||||||||||||||||||
| 775 | =over 6 | ||||||||||||||||||||||
| 776 | |||||||||||||||||||||||
| 777 | =item * C<arduino> | ||||||||||||||||||||||
| 778 | |||||||||||||||||||||||
| 779 | Arduino dialect. Requires C<avr-gcc> or C<arm-none-eabi-gcc>. | ||||||||||||||||||||||
| 780 | |||||||||||||||||||||||
| 781 | =item * C<esp32> | ||||||||||||||||||||||
| 782 | |||||||||||||||||||||||
| 783 | ESP32 specific dialect. Requires C<xtensa-esp32-elf-gcc>. | ||||||||||||||||||||||
| 784 | |||||||||||||||||||||||
| 785 | =item * C<pic> | ||||||||||||||||||||||
| 786 | |||||||||||||||||||||||
| 787 | Microchip PIC dialect. Requires C<xc8>, C<xc16>, or C<xc32>. | ||||||||||||||||||||||
| 788 | |||||||||||||||||||||||
| 789 | =item * C<avr> | ||||||||||||||||||||||
| 790 | |||||||||||||||||||||||
| 791 | Raw AVR dialect. Requires C<avr-gcc>. | ||||||||||||||||||||||
| 792 | |||||||||||||||||||||||
| 793 | =back | ||||||||||||||||||||||
| 794 | |||||||||||||||||||||||
| 795 | =back | ||||||||||||||||||||||
| 796 | |||||||||||||||||||||||
| 797 | =item * C++ Based Dialects | ||||||||||||||||||||||
| 798 | |||||||||||||||||||||||
| 799 | =over 4 | ||||||||||||||||||||||
| 800 | |||||||||||||||||||||||
| 801 | =item * Languages | ||||||||||||||||||||||
| 802 | |||||||||||||||||||||||
| 803 | =over 6 | ||||||||||||||||||||||
| 804 | |||||||||||||||||||||||
| 805 | =item * C<objcpp> | ||||||||||||||||||||||
| 806 | |||||||||||||||||||||||
| 807 | Objective-C++ language | ||||||||||||||||||||||
| 808 | |||||||||||||||||||||||
| 809 | =back | ||||||||||||||||||||||
| 810 | |||||||||||||||||||||||
| 811 | =item * Shaders | ||||||||||||||||||||||
| 812 | |||||||||||||||||||||||
| 813 | =over 6 | ||||||||||||||||||||||
| 814 | |||||||||||||||||||||||
| 815 | =item * C<metal> - Apple Metal Shading Language. (Based on C++14. Requires C<metal> compiler) | ||||||||||||||||||||||
| 816 | |||||||||||||||||||||||
| 817 | =back | ||||||||||||||||||||||
| 818 | |||||||||||||||||||||||
| 819 | =item * GPU Computing | ||||||||||||||||||||||
| 820 | |||||||||||||||||||||||
| 821 | =over 6 | ||||||||||||||||||||||
| 822 | |||||||||||||||||||||||
| 823 | =item * C<cuda> - NVIDIA CUDA dialect. (Requires C<nvcc>) | ||||||||||||||||||||||
| 824 | |||||||||||||||||||||||
| 825 | =item * C<hip> - AMD ROCm HIP dialect. (Requires C<hipcc>) | ||||||||||||||||||||||
| 826 | |||||||||||||||||||||||
| 827 | =item * C<sycl> - SYCL dialect for heterogeneous computing. (Requires C<dpc++>) | ||||||||||||||||||||||
| 828 | |||||||||||||||||||||||
| 829 | =back | ||||||||||||||||||||||
| 830 | |||||||||||||||||||||||
| 831 | =item * Hardware Logic Design (FPGA) | ||||||||||||||||||||||
| 832 | |||||||||||||||||||||||
| 833 | =over 6 | ||||||||||||||||||||||
| 834 | |||||||||||||||||||||||
| 835 | =item * C<hls> - High-Level Synthesis dialect. (Usually based on C++. Requires C<v++>) | ||||||||||||||||||||||
| 836 | |||||||||||||||||||||||
| 837 | =back | ||||||||||||||||||||||
| 838 | |||||||||||||||||||||||
| 839 | =back | ||||||||||||||||||||||
| 840 | |||||||||||||||||||||||
| 841 | =back | ||||||||||||||||||||||
| 842 | |||||||||||||||||||||||
| 843 | =head2 copyright_print_ccflags | ||||||||||||||||||||||
| 844 | |||||||||||||||||||||||
| 845 | my $copyright_print_ccflags = $config->copyright_print_ccflags; | ||||||||||||||||||||||
| 846 | $config->copyright_print_ccflags(['-nologo']); | ||||||||||||||||||||||
| 847 | |||||||||||||||||||||||
| 848 | Gets and sets the C<copyright_print_ccflags> field, an array reference containing compiler arguments to control the printing of the copyright banner or logo (e.g., C<-nologo> in MSVC). | ||||||||||||||||||||||
| 849 | |||||||||||||||||||||||
| 850 | =head2 language_ccflags | ||||||||||||||||||||||
| 851 | |||||||||||||||||||||||
| 852 | my $language_ccflags = $config->language_ccflags; | ||||||||||||||||||||||
| 853 | $config->language_ccflags($language_ccflags); | ||||||||||||||||||||||
| 854 | |||||||||||||||||||||||
| 855 | Gets and sets C<language_ccflags> field, an array reference containing arguments of the compiler L</"cc"> for language. | ||||||||||||||||||||||
| 856 | |||||||||||||||||||||||
| 857 | =head2 arch_ccflags | ||||||||||||||||||||||
| 858 | |||||||||||||||||||||||
| 859 | my $arch_ccflags = $config->arch_ccflags; | ||||||||||||||||||||||
| 860 | $config->arch_ccflags($arch_ccflags); | ||||||||||||||||||||||
| 861 | |||||||||||||||||||||||
| 862 | Gets and sets C<arch_ccflags> field, an array reference containing arguments of the compiler L</"cc"> for CPU architecture or host environment. | ||||||||||||||||||||||
| 863 | |||||||||||||||||||||||
| 864 | =head2 warn_ccflags | ||||||||||||||||||||||
| 865 | |||||||||||||||||||||||
| 866 | my $warn_ccflags = $config->warn_ccflags; | ||||||||||||||||||||||
| 867 | $config->warn_ccflags(['-Wall', '-Wextra']); | ||||||||||||||||||||||
| 868 | |||||||||||||||||||||||
| 869 | Gets and sets the C<warn_ccflags> field, an array reference containing compiler arguments for warning settings. | ||||||||||||||||||||||
| 870 | |||||||||||||||||||||||
| 871 | =head2 debug_info_ccflags | ||||||||||||||||||||||
| 872 | |||||||||||||||||||||||
| 873 | my $debug_info_ccflags = $config->debug_info_ccflags; | ||||||||||||||||||||||
| 874 | $config->debug_info_ccflags(['-g']); | ||||||||||||||||||||||
| 875 | |||||||||||||||||||||||
| 876 | Gets and sets the C<debug_info_ccflags> field, an array reference containing compiler arguments for generating debug information. | ||||||||||||||||||||||
| 877 | |||||||||||||||||||||||
| 878 | =head2 source_encoding_ccflags | ||||||||||||||||||||||
| 879 | |||||||||||||||||||||||
| 880 | my $source_encoding_ccflags = $config->source_encoding_ccflags; | ||||||||||||||||||||||
| 881 | $config->source_encoding_ccflags(['-finput-charset=UTF-8']); | ||||||||||||||||||||||
| 882 | |||||||||||||||||||||||
| 883 | Gets and sets the C<source_encoding_ccflags> field, an array reference containing compiler arguments for source file encoding settings. | ||||||||||||||||||||||
| 884 | |||||||||||||||||||||||
| 885 | =head2 function_level_linking_ccflags | ||||||||||||||||||||||
| 886 | |||||||||||||||||||||||
| 887 | my $function_level_linking_ccflags = $config->function_level_linking_ccflags; | ||||||||||||||||||||||
| 888 | $config->function_level_linking_ccflags(['-Gy']); | ||||||||||||||||||||||
| 889 | |||||||||||||||||||||||
| 890 | Gets and sets the C<function_level_linking_ccflags> field, an array reference containing compiler arguments to enable function-level linking (e.g., C<-Gy> in MSVC). | ||||||||||||||||||||||
| 891 | |||||||||||||||||||||||
| 892 | This allows the linker to optimize the executable size by removing unreferenced functions. | ||||||||||||||||||||||
| 893 | |||||||||||||||||||||||
| 894 | =head2 cpp_exception_handling | ||||||||||||||||||||||
| 895 | |||||||||||||||||||||||
| 896 | my $cpp_exception_handling = $config->cpp_exception_handling; | ||||||||||||||||||||||
| 897 | $config->cpp_exception_handling(1); | ||||||||||||||||||||||
| 898 | |||||||||||||||||||||||
| 899 | Gets and sets the C<cpp_exception_handling> field, a boolean value that indicates whether C++ exception handling is enabled. | ||||||||||||||||||||||
| 900 | |||||||||||||||||||||||
| 901 | If this value is true, the compiler is configured to support C++ exceptions (e.g., C<-EHsc> in MSVC, C<-fexceptions> in GCC). | ||||||||||||||||||||||
| 902 | Defaults to undef. | ||||||||||||||||||||||
| 903 | |||||||||||||||||||||||
| 904 | =head2 library_linkage_ccflags | ||||||||||||||||||||||
| 905 | |||||||||||||||||||||||
| 906 | my $library_linkage_ccflags = $config->library_linkage_ccflags; | ||||||||||||||||||||||
| 907 | $config->library_linkage_ccflags(['-MT']); | ||||||||||||||||||||||
| 908 | |||||||||||||||||||||||
| 909 | Gets and sets the C<library_linkage_ccflags> field, an array reference containing compiler arguments to specify the library linkage (e.g., static or dynamic linking). | ||||||||||||||||||||||
| 910 | |||||||||||||||||||||||
| 911 | These flags are passed to the compiler L</"cc"> to determine how libraries (such as the C runtime library) are linked. For example, C<-MT> or C<-MD> in MSVC. | ||||||||||||||||||||||
| 912 | |||||||||||||||||||||||
| 913 | =head2 cc_output_option_name | ||||||||||||||||||||||
| 914 | |||||||||||||||||||||||
| 915 | my $cc_output_option_name = $config->cc_output_option_name; | ||||||||||||||||||||||
| 916 | $config->cc_output_option_name($cc_output_option_name); | ||||||||||||||||||||||
| 917 | |||||||||||||||||||||||
| 918 | Gets and sets C<cc_output_option_name> field, a string that is an option name to specify a compiler output file name. | ||||||||||||||||||||||
| 919 | |||||||||||||||||||||||
| 920 | =head1 Class Methods | ||||||||||||||||||||||
| 921 | |||||||||||||||||||||||
| 922 | =head2 new | ||||||||||||||||||||||
| 923 | |||||||||||||||||||||||
| 924 | my $config = SPVM::Builder::Config->new(%fields); | ||||||||||||||||||||||
| 925 | |||||||||||||||||||||||
| 926 | Creates a new C<SPVM::Builder::Config> object. This method calls the C<new> method of the super class L<SPVM::Builder::Config::Linker>. | ||||||||||||||||||||||
| 927 | |||||||||||||||||||||||
| 928 | Default settings for the GCC or Clang compiler are performed. | ||||||||||||||||||||||
| 929 | |||||||||||||||||||||||
| 930 | Field Default Values: | ||||||||||||||||||||||
| 931 | |||||||||||||||||||||||
| 932 | =over 2 | ||||||||||||||||||||||
| 933 | |||||||||||||||||||||||
| 934 | =item * L</"cc"> | ||||||||||||||||||||||
| 935 | |||||||||||||||||||||||
| 936 | undef | ||||||||||||||||||||||
| 937 | |||||||||||||||||||||||
| 938 | =item * L</"ccflags"> | ||||||||||||||||||||||
| 939 | |||||||||||||||||||||||
| 940 | [] | ||||||||||||||||||||||
| 941 | |||||||||||||||||||||||
| 942 | =item * L</"defines"> | ||||||||||||||||||||||
| 943 | |||||||||||||||||||||||
| 944 | [] | ||||||||||||||||||||||
| 945 | |||||||||||||||||||||||
| 946 | =item * L</"cc_version"> | ||||||||||||||||||||||
| 947 | |||||||||||||||||||||||
| 948 | The return value of L</"create_cc_version">. | ||||||||||||||||||||||
| 949 | |||||||||||||||||||||||
| 950 | =item * L</"optimize"> | ||||||||||||||||||||||
| 951 | |||||||||||||||||||||||
| 952 | "" | ||||||||||||||||||||||
| 953 | |||||||||||||||||||||||
| 954 | =item * L</"copyright_print_ccflags"> | ||||||||||||||||||||||
| 955 | |||||||||||||||||||||||
| 956 | [] | ||||||||||||||||||||||
| 957 | |||||||||||||||||||||||
| 958 | =item * L</"language_ccflags"> | ||||||||||||||||||||||
| 959 | |||||||||||||||||||||||
| 960 | [] | ||||||||||||||||||||||
| 961 | |||||||||||||||||||||||
| 962 | =item * L</"arch_ccflags"> | ||||||||||||||||||||||
| 963 | |||||||||||||||||||||||
| 964 | [] | ||||||||||||||||||||||
| 965 | |||||||||||||||||||||||
| 966 | =item * L</"warn_ccflags"> | ||||||||||||||||||||||
| 967 | |||||||||||||||||||||||
| 968 | [] | ||||||||||||||||||||||
| 969 | |||||||||||||||||||||||
| 970 | =item * L</"debug_info_ccflags"> | ||||||||||||||||||||||
| 971 | |||||||||||||||||||||||
| 972 | [] | ||||||||||||||||||||||
| 973 | |||||||||||||||||||||||
| 974 | =item * L</"source_encoding_ccflags"> | ||||||||||||||||||||||
| 975 | |||||||||||||||||||||||
| 976 | [] | ||||||||||||||||||||||
| 977 | |||||||||||||||||||||||
| 978 | =item * L</"function_level_linking_ccflags"> | ||||||||||||||||||||||
| 979 | |||||||||||||||||||||||
| 980 | [] | ||||||||||||||||||||||
| 981 | |||||||||||||||||||||||
| 982 | =item * L</"cpp_exception_handling_ccflags"> | ||||||||||||||||||||||
| 983 | |||||||||||||||||||||||
| 984 | Windows: | ||||||||||||||||||||||
| 985 | |||||||||||||||||||||||
| 986 | ['-D__USE_MINGW_ANSI_STDIO'] | ||||||||||||||||||||||
| 987 | |||||||||||||||||||||||
| 988 | Other OSs: | ||||||||||||||||||||||
| 989 | |||||||||||||||||||||||
| 990 | [] | ||||||||||||||||||||||
| 991 | |||||||||||||||||||||||
| 992 | =item * L</"library_linkage_ccflags"> | ||||||||||||||||||||||
| 993 | |||||||||||||||||||||||
| 994 | [] | ||||||||||||||||||||||
| 995 | |||||||||||||||||||||||
| 996 | =item * L</"position_independent_code_ccflags"> | ||||||||||||||||||||||
| 997 | |||||||||||||||||||||||
| 998 | Windows: | ||||||||||||||||||||||
| 999 | |||||||||||||||||||||||
| 1000 | [] | ||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||
| 1002 | Other OSs: | ||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||
| 1004 | ["-fPIC"] | ||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||
| 1006 | =item * L</"thread_ccflags"> | ||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||
| 1008 | ["-pthread"] | ||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||
| 1010 | =item * L</"extra_ccflags"> | ||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||
| 1012 | [] | ||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||
| 1014 | =item * L</"ndebug_ccflags"> | ||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||
| 1016 | ["-DNDEBUG"] | ||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||
| 1018 | =item * L</"debug_file_synchronized_write_ccflags"> | ||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||
| 1020 | [] | ||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||
| 1022 | =item * L</"include_dirs"> | ||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||
| 1024 | [] | ||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||
| 1026 | =item * L</"spvm_core_include_dir"> | ||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||
| 1028 | The SPVM core header file search directory. | ||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||
| 1030 | =item * L</"resource_include_dirs"> | ||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||
| 1032 | [] | ||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||
| 1034 | =item * L</"native_include_dir"> | ||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||
| 1036 | The directory described in L<SPVM::Document::NativeClass/"Native Header Files">. | ||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||
| 1038 | =item * L</"source_files"> | ||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||
| 1040 | [] | ||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||
| 1042 | =item * L</"cc_output_option_name"> | ||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||
| 1044 | "-o" | ||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||
| 1046 | =back | ||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||
| 1048 | =cut | ||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||
| 1050 | =head2 new_c | ||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||
| 1052 | my $config = SPVM::Builder::Config->new_c; | ||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||
| 1054 | Calls L</"new"> method and sets L</"ext"> field to C<c>, L</"language"> field to C<c>, L</"cc"> field to a C++ compiler, and returns the return value of L</"new"> method. | ||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||
| 1056 | =head2 new_c99 | ||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||
| 1058 | my $config = SPVM::Builder::Config->new_c99; | ||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||
| 1060 | Calls L</"new_c"> method and sets L</"std"> field to C<c99>, and returns the return value of L</"new_c"> method. | ||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||
| 1062 | =head2 new_c11 | ||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||
| 1064 | my $config = SPVM::Builder::Config->new_c11; | ||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||
| 1066 | Calls L</"new_c"> method and sets L</"std"> field to C<c11>, and returns the return value of L</"new_c"> method. | ||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||
| 1068 | =head2 new_c17 | ||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||
| 1070 | my $config = SPVM::Builder::Config->new_c17; | ||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||
| 1072 | Calls L</"new_c"> method and sets L</"std"> field to C<c17>, and returns the return value of L</"new_c"> method. | ||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||
| 1074 | =head2 new_c23 | ||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||
| 1076 | my $config = SPVM::Builder::Config->new_c23; | ||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||
| 1078 | Calls L</"new_c"> method and sets L</"std"> field to C<c23>, and returns the return value of L</"new_c"> method. | ||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||
| 1080 | =head2 new_cpp | ||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||
| 1082 | my $config = SPVM::Builder::Config->new_cpp; | ||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||
| 1084 | Calls L</"new"> method and sets L</"ext"> field to C<cpp>, L</"language"> field to C<cpp>, L</"cc"> field to a C++ compiler, and L</"ld"> field to a C++ linker, and returns the return value of L</"new"> method. | ||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||
| 1086 | If C<$Config{gccversion}> contains C<clang>, L</"cc"> field and L</"ld"> field are set to C<clang++>. Otherwise, L</"cc"> field and L</"ld"> field are set to C<g++>. | ||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||
| 1088 | =head2 new_cpp11 | ||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||
| 1090 | my $config = SPVM::Builder::Config->new_cpp11; | ||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||
| 1092 | Calls L</"new_cpp"> method and sets L</"std"> field to C<c++11>, and returns the return value of L</"new_cpp"> method. | ||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||
| 1094 | =head2 new_cpp14 | ||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||
| 1096 | my $config = SPVM::Builder::Config->new_cpp14; | ||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||
| 1098 | Calls L</"new_cpp"> method and sets L</"std"> field to C<c++14>, and returns the return value of L</"new_cpp"> method. | ||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||
| 1100 | =head2 new_cpp17 | ||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||
| 1102 | my $config = SPVM::Builder::Config->new_cpp17; | ||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||
| 1104 | Calls L</"new_cpp"> method and sets L</"std"> field to C<c++17>, and returns the return value of L</"new_cpp"> method. | ||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||
| 1106 | =head2 new_cpp20 | ||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||
| 1108 | my $config = SPVM::Builder::Config->new_cpp20; | ||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||
| 1110 | Calls L</"new_cpp"> method and sets L</"std"> field to C<c++20>, and returns the return value of L</"new_cpp"> method. | ||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||
| 1112 | =head2 new_cpp23 | ||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||
| 1114 | my $config = SPVM::Builder::Config->new_cpp23; | ||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||
| 1116 | Calls L</"new_cpp"> method and sets L</"std"> field to C<c++23>, and returns the return value of L</"new_cpp"> method. | ||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||
| 1118 | =head1 Instance Methods | ||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||
| 1120 | =head2 add_ccflag | ||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||
| 1122 | $config->add_ccflag(@ccflags); | ||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||
| 1124 | Adds @ccflags to the end of L</"ccflags"> field. | ||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||
| 1126 | =head2 add_define | ||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||
| 1128 | $config->add_define(@defines); | ||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||
| 1130 | Adds @defines to the end of L</"defines"> field. | ||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||
| 1132 | =head2 add_include_dir | ||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||
| 1134 | $config->add_include_dir(@include_dirs); | ||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||
| 1136 | Adds @include_dirs to the end of L</"include_dirs"> field. | ||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||
| 1138 | =head2 add_source_file | ||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||
| 1140 | $config->add_source_file(@source_files); | ||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||
| 1142 | Adds @source_files to the end of L</"source_files"> field. | ||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||
| 1144 | Examples: | ||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||
| 1146 | $config->add_source_file('foo.c', 'bar.c'); | ||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||
| 1148 | =head2 clear_system_fields | ||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||
| 1150 | $config->clear_system_fields; | ||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||
| 1152 | Clears the fields that are set by default for a specific environment. | ||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||
| 1154 | These fields might be updated in the future to support appropriate settings for different environments. | ||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||
| 1156 | This method calls the L<clear_system_fields|SPVM::Builder::Config::Linker/"clear_system_fields"> method of the L<SPVM::Builder::Config::Linker> class to clear linker settings. | ||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||
| 1158 | Then it clears the compiler settings whose field names are returned by the L<get_cc_system_field_names|/"get_cc_system_field_names"> method by setting them to C<[]>. | ||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||
| 1160 | =cut | ||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||
| 1162 | =head2 get_cc_system_field_names | ||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||
| 1164 | my $field_names = $config->get_cc_system_field_names; | ||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||
| 1166 | Returns the field names of the compiler settings that are set by default for a specific environment. | ||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||
| 1168 | These fields might be updated in the future to support appropriate settings for different environments. | ||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||
| 1170 | The field names returned by this method are used by the L<clear_system_fields|/"clear_system_fields"> method to clear the compiler settings. | ||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||
| 1172 | The following field names are returned: | ||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||
| 1174 | =over 2 | ||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||
| 1176 | =item * C<position_independent_code_ccflags> | ||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||
| 1178 | =item * C<thread_ccflags> | ||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||
| 1180 | =item * C<extra_ccflags> | ||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||
| 1182 | =item * C<ndebug_ccflags> | ||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||
| 1184 | =item * C<debug_file_synchronized_write_ccflags> | ||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||
| 1186 | =item * C<copyright_print_ccflags> | ||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||
| 1188 | =item * C<language_ccflags> | ||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||
| 1190 | =item * C<arch_ccflags> | ||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||
| 1192 | =item * C<warn_ccflags> | ||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||
| 1194 | =item * C<debug_info_ccflags> | ||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||
| 1196 | =item * C<source_encoding_ccflags> | ||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||
| 1198 | =item * C<function_level_linking_ccflags> | ||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||
| 1200 | =item * C<cpp_exception_handling_ccflags> | ||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||
| 1202 | =item * C<library_linkage_ccflags> | ||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||
| 1204 | =back | ||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||
| 1206 | =cut | ||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||
| 1208 | =head2 create_cc_version | ||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||
| 1210 | my $cc_version = $config->create_cc_version; | ||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||
| 1212 | Executes the compiler defined in L</"cc"> with the C<--version> option and returns the output. | ||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||
| 1214 | The return value contains the compiler command itself and its version information (the first line of the output). | ||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||
| 1216 | If the execution fails, an empty string is returned. | ||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||
| 1218 | This information is intended to be used as a part of the digest for the build cache. | ||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||
| 1220 | =head2 native_include_dir | ||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||
| 1222 | my $native_include_dir = $config->native_include_dir; | ||||||||||||||||||||||
| 1223 | $config->native_include_dir($native_include_dir); | ||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||
| 1225 | Creates the path of C<include> header directory for the native class. | ||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||
| 1227 | =head2 native_src_dir | ||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||
| 1229 | my $native_src_dir = $config->native_src_dir; | ||||||||||||||||||||||
| 1230 | $config->native_src_dir($native_src_dir); | ||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||
| 1232 | Creates the path of C<src> source directory for the native class. | ||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||
| 1234 | =head1 Copyright & License | ||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||
| 1236 | Copyright (c) 2023 Yuki Kimoto | ||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||
| 1238 | MIT License | ||||||||||||||||||||||