line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package InlineX::C2XS; |
2
|
15
|
|
|
15
|
|
7376
|
use warnings; |
|
15
|
|
|
|
|
91
|
|
|
15
|
|
|
|
|
386
|
|
3
|
15
|
|
|
15
|
|
68
|
use strict; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
264
|
|
4
|
15
|
|
|
15
|
|
62
|
use Carp; |
|
15
|
|
|
|
|
27
|
|
|
15
|
|
|
|
|
1366
|
|
5
|
15
|
|
|
15
|
|
87
|
use Config; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
1389
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw(c2xs context); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.27'; |
13
|
|
|
|
|
|
|
#$VERSION = eval $VERSION; |
14
|
|
|
|
|
|
|
|
15
|
15
|
|
|
15
|
|
5316
|
use InlineX::C2XS::Context; |
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
44789
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $config_options; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @allowable_config_keys = ('AUTOWRAP', 'AUTO_INCLUDE', 'CODE', 'DIST', 'TYPEMAPS', 'LIBS', 'INC', |
20
|
|
|
|
|
|
|
'WRITE_MAKEFILE_PL', 'BUILD_NOISY', 'BOOT', 'BOOT_F', 'EXPORT_ALL', 'EXPORT_OK_ALL', 'MANIF', |
21
|
|
|
|
|
|
|
'EXPORT_TAGS_ALL', 'MAKE', 'PREFIX', 'PREREQ_PM', 'CCFLAGS', 'CCFLAGSEX', 'LD', 'LDDLFLAGS', |
22
|
|
|
|
|
|
|
'MYEXTLIB', 'OBJECT', 'OPTIMIZE', 'PRE_HEAD', 'PROTOTYPE', 'PROTOTYPES', 'CC', 'SRC_LOCATION', 'T', |
23
|
|
|
|
|
|
|
'_TESTING', 'USE', 'USING', 'WRITE_PM', 'VERSION'); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
##=========================## |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub c2xs { |
28
|
30
|
|
|
30
|
0
|
7543
|
eval {require "Inline/C.pm"}; |
|
30
|
|
|
|
|
6369
|
|
29
|
30
|
50
|
|
|
|
561054
|
if($@) {die "Need a functioning Inline::C (version 0.46_01 or later). $@"} |
|
0
|
|
|
|
|
0
|
|
30
|
30
|
|
|
|
|
154
|
my $module = shift; |
31
|
30
|
|
|
|
|
48
|
my $pkg = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Set the default for $build_dir. |
34
|
|
|
|
|
|
|
# (This will be overwritten by a supplied build_dir argument.) |
35
|
30
|
|
|
|
|
45
|
my $build_dir = '.'; |
36
|
|
|
|
|
|
|
|
37
|
30
|
50
|
|
|
|
84
|
if(@_) { |
38
|
30
|
100
|
|
|
|
102
|
if(ref($_[0]) eq "HASH") { |
39
|
12
|
|
|
|
|
25
|
$config_options = shift; |
40
|
|
|
|
|
|
|
# Check for invalid config options - and die if one is found |
41
|
12
|
100
|
|
|
|
32
|
for(keys(%$config_options)) { die "$_ is an invalid config option" if !_check_config_keys($_)} |
|
17
|
|
|
|
|
31
|
|
42
|
10
|
100
|
|
|
|
19
|
if(@_) {die "Incorrect usage - there should be no arguments to c2xs() after the hash reference"} |
|
2
|
|
|
|
|
10
|
|
43
|
|
|
|
|
|
|
} |
44
|
18
|
|
|
|
|
39
|
else {$build_dir = shift} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
26
|
100
|
|
|
|
89
|
if(@_) { |
48
|
16
|
100
|
|
|
|
64
|
if(ref($_[0]) ne "HASH") {die "Fourth arg to c2xs() needs to be a hash containing config options ... but it's not !!\n"} |
|
4
|
|
|
|
|
18
|
|
49
|
12
|
|
|
|
|
23
|
$config_options = shift; |
50
|
|
|
|
|
|
|
# Check for invalid config options - and die if one is found |
51
|
12
|
50
|
|
|
|
91
|
for(keys(%$config_options)) { die "$_ is an invalid config option" if !_check_config_keys($_)} |
|
89
|
|
|
|
|
142
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
22
|
100
|
|
|
|
468
|
unless(-d $build_dir) { |
55
|
2
|
|
|
|
|
24
|
die "$build_dir is not a valid directory"; |
56
|
|
|
|
|
|
|
} |
57
|
20
|
|
|
|
|
121
|
my $modfname = (split /::/, $module)[-1]; |
58
|
20
|
100
|
|
|
|
89
|
my $need_inline_h = $config_options->{AUTOWRAP} ? 1 : 0; |
59
|
20
|
|
|
|
|
36
|
my $code = ''; |
60
|
20
|
|
|
|
|
29
|
my $o; |
61
|
|
|
|
|
|
|
|
62
|
20
|
100
|
100
|
|
|
86
|
if(exists($config_options->{CODE}) && exists($config_options->{SRC_LOCATION})) { |
63
|
2
|
|
|
|
|
14
|
die "You can provide either CODE *or* SRC_LOCATION arguments ... but not *both*"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
18
|
50
|
66
|
|
|
72
|
if(exists($config_options->{BOOT}) && exists($config_options->{BOOT_F})) { |
67
|
0
|
|
|
|
|
0
|
die "You can provide either BOOT *or* BOOT_F arguments ... but not *both*"; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
18
|
100
|
|
|
|
63
|
if(exists($config_options->{CODE})) { |
|
|
100
|
|
|
|
|
|
71
|
4
|
|
|
|
|
9
|
$code = $config_options->{CODE}; |
72
|
4
|
50
|
|
|
|
30
|
if($code =~ /inline_stack_vars/i) {$need_inline_h = 1 } |
|
0
|
|
|
|
|
0
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
elsif(exists($config_options->{SRC_LOCATION})) { |
75
|
4
|
100
|
|
|
|
608
|
open(RD, "<", $config_options->{SRC_LOCATION}) or die "Can't open ", $config_options->{SRC_LOCATION}, " for reading: $!"; |
76
|
2
|
|
|
|
|
50
|
while() { |
77
|
4
|
|
|
|
|
12
|
$code .= $_; |
78
|
4
|
50
|
|
|
|
34
|
if($_ =~ /inline_stack_vars/i) {$need_inline_h = 1} |
|
0
|
|
|
|
|
0
|
|
79
|
|
|
|
|
|
|
} |
80
|
2
|
50
|
|
|
|
32
|
close(RD) or die "Can't close ", $config_options->{SRC_LOCATION}, " after reading: $!"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
else { |
83
|
10
|
50
|
|
|
|
371
|
open(RD, "<", "src/$modfname.c") or die "Can't open src/${modfname}.c for reading: $!"; |
84
|
10
|
|
|
|
|
190
|
while() { |
85
|
916
|
|
|
|
|
979
|
$code .= $_; |
86
|
916
|
100
|
|
|
|
1745
|
if($_ =~ /inline_stack_vars/i) {$need_inline_h = 1} |
|
4
|
|
|
|
|
10
|
|
87
|
|
|
|
|
|
|
} |
88
|
10
|
50
|
|
|
|
111
|
close(RD) or die "Can't close src/$modfname.c after reading: $!"; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
## Initialise $o. |
92
|
|
|
|
|
|
|
## Many of these keys may not be needed for the purpose of this |
93
|
|
|
|
|
|
|
## specific exercise - but they shouldn't do any harm, so I'll |
94
|
|
|
|
|
|
|
## leave them in, just in case they're ever needed. |
95
|
16
|
|
|
|
|
62
|
$o->{CONFIG}{BUILD_TIMERS} = 0; |
96
|
16
|
|
|
|
|
43
|
$o->{CONFIG}{PRINT_INFO} = 0; |
97
|
16
|
|
|
|
|
46
|
$o->{CONFIG}{USING} = []; |
98
|
16
|
|
|
|
|
37
|
$o->{CONFIG}{WARNINGS} = 1; |
99
|
16
|
|
|
|
|
32
|
$o->{CONFIG}{PRINT_VERSION} = 0; |
100
|
16
|
|
|
|
|
35
|
$o->{CONFIG}{CLEAN_BUILD_AREA} = 0; |
101
|
16
|
|
|
|
|
34
|
$o->{CONFIG}{GLOBAL_LOAD} = 0; |
102
|
16
|
|
|
|
|
45
|
$o->{CONFIG}{DIRECTORY} = ''; |
103
|
16
|
|
|
|
|
41
|
$o->{CONFIG}{SAFEMODE} = -1; |
104
|
16
|
|
|
|
|
33
|
$o->{CONFIG}{CLEAN_AFTER_BUILD} = 1; |
105
|
16
|
|
|
|
|
31
|
$o->{CONFIG}{FORCE_BUILD} = 0; |
106
|
16
|
|
|
|
|
39
|
$o->{CONFIG}{NAME} = ''; |
107
|
16
|
|
|
|
|
33
|
$o->{CONFIG}{_INSTALL_} = 0; |
108
|
16
|
|
|
|
|
32
|
$o->{CONFIG}{WITH} = []; |
109
|
16
|
|
|
|
|
33
|
$o->{CONFIG}{AUTONAME} = 1; |
110
|
16
|
|
|
|
|
40
|
$o->{CONFIG}{REPORTBUG} = 0; |
111
|
16
|
|
|
|
|
33
|
$o->{CONFIG}{UNTAINT} = 0; |
112
|
16
|
|
|
|
|
40
|
$o->{CONFIG}{VERSION} = ''; |
113
|
16
|
|
|
|
|
32
|
$o->{CONFIG}{BUILD_NOISY} = 1; |
114
|
16
|
|
|
|
|
185
|
$o->{INLINE}{ILSM_suffix} = $Config::Config{dlext}; |
115
|
16
|
|
|
|
|
49
|
$o->{INLINE}{ILSM_module} = 'Inline::C'; |
116
|
16
|
|
|
|
|
41
|
$o->{INLINE}{version} = $Inline::VERSION; |
117
|
16
|
|
|
|
|
108
|
$o->{INLINE}{ILSM_type} = 'compiled'; |
118
|
16
|
|
|
|
|
36
|
$o->{INLINE}{DIRECTORY} = 'irrelevant_0'; |
119
|
16
|
|
|
|
|
35
|
$o->{INLINE}{object_ready} = 0; |
120
|
16
|
|
|
|
|
38
|
$o->{INLINE}{md5} = 'irrelevant_1'; |
121
|
16
|
|
|
|
|
37
|
$o->{API}{modfname} = $modfname; |
122
|
16
|
|
|
|
|
39
|
$o->{API}{script} = 'irrelevant_2'; |
123
|
16
|
|
|
|
|
33
|
$o->{API}{location} = 'irrelevant_3'; |
124
|
16
|
|
|
|
|
33
|
$o->{API}{language} = 'C'; |
125
|
16
|
|
|
|
|
31
|
$o->{API}{modpname} = 'irrelevant_4'; |
126
|
16
|
|
|
|
|
35
|
$o->{API}{directory} = 'irrelevant_5'; |
127
|
16
|
|
|
|
|
28
|
$o->{API}{install_lib} = 'irrelevant_6'; |
128
|
16
|
|
|
|
|
37
|
$o->{API}{build_dir} = $build_dir; |
129
|
16
|
|
|
|
|
30
|
$o->{API}{language_id} = 'C'; |
130
|
16
|
|
|
|
|
31
|
$o->{API}{pkg} = $pkg; |
131
|
16
|
|
|
|
|
73
|
$o->{API}{suffix} = $Config::Config{dlext}; |
132
|
16
|
|
|
|
|
44
|
$o->{API}{cleanup} = 1; |
133
|
16
|
|
|
|
|
34
|
$o->{API}{module} = $module; |
134
|
16
|
|
|
|
|
42
|
$o->{API}{code} = $code; |
135
|
|
|
|
|
|
|
|
136
|
16
|
50
|
|
|
|
49
|
if(exists($config_options->{PROTOTYPE})) {$o->{CONFIG}{PROTOTYPE} = $config_options->{PROTOTYPE}} |
|
0
|
|
|
|
|
0
|
|
137
|
|
|
|
|
|
|
|
138
|
16
|
50
|
|
|
|
42
|
if(exists($config_options->{PROTOTYPES})) {$o->{CONFIG}{PROTOTYPES} = $config_options->{PROTOTYPES}} |
|
0
|
|
|
|
|
0
|
|
139
|
|
|
|
|
|
|
|
140
|
16
|
100
|
|
|
|
40
|
if(exists($config_options->{BUILD_NOISY})) {$o->{CONFIG}{BUILD_NOISY} = $config_options->{BUILD_NOISY}} |
|
2
|
|
|
|
|
4
|
|
141
|
|
|
|
|
|
|
|
142
|
16
|
50
|
|
|
|
49
|
if(exists($config_options->{_TESTING})) {$o->{CONFIG}{_TESTING} = $config_options->{_TESTING}} # Internal testing flag |
|
0
|
|
|
|
|
0
|
|
143
|
|
|
|
|
|
|
|
144
|
16
|
100
|
|
|
|
48
|
if($config_options->{AUTOWRAP}) {$o->{ILSM}{AUTOWRAP} = 1} |
|
10
|
|
|
|
|
26
|
|
145
|
|
|
|
|
|
|
|
146
|
16
|
100
|
|
|
|
50
|
if($config_options->{BOOT}) {$o->{ILSM}{XS}{BOOT} = $config_options->{BOOT}} |
|
2
|
|
|
|
|
6
|
|
147
|
|
|
|
|
|
|
|
148
|
16
|
100
|
|
|
|
47
|
if($config_options->{DIST}) { |
149
|
1
|
|
|
|
|
3
|
$config_options->{WRITE_MAKEFILE_PL} = 1; |
150
|
1
|
|
|
|
|
2
|
$config_options->{WRITE_PM} = 1; |
151
|
1
|
|
|
|
|
3
|
$config_options->{MANIF} = 1; |
152
|
1
|
|
|
|
|
3
|
$config_options->{T} = 1; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
16
|
50
|
|
|
|
42
|
if($config_options->{BOOT_F}) { |
156
|
0
|
|
|
|
|
0
|
my $code; |
157
|
0
|
0
|
|
|
|
0
|
open(RD, "<", $config_options->{BOOT_F}) or die "Can't open ", $config_options->{BOOT_F}, " for reading: $!"; |
158
|
0
|
|
|
|
|
0
|
while() { |
159
|
0
|
|
|
|
|
0
|
$code .= $_; |
160
|
0
|
0
|
|
|
|
0
|
if($_ =~ /inline_stack_vars/i) {$need_inline_h = 1} |
|
0
|
|
|
|
|
0
|
|
161
|
|
|
|
|
|
|
} |
162
|
0
|
0
|
|
|
|
0
|
close(RD) or die "Can't close ", $config_options->{BOOT_F}, " after reading: $!"; |
163
|
0
|
|
|
|
|
0
|
$o->{ILSM}{XS}{BOOT} = $code; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# This is what Inline::C does with the MAKE parameter ... so we'll do the same. |
167
|
|
|
|
|
|
|
# Not sure that this achieves anything in the context of InlineX::C2XS. |
168
|
16
|
100
|
|
|
|
53
|
if($config_options->{MAKE}) {$o->{ILSM}{MAKE} = $config_options->{MAKE}} |
|
2
|
|
|
|
|
5
|
|
169
|
|
|
|
|
|
|
|
170
|
16
|
100
|
|
|
|
44
|
if(exists($config_options->{TYPEMAPS})) { |
171
|
12
|
|
|
|
|
28
|
my $val =$config_options->{TYPEMAPS}; |
172
|
12
|
100
|
|
|
|
48
|
if(ref($val) eq 'ARRAY') { |
173
|
9
|
|
|
|
|
16
|
for(@{$val}) { |
|
9
|
|
|
|
|
26
|
|
174
|
9
|
100
|
|
|
|
217
|
die "Couldn't locate the typemap $_" unless -f $_; |
175
|
|
|
|
|
|
|
} |
176
|
7
|
|
|
|
|
33
|
$o->{ILSM}{MAKEFILE}{TYPEMAPS} = $val; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
else { |
179
|
3
|
|
|
|
|
15
|
my @vals = split /\s+/, $val; |
180
|
3
|
|
|
|
|
9
|
for(@vals) { |
181
|
3
|
50
|
|
|
|
49
|
die "Couldn't locate the typemap $_" unless -f $_; |
182
|
|
|
|
|
|
|
} |
183
|
3
|
|
|
|
|
15
|
$o->{ILSM}{MAKEFILE}{TYPEMAPS} = \@vals; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
else { |
187
|
4
|
|
|
|
|
9
|
$o->{ILSM}{MAKEFILE}{TYPEMAPS} = []; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
14
|
|
|
|
|
31
|
my @uncorrupted_typemaps = @{$o->{ILSM}{MAKEFILE}{TYPEMAPS}}; |
|
14
|
|
|
|
|
54
|
|
191
|
|
|
|
|
|
|
|
192
|
14
|
100
|
|
|
|
45
|
if($config_options->{LIBS}) { |
193
|
2
|
|
|
|
|
5
|
$o->{ILSM}{MAKEFILE}{LIBS} = $config_options->{LIBS}; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
14
|
100
|
|
|
|
46
|
if($config_options->{PREFIX}) {$o->{ILSM}{XS}{PREFIX} = $config_options->{PREFIX}} |
|
2
|
|
|
|
|
3
|
|
197
|
|
|
|
|
|
|
|
198
|
14
|
|
|
|
|
64
|
bless($o, 'Inline::C'); |
199
|
|
|
|
|
|
|
|
200
|
14
|
|
|
|
|
73
|
Inline::C::validate($o); |
201
|
|
|
|
|
|
|
|
202
|
14
|
100
|
|
|
|
19618
|
if($config_options->{PRE_HEAD}) { |
203
|
2
|
|
|
|
|
7
|
my $v = $config_options->{PRE_HEAD}; |
204
|
|
|
|
|
|
|
#{ # open scope |
205
|
|
|
|
|
|
|
# no warnings 'newline'; |
206
|
2
|
100
|
|
|
|
74
|
unless( -f $v) { |
207
|
1
|
|
|
|
|
89
|
$o->{ILSM}{AUTO_INCLUDE} = $v . "\n" . $o->{ILSM}{AUTO_INCLUDE}; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
else { |
210
|
1
|
|
|
|
|
5
|
my $insert; |
211
|
1
|
50
|
|
|
|
28
|
open RD, '<', $v or die "Couldn't open $v for reading: $!"; |
212
|
1
|
|
|
|
|
33
|
while() {$insert .= $_} |
|
5
|
|
|
|
|
57
|
|
213
|
1
|
50
|
|
|
|
11
|
close RD or die "Couldn't close $v after reading: $!"; |
214
|
1
|
|
|
|
|
8
|
$o->{ILSM}{AUTO_INCLUDE} = $insert . "\n" . $o->{ILSM}{AUTO_INCLUDE}; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
#} # close scope |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
14
|
100
|
|
|
|
52
|
if($config_options->{AUTO_INCLUDE}) {$o->{ILSM}{AUTO_INCLUDE} .= $config_options->{AUTO_INCLUDE} . "\n"} |
|
10
|
|
|
|
|
47
|
|
220
|
|
|
|
|
|
|
|
221
|
14
|
100
|
|
|
|
55
|
if($config_options->{CC}) {$o->{ILSM}{MAKEFILE}{CC} = $config_options->{CC}} |
|
2
|
|
|
|
|
6
|
|
222
|
|
|
|
|
|
|
|
223
|
14
|
100
|
|
|
|
45
|
if($config_options->{OBJECT}) {$o->{ILSM}{MAKEFILE}{OBJECT} = $config_options->{OBJECT}} |
|
2
|
|
|
|
|
4
|
|
224
|
|
|
|
|
|
|
|
225
|
14
|
100
|
|
|
|
43
|
if($config_options->{CCFLAGS}) {$o->{ILSM}{MAKEFILE}{CCFLAGS} = " " . $config_options->{CCFLAGS}} |
|
2
|
|
|
|
|
5
|
|
226
|
|
|
|
|
|
|
|
227
|
14
|
50
|
|
|
|
55
|
if($config_options->{CCFLAGSEX}) {$o->{ILSM}{MAKEFILE}{CCFLAGS} = $Config{ccflags} . " " |
228
|
0
|
|
|
|
|
0
|
. $config_options->{CCFLAGSEX}} |
229
|
|
|
|
|
|
|
|
230
|
14
|
100
|
|
|
|
52
|
if(exists($config_options->{INC})) { |
231
|
10
|
50
|
|
|
|
51
|
if(ref($config_options->{INC}) eq 'ARRAY') {$o->{ILSM}{MAKEFILE}{INC} = join ' ', @{$config_options->{INC}};} |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
232
|
10
|
|
|
|
|
33
|
else {$o->{ILSM}{MAKEFILE}{INC} = $config_options->{INC};} |
233
|
|
|
|
|
|
|
} |
234
|
4
|
|
|
|
|
12
|
else {$o->{ILSM}{MAKEFILE}{INC} = ''} |
235
|
|
|
|
|
|
|
|
236
|
14
|
|
|
|
|
37
|
my $uncorrupted_inc = $o->{ILSM}{MAKEFILE}{INC}; |
237
|
|
|
|
|
|
|
|
238
|
14
|
100
|
|
|
|
47
|
if($config_options->{LD}) {$o->{ILSM}{MAKEFILE}{LD} = " " . $config_options->{LD}} |
|
2
|
|
|
|
|
6
|
|
239
|
|
|
|
|
|
|
|
240
|
14
|
100
|
|
|
|
44
|
if($config_options->{PREREQ_PM}) {$o->{ILSM}{MAKEFILE}{PREREQ_PM} = $config_options->{PREREQ_PM}} |
|
1
|
|
|
|
|
4
|
|
241
|
|
|
|
|
|
|
|
242
|
14
|
100
|
|
|
|
43
|
if($config_options->{LDDLFLAGS}) {$o->{ILSM}{MAKEFILE}{LDDLFLAGS} = " " . $config_options->{LDDLFLAGS}} |
|
2
|
|
|
|
|
7
|
|
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
# Here, we'll add the MAKE parameter to $o->{ILSM}{MAKEFILE}{MAKE} ... which |
245
|
|
|
|
|
|
|
# could be useful (given that recent versions of Extutils::MakeMaker now recognise it): |
246
|
14
|
100
|
|
|
|
37
|
if($config_options->{MAKE}) {$o->{ILSM}{MAKEFILE}{MAKE} = $config_options->{MAKE}} |
|
2
|
|
|
|
|
4
|
|
247
|
|
|
|
|
|
|
|
248
|
14
|
100
|
|
|
|
47
|
if($config_options->{MYEXTLIB}) {$o->{ILSM}{MAKEFILE}{MYEXTLIB} = " " . $config_options->{MYEXTLIB}} |
|
2
|
|
|
|
|
6
|
|
249
|
|
|
|
|
|
|
|
250
|
14
|
100
|
|
|
|
60
|
if($config_options->{OPTIMIZE}) {$o->{ILSM}{MAKEFILE}{OPTIMIZE} = " " . $config_options->{OPTIMIZE}} |
|
2
|
|
|
|
|
4
|
|
251
|
|
|
|
|
|
|
|
252
|
14
|
100
|
|
|
|
47
|
if($config_options->{USING}) { |
253
|
5
|
|
|
|
|
12
|
my $val = $config_options->{USING}; |
254
|
5
|
100
|
|
|
|
21
|
if(ref($val) eq 'ARRAY') { |
255
|
4
|
|
|
|
|
13
|
$o->{CONFIG}{USING} = $val; |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
else { |
258
|
1
|
|
|
|
|
2
|
$o->{CONFIG}{USING} = [$val]; |
259
|
|
|
|
|
|
|
} |
260
|
5
|
|
|
|
|
25
|
Inline::push_overrides($o); |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
|
263
|
14
|
100
|
|
|
|
8620
|
if(!$need_inline_h) {$o->{ILSM}{AUTO_INCLUDE} =~ s/#include "INLINE\.h"//i} |
|
2
|
|
|
|
|
15
|
|
264
|
|
|
|
|
|
|
|
265
|
14
|
|
|
|
|
80
|
_build($o, $need_inline_h); |
266
|
|
|
|
|
|
|
|
267
|
14
|
100
|
|
|
|
2240
|
if($config_options->{WRITE_MAKEFILE_PL}) { |
268
|
3
|
|
|
|
|
12
|
$o->{ILSM}{MAKEFILE}{INC} = $uncorrupted_inc; # Make sure cwd is included only if it was specified. |
269
|
3
|
|
|
|
|
13
|
$o->{ILSM}{MAKEFILE}{TYPEMAPS} = \@uncorrupted_typemaps; # Otherwise the standard perl typemap gets included ... annoying. |
270
|
3
|
50
|
|
|
|
11
|
if($config_options->{VERSION}) {$o->{API}{version} = $config_options->{VERSION}} |
|
3
|
|
|
|
|
10
|
|
271
|
0
|
|
|
|
|
0
|
else {warn "'VERSION' being set to '0.00' in the Makefile.PL. Did you supply a correct version number to c2xs() ?"} |
272
|
3
|
|
|
|
|
8
|
print "Writing Makefile.PL in the ", $o->{API}{build_dir}, " directory\n"; |
273
|
3
|
|
|
|
|
11
|
$o->call('write_Makefile_PL', 'Build Glue 3'); |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
14
|
100
|
|
|
|
844
|
if($config_options->{WRITE_PM}) { |
277
|
4
|
50
|
|
|
|
14
|
if($config_options->{VERSION}) {$o->{API}{version} = $config_options->{VERSION}} |
|
4
|
|
|
|
|
13
|
|
278
|
|
|
|
|
|
|
else { |
279
|
0
|
|
|
|
|
0
|
warn "'\$VERSION' being set to '0.00' in ", $o->{API}{modfname}, ".pm. Did you supply a correct version number to c2xs() ?"; |
280
|
0
|
|
|
|
|
0
|
$o->{API}{version} = '0.00'; |
281
|
|
|
|
|
|
|
} |
282
|
4
|
|
|
|
|
16
|
_write_pm($o); |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
14
|
100
|
|
|
|
68
|
if($config_options->{MANIF}) { |
286
|
1
|
|
|
|
|
4
|
_write_manifest($modfname, $build_dir, $config_options, $need_inline_h); |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
|
289
|
14
|
100
|
|
|
|
199
|
if($config_options->{T}) { |
290
|
1
|
|
|
|
|
3
|
_write_test_script($module, $build_dir); |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
##=========================## |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
sub _build { |
297
|
14
|
|
|
14
|
|
32
|
my $o = shift; |
298
|
14
|
|
|
|
|
29
|
my $need_inline_headers = shift; |
299
|
|
|
|
|
|
|
|
300
|
14
|
|
|
|
|
68
|
$o->call('preprocess', 'Build Preprocess'); |
301
|
14
|
|
|
|
|
97934
|
$o->call('parse', 'Build Parse'); |
302
|
|
|
|
|
|
|
|
303
|
14
|
|
|
|
|
2102381
|
print "Writing ", $o->{API}{modfname}, ".xs in the ", $o->{API}{build_dir}, " directory\n"; |
304
|
14
|
|
|
|
|
86
|
$o->call('write_XS', 'Build Glue 1'); |
305
|
|
|
|
|
|
|
|
306
|
14
|
100
|
|
|
|
9110
|
if($need_inline_headers) { |
307
|
12
|
|
|
|
|
59
|
print "Writing INLINE.h in the ", $o->{API}{build_dir}, " directory\n"; |
308
|
12
|
|
|
|
|
64
|
$o->call('write_Inline_headers', 'Build Glue 2'); |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
##=========================## |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
sub _check_config_keys { |
315
|
106
|
|
|
106
|
|
153
|
for(@allowable_config_keys) { |
316
|
1530
|
100
|
|
|
|
2199
|
return 1 if $_ eq $_[0]; # it's a valid config option |
317
|
|
|
|
|
|
|
} |
318
|
2
|
|
|
|
|
13
|
return 0; # it's an invalid config option |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
##=========================## |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
sub _write_pm { |
324
|
4
|
|
|
4
|
|
8
|
my $o = shift; |
325
|
4
|
|
|
|
|
8
|
my $offset = 4; |
326
|
4
|
|
|
|
|
7
|
my $max = 100; |
327
|
4
|
|
|
|
|
6
|
my $length = $offset; |
328
|
4
|
|
|
|
|
7
|
my @use; |
329
|
|
|
|
|
|
|
|
330
|
4
|
100
|
|
|
|
15
|
if($config_options->{USE}) { |
331
|
|
|
|
|
|
|
die "Value supplied to config option USE must be an array reference" |
332
|
3
|
50
|
|
|
|
13
|
if ref($config_options->{USE}) ne 'ARRAY'; |
333
|
3
|
|
|
|
|
6
|
@use = @{$config_options->{USE}}; |
|
3
|
|
|
|
|
10
|
|
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
4
|
50
|
|
|
|
266
|
open(WR, '>', $o->{API}{build_dir} . '/' . $o->{API}{modfname} . ".pm") |
337
|
|
|
|
|
|
|
or die "Couldn't create the .pm file: $!"; |
338
|
4
|
|
|
|
|
26
|
print "Writing ", $o->{API}{modfname}, ".pm in the ", $o->{API}{build_dir}, " directory\n"; |
339
|
4
|
|
|
|
|
41
|
print WR "## This file generated by InlineX::C2XS (version ", |
340
|
|
|
|
|
|
|
$InlineX::C2XS::VERSION, ") using Inline::C (version ", $Inline::C::VERSION, ")\n"; |
341
|
4
|
|
|
|
|
14
|
print WR "package ", $o->{API}{module}, ";\n"; |
342
|
4
|
|
|
|
|
10
|
for(@use) { |
343
|
3
|
|
|
|
|
11
|
print WR "use ${_};\n"; |
344
|
|
|
|
|
|
|
} |
345
|
4
|
|
|
|
|
11
|
print WR "\n"; |
346
|
4
|
|
|
|
|
7
|
print WR "require Exporter;\n*import = \\&Exporter::import;\nrequire DynaLoader;\n\n"; |
347
|
|
|
|
|
|
|
# Switch to xdg's recommendation for assigning version number |
348
|
|
|
|
|
|
|
#print WR "\$", $o->{API}{module}, "::VERSION = '", $o->{API}{version}, "';\n\n"; |
349
|
4
|
|
|
|
|
37
|
print WR "our \$VERSION = '", $o->{API}{version}, "';\n\$VERSION = eval \$VERSION;\n"; |
350
|
4
|
|
|
|
|
13
|
print WR "DynaLoader::bootstrap ", $o->{API}{module}, " \$VERSION;\n\n"; |
351
|
|
|
|
|
|
|
|
352
|
4
|
100
|
|
|
|
14
|
unless($config_options->{EXPORT_ALL}) { |
353
|
3
|
|
|
|
|
9
|
print WR "\@", $o->{API}{module}, "::EXPORT = ();\n"; |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
else { |
356
|
1
|
|
|
|
|
3
|
print WR "\@", $o->{API}{module}, "::EXPORT = qw(\n"; |
357
|
1
|
|
|
|
|
1
|
for(@{$o->{ILSM}{parser}{data}{functions}}) { |
|
1
|
|
|
|
|
4
|
|
358
|
8
|
100
|
100
|
|
|
25
|
if ($_ =~ /^_/ && $_ !~ /^__/) {next} |
|
4
|
|
|
|
|
7
|
|
359
|
4
|
|
|
|
|
6
|
my $l = length($_); |
360
|
4
|
50
|
|
|
|
6
|
if($length + $l > $max) { |
361
|
0
|
|
|
|
|
0
|
print WR "\n", " " x $offset, "$_ "; |
362
|
0
|
|
|
|
|
0
|
$length = $offset + $l + 1; |
363
|
|
|
|
|
|
|
} |
364
|
4
|
100
|
|
|
|
9
|
if($length == $offset) {print WR " " x $offset, "$_ "} |
|
1
|
|
|
|
|
4
|
|
365
|
3
|
|
|
|
|
6
|
else {print WR "$_ " } |
366
|
4
|
|
|
|
|
6
|
$length += $l + 1; |
367
|
|
|
|
|
|
|
} |
368
|
1
|
|
|
|
|
3
|
print WR "\n", " " x $offset, ");\n\n"; |
369
|
1
|
|
|
|
|
2
|
$length = $offset; |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
|
372
|
4
|
100
|
66
|
|
|
23
|
unless($config_options->{EXPORT_OK_ALL} || $config_options->{EXPORT_TAGS_ALL}) { |
373
|
3
|
|
|
|
|
9
|
print WR "\@", $o->{API}{module}, "::EXPORT_OK = ();\n\n"; |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
else { |
376
|
1
|
|
|
|
|
3
|
print WR "\@", $o->{API}{module}, "::EXPORT_OK = qw(\n"; |
377
|
1
|
|
|
|
|
2
|
for(@{$o->{ILSM}{parser}{data}{functions}}) { |
|
1
|
|
|
|
|
3
|
|
378
|
8
|
100
|
100
|
|
|
22
|
if ($_ =~ /^_/ && $_ !~ /^__/) {next} |
|
4
|
|
|
|
|
6
|
|
379
|
4
|
|
|
|
|
6
|
my $l = length($_); |
380
|
4
|
50
|
|
|
|
6
|
if($length + $l > $max) { |
381
|
0
|
|
|
|
|
0
|
print WR "\n", " " x $offset, "$_ "; |
382
|
0
|
|
|
|
|
0
|
$length = $offset + $l + 1; |
383
|
|
|
|
|
|
|
} |
384
|
4
|
100
|
|
|
|
7
|
if($length == $offset) {print WR " " x $offset, "$_ "} |
|
1
|
|
|
|
|
3
|
|
385
|
3
|
|
|
|
|
6
|
else {print WR "$_ " } |
386
|
4
|
|
|
|
|
5
|
$length += $l + 1; |
387
|
|
|
|
|
|
|
} |
388
|
1
|
|
|
|
|
4
|
print WR "\n", " " x $offset, ");\n\n"; |
389
|
1
|
|
|
|
|
2
|
$length = $offset; |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
4
|
100
|
|
|
|
11
|
if($config_options->{EXPORT_TAGS_ALL}){ |
393
|
1
|
|
|
|
|
4
|
print WR "\%", $o->{API}{module}, "::EXPORT_TAGS = (", $config_options->{EXPORT_TAGS_ALL}, " => [qw(\n"; |
394
|
1
|
|
|
|
|
2
|
for(@{$o->{ILSM}{parser}{data}{functions}}) { |
|
1
|
|
|
|
|
3
|
|
395
|
8
|
100
|
100
|
|
|
37
|
if ($_ =~ /^_/ && $_ !~ /^__/) {next} |
|
4
|
|
|
|
|
7
|
|
396
|
4
|
|
|
|
|
6
|
my $l = length($_); |
397
|
4
|
50
|
|
|
|
8
|
if($length + $l > $max) { |
398
|
0
|
|
|
|
|
0
|
print WR "\n", " " x $offset, "$_ "; |
399
|
0
|
|
|
|
|
0
|
$length = $offset + $l + 1; |
400
|
|
|
|
|
|
|
} |
401
|
4
|
100
|
|
|
|
7
|
if($length == $offset) {print WR " " x $offset, "$_ "} |
|
1
|
|
|
|
|
5
|
|
402
|
3
|
|
|
|
|
6
|
else {print WR "$_ " } |
403
|
4
|
|
|
|
|
5
|
$length += $l + 1; |
404
|
|
|
|
|
|
|
} |
405
|
1
|
|
|
|
|
3
|
print WR "\n", " " x $offset, ")]);\n\n"; |
406
|
1
|
|
|
|
|
2
|
$length = $offset; |
407
|
|
|
|
|
|
|
} |
408
|
|
|
|
|
|
|
|
409
|
4
|
|
|
|
|
10
|
print WR "sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaking\n\n"; |
410
|
4
|
|
|
|
|
7
|
print WR "1;\n"; |
411
|
4
|
50
|
|
|
|
127
|
close(WR) or die "Couldn't close the .pm file after writing to it: $!"; |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
##=========================## |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
sub _write_manifest { |
417
|
1
|
|
|
1
|
|
3
|
my $m = shift; # name of pm and xs files |
418
|
1
|
|
|
|
|
1
|
my $bd = shift; # build directory |
419
|
1
|
|
|
|
|
2
|
my $c = shift; # config options |
420
|
1
|
|
|
|
|
1
|
my $ih = shift; # INLINE.h is present ? |
421
|
|
|
|
|
|
|
|
422
|
1
|
|
|
|
|
4
|
print "Writing the MANIFEST file in the $bd directory\n"; |
423
|
|
|
|
|
|
|
|
424
|
1
|
50
|
|
|
|
50
|
open WRM, '>', "$bd/MANIFEST" or die "Can't open MANIFEST for writing: $!"; |
425
|
1
|
|
|
|
|
5
|
print WRM "MANIFEST\n"; |
426
|
1
|
50
|
|
|
|
4
|
if($c->{WRITE_PM}) {print WRM "$m.pm\n"} |
|
1
|
|
|
|
|
3
|
|
427
|
1
|
50
|
|
|
|
3
|
if($ih) {print WRM "INLINE.h\n"} |
|
0
|
|
|
|
|
0
|
|
428
|
1
|
|
|
|
|
3
|
print WRM "$m.xs\n"; |
429
|
1
|
50
|
|
|
|
2
|
if($c->{WRITE_MAKEFILE_PL}) { |
430
|
1
|
|
|
|
|
3
|
print WRM "Makefile.PL\n"; |
431
|
|
|
|
|
|
|
} |
432
|
1
|
50
|
|
|
|
2
|
if($c->{T}){ |
433
|
1
|
|
|
|
|
3
|
print WRM "t/00load.t\n"; |
434
|
|
|
|
|
|
|
} |
435
|
1
|
50
|
|
|
|
28
|
close WRM or die "Can't close $bd/MANIFEST after writing: $!"; |
436
|
|
|
|
|
|
|
} |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
##=========================## |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
sub _write_test_script { |
441
|
15
|
|
|
15
|
|
174
|
use File::Path; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
4639
|
|
442
|
1
|
|
|
1
|
|
3
|
my $mod = $_[0]; |
443
|
1
|
|
|
|
|
3
|
my $path = "$_[1]/t"; |
444
|
1
|
50
|
|
|
|
19
|
unless(-d $path) { |
445
|
1
|
50
|
|
|
|
185
|
if(!File::Path::make_path($path, {verbose => 1})) {die "Failed to create $path directory"}; |
|
0
|
|
|
|
|
0
|
|
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
1
|
|
|
|
|
7
|
print "Writing 00load.t in the $path directory\n"; |
449
|
1
|
50
|
|
|
|
59
|
open WRT, '>', "$path/00load.t" or die "Couldn't open $path/00load.t for writing: $!"; |
450
|
1
|
|
|
|
|
15
|
print WRT "## This file auto-generated by InlineX-C2XS-" . $InlineX::C2XS::VERSION . "\n\n"; |
451
|
1
|
|
|
|
|
6
|
print WRT "use strict;\nuse warnings;\n\n"; |
452
|
1
|
|
|
|
|
2
|
print WRT "print \"1..1\\n\";\n\n"; |
453
|
1
|
|
|
|
|
3
|
print WRT "eval{require $mod;};\n"; |
454
|
1
|
|
|
|
|
2
|
print WRT "if(\$\@) {\n warn \"\\\$\\\@: \$\@\";\n print \"not ok 1\\n\";\n}\n"; |
455
|
1
|
|
|
|
|
2
|
print WRT "else {print \"ok 1\\n\"}\n"; |
456
|
1
|
50
|
|
|
|
37
|
close WRT or die "Couldn't close $path/00load.t after writing: $!"; |
457
|
|
|
|
|
|
|
} |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
##=========================## |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
*context = \&InlineX::C2XS::Context::apply_context_args; |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
##=========================## |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
##=========================## |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
1; |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
__END__ |