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