File Coverage

blib/lib/SPVM/Builder/Config/Exe.pm
Criterion Covered Total %
statement 47 47 100.0
branch 10 14 71.4
condition n/a
subroutine 11 11 100.0
pod 4 5 80.0
total 72 77 93.5


line stmt bran cond sub pod time code
1             package SPVM::Builder::Config::Exe;
2              
3 2     2   69150 use strict;
  2         11  
  2         62  
4 2     2   9 use warnings;
  2         4  
  2         49  
5 2     2   13 use Carp 'confess';
  2         4  
  2         222  
6              
7 2     2   486 use SPVM::Builder::Util;
  2         5  
  2         59  
8 2     2   417 use SPVM::Builder::Util::API;
  2         3  
  2         54  
9              
10             # Inheritance
11 2     2   27 use base 'SPVM::Builder::Config';
  2         4  
  2         1069  
12              
13             # Fields
14             sub before_each_compile_cbs {
15 117     117 0 334 my $self = shift;
16 117 100       420 if (@_) {
17 3         13 $self->{before_each_compile_cbs} = $_[0];
18 3         11 return $self;
19             }
20             else {
21 114         419 return $self->{before_each_compile_cbs};
22             }
23             }
24              
25             sub config_spvm_core {
26 8     8 1 18 my $self = shift;
27 8 100       21 if (@_) {
28 3         11 $self->{config_spvm_core} = $_[0];
29 3         6 return $self;
30             }
31             else {
32 5         22 return $self->{config_spvm_core};
33             }
34             }
35              
36             sub config_bootstrap {
37 8     8 1 25 my $self = shift;
38 8 100       23 if (@_) {
39 3         20 $self->{config_bootstrap} = $_[0];
40 3         19 return $self;
41             }
42             else {
43 5         35 return $self->{config_bootstrap};
44             }
45             }
46              
47             # Class Methods
48             sub new {
49 3     3 1 103 my ($self, %fields) = @_;
50              
51 3 50       19 unless (defined $fields{output_type}) {
52 3         10 $fields{output_type} = 'exe';
53             }
54            
55 3         32 $self = $self->SUPER::new(%fields);
56            
57 3 50       20 unless (defined $self->before_each_compile_cbs) {
58 3         10 $self->before_each_compile_cbs([]);
59             }
60            
61 3 50       18 unless (defined $self->config_spvm_core) {
62 3         34 $self->config_spvm_core(SPVM::Builder::Util::API::create_default_config());
63             }
64            
65 3 50       17 unless (defined $self->config_bootstrap) {
66 3         13 $self->config_bootstrap(SPVM::Builder::Util::API::create_default_config());
67             }
68            
69 3         21 return $self;
70             }
71              
72             # Instance Methods
73             sub add_before_each_compile_cb {
74 1     1 1 9 my ($self, @before_each_compile_cbs) = @_;
75            
76 1         3 push @{$self->{before_each_compile_cbs}}, @before_each_compile_cbs;
  1         4  
77             }
78              
79             1;
80              
81             =head1 Name
82              
83             SPVM::Builder::Config::Exe - Configurations of creating excutable files.
84              
85             =head1 Description
86              
87             The SPVM::Builder::Config::Exe class has methods to manipulate a config to generate an excutable file using L.
88              
89             =head1 Usage
90              
91             use SPVM::Builder::Config::Exe;
92            
93             my $config_exe = SPVM::Builder::Config::Exe->new_gnu99;
94              
95             =head1 Inheritance
96              
97             =over 2
98              
99             =item * L
100              
101             =back
102              
103             =head1 Fields
104              
105             =head2 config_spvm_core
106              
107             my $config_exe_spvm_core = $config_exe->config_spvm_core;
108             $config_exe->config_spvm_core($config_exe_spvm_core);
109              
110             Gets and sets the C field.
111              
112             This field is a L object for SPVM core source files.
113              
114             =head2 config_bootstrap
115              
116             my $config_exe_bootstrap = $config_exe->config_bootstrap;
117             $config_exe->config_bootstrap($config_exe_bootstrap);
118              
119             Gets and sets the C field.
120              
121             This field is a L object for the bootstrap source file that contains C
function in the C language for the executable file.
122              
123             =head1 Methods
124              
125             =head2 new
126              
127             my $config_exe = SPVM::Builder::Config::Exe->new(%fields);
128              
129             Create a new C object with L.
130              
131             This method calls the C method of the L before the own operations of this method.
132              
133             Default Field Values:
134              
135             If a field is not defined, the field is set to the following default value.
136              
137             =over 2
138              
139             =item * L
140              
141             "exe"
142              
143             =item * L
144              
145             []
146              
147             =item * L
148              
149             The return value of the L function of the L class.
150              
151             =item * L
152              
153             The return value of the L function of the L class.
154              
155             =back
156              
157             =head2 add_before_each_compile_cb
158              
159             $config_exe->add_before_compile_cb(@before_each_compile_cbs);
160              
161             Adds elements after the last element of the L field.
162              
163             =head1 Copyright & License
164              
165             Copyright (c) 2023 Yuki Kimoto
166              
167             MIT License