line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::TinyCCx; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
45504
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
90
|
|
4
|
4
|
|
|
4
|
|
12
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
146
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Follow Golden's Version Rule: http://www.dagolden.com/index.php/369/version-numbers-should-be-boring/ |
7
|
|
|
|
|
|
|
our $VERSION = "0.12_01"; |
8
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
1665
|
use File::ShareDir; |
|
4
|
|
|
|
|
18736
|
|
|
4
|
|
|
|
|
181
|
|
11
|
4
|
|
|
4
|
|
21
|
use File::Spec; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
81
|
|
12
|
4
|
|
|
4
|
|
3194
|
use Env qw( @PATH ); |
|
4
|
|
|
|
|
8634
|
|
|
4
|
|
|
|
|
21
|
|
13
|
4
|
|
|
4
|
|
564
|
use Carp; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
172
|
|
14
|
4
|
|
|
4
|
|
17
|
use Config; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
2075
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
################################### |
17
|
|
|
|
|
|
|
# Find the Distribution Directory # |
18
|
|
|
|
|
|
|
################################### |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# The prefix will depend on whether or not the thing was finally installed. |
21
|
|
|
|
|
|
|
# The easiest way to know that is if *this* *module* *file* is in a blib |
22
|
|
|
|
|
|
|
# directory or not: |
23
|
|
|
|
|
|
|
my $dist_dir; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $mod_path = $INC{'Alien/TinyCCx.pm'}; |
26
|
|
|
|
|
|
|
if ($mod_path =~ s/(.*)blib.*/$1share/) { |
27
|
|
|
|
|
|
|
$dist_dir = $mod_path; |
28
|
|
|
|
|
|
|
croak('Looks like Alien::TinyCCx is being invoked from blib, but I cannot find build-time sharedir!') |
29
|
|
|
|
|
|
|
unless -d $dist_dir; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
|
|
|
|
|
|
$dist_dir = File::ShareDir::dist_dir('Alien-TinyCCx'); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
############################ |
36
|
|
|
|
|
|
|
# Path retrieval functions # |
37
|
|
|
|
|
|
|
############################ |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# First we need to find a number of files of interest. Rather than guess |
40
|
|
|
|
|
|
|
# at these files' locations, we can perform a simple search for them |
41
|
|
|
|
|
|
|
# and store the locations that we find. |
42
|
|
|
|
|
|
|
my %files_to_find = ( |
43
|
|
|
|
|
|
|
bin => 'tcc', |
44
|
|
|
|
|
|
|
lib => 'libtcc.', |
45
|
|
|
|
|
|
|
inc => 'libtcc.h' |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
if ($^O =~ /MSWin/) { |
48
|
|
|
|
|
|
|
$files_to_find{bin} .= '.exe'; |
49
|
|
|
|
|
|
|
$files_to_find{lib} .= 'dll'; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else { |
52
|
|
|
|
|
|
|
$files_to_find{lib} .= 'a'; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
my %path_for_file; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Otherwise go through all dirs and subdirs of dist_dir |
57
|
|
|
|
|
|
|
my @dirs = $dist_dir; |
58
|
|
|
|
|
|
|
while (@dirs) { |
59
|
|
|
|
|
|
|
# Pull the next directory off the list |
60
|
|
|
|
|
|
|
my $dir = shift @dirs; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Check if any of the unfound files are in this directory |
63
|
|
|
|
|
|
|
for my $file_type (keys %files_to_find) { |
64
|
|
|
|
|
|
|
if (-f File::Spec->catfile($dir, $files_to_find{$file_type})) { |
65
|
|
|
|
|
|
|
delete $files_to_find{$file_type}; |
66
|
|
|
|
|
|
|
$path_for_file{$file_type} = $dir; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Otherwise, scan this directory for subdirectories |
71
|
|
|
|
|
|
|
opendir (my $dh, $dir) or next; |
72
|
|
|
|
|
|
|
CHILD: for my $child (readdir $dh) { |
73
|
|
|
|
|
|
|
next CHILD if $child =~ /^\./; # skip dot-files and dot-dirs |
74
|
|
|
|
|
|
|
my $full_path = File::Spec->catdir($dir, $child); |
75
|
|
|
|
|
|
|
push @dirs, $full_path if -d $full_path; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
close $dh; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Find the path to the tcc executable |
81
|
5
|
|
|
5
|
1
|
39
|
sub path_to_tcc { $path_for_file{bin} } |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Modify the PATH environment variable to include tcc's directory |
84
|
|
|
|
|
|
|
unshift @PATH, path_to_tcc(); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Find the path to the compiled libraries. Note that this is only applicable |
87
|
|
|
|
|
|
|
# on Unixish systems; Windows simply uses the %PATH%, which was already |
88
|
|
|
|
|
|
|
# appropriately set. |
89
|
5
|
|
|
5
|
1
|
43
|
sub libtcc_library_path { $path_for_file{lib} } |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Add library path on Unixish: |
92
|
|
|
|
|
|
|
if ($ENV{LD_LIBRARY_PATH}) { |
93
|
|
|
|
|
|
|
$ENV{LD_LIBRARY_PATH} = libtcc_library_path() . ':' . $ENV{LD_LIBRARY_PATH}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
elsif ($^O !~ /MSWin/) { |
96
|
|
|
|
|
|
|
$ENV{LD_LIBRARY_PATH} = libtcc_library_path(); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Determine path for libtcc.h |
100
|
1
|
|
|
1
|
1
|
36
|
sub libtcc_include_path { $path_for_file{inc} } |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
########################### |
103
|
|
|
|
|
|
|
# Module::Build Functions # |
104
|
|
|
|
|
|
|
########################### |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub MB_linker_flags { |
107
|
0
|
|
|
0
|
1
|
|
return ('-L' . libtcc_library_path, '-ltcc'); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
################################# |
111
|
|
|
|
|
|
|
# ExtUtils::MakeMaker Functions # |
112
|
|
|
|
|
|
|
################################# |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub EUMM_LIBS { |
115
|
0
|
0
|
|
0
|
0
|
|
return (LIBS => ['-L' . libtcc_library_path . '\libtcc -ltcc']) if $^O =~ /MSWin/; |
116
|
0
|
|
|
|
|
|
return; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub EUMM_OBJECT { |
120
|
0
|
0
|
|
0
|
0
|
|
return OBJECT => '$(O_FILES)' if $^O =~ /MSWin/; |
121
|
0
|
|
|
|
|
|
return OBJECT => '$(O_FILES) ' . File::Spec->catdir(libtcc_library_path, 'libtcc'.$Config{lib_ext}), |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# version |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__ |