-
Notifications
You must be signed in to change notification settings - Fork 8
/
dependencies.plx
executable file
·218 lines (191 loc) · 4.22 KB
/
dependencies.plx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/usr/bin/perl -w
# this attempts to make sure there are no dependency conflicts.
# run it every once in awhile if you care to.
#
# $Id$
#
sub warner { warn @_ unless $_[0] =~ /(?:Use of uninitialized value|[Ss]ubroutine \S+ redefined)/ }
$SIG{__WARN__} = \&warner;
my %data;
package Slash::Test::Dependencies;
use strict;
use base 'Exporter';
our @EXPORT = ('require');
sub require {
my $caller = caller(0);
$caller = caller(2) if $caller eq 'base';
my $package = my $required = shift;
return if $package =~ /^\d/;
$package =~ s/\.pm$//;
$package =~ s|/|::|g;
# printf "%s called %s (%s)\n", $caller, $required, $package;
push @{$data{$caller}}, $package;
CORE::require $required;
}
# for when we "use base" to get a module
*base::import_new = *base::import{CODE};
*base::import = sub {
my $caller = caller(0);
my $package = $_[1];
# printf "%s called %s (%s)\n", $caller, $required, $package;
push @{$data{$caller}}, $package;
goto &base::import_new;
};
Slash::Test::Dependencies->export('base', 'require');
package main;
use strict;
use File::Find;
die $0;
my $path = shift @ARGV || '/usr/local/src/slash/main/slash/';
$path .= '/' unless $path =~ m|/$|;
my %pms;
my $skip = qr{(?:Bundle::Slash|Slash::SOAP::WSDL|Slash::Apache(?:::(?:User|Banlist))?)$};
find(sub {
my $file = $File::Find::name;
if ($file =~ /\.pm$/) {
(my $f = $file) =~ s|^\Q$path\E||;
$f =~ s/\.pm$//;
$f =~ s/^plugins/Slash/;
$f =~ s|\b(\w+)/\1$|$1|;
$f =~ s|/|::|g;
return if $f =~ $skip;
$pms{$f} ||= $file;
} else {
return;
}
}, $path);
for my $f (sort keys %pms) {
# next unless $f eq 'Slash::DB::MySQL';
$SIG{__WARN__} = \&warner;
Slash::Test::Dependencies->export($f, 'require');
require $pms{$f};
}
# make sure we get an error, for testing
#push @{$data{'Slash::Utility'}}, 'Slash::DB::MySQL';
#push @{$data{'Slash::DB::MySQL'}}, 'Slash::Utility';
use Data::Dumper;
print Dumper \%data;
for my $class (keys %data) {
my $aref = $data{$class};
$data{$class} = { map { ($_ => 1) } @$aref };
}
my %checked;
for my $class (keys %data) {
for my $sub (keys %{$data{$class}}) {
check($class, $sub, [$class, $sub]);
}
}
print "All OK!\n";
sub check {
my($class, $sub, $trace) = @_;
return if $checked{$class,$sub};
$checked{$class,$sub}++;
for (keys %{$data{$sub}}) {
my $ntrace = [@$trace, $_, $class];
local $" = " =>\n\t";
if (exists $data{$_}{$class}) {
die "damn:\n\t@$ntrace\n";
}
check($class, $_, [@$trace, $_]);
}
}
__END__
my %data = (
'Slash' => [qw(
Slash::Constants
Slash::DB
Slash::Display
Slash::Utility
)],
'Slash::Apache' => [qw(
Slash
Slash::DB
Slash::Display
Slash::Utility
)],
'Slash::Apache::Log' => [qw(
Slash::Utility
)],
'Slash::Apache::User' => [qw(
Slash
Slash::Apache
Slash::Display
Slash::Utility
)],
'Slash::Constants' => [qw(
)],
'Slash::DB' => [qw(
Slash::DB::Utility
)],
'Slash::DB::MySQL' => [qw(
Slash::DB
Slash::DB::Utility
Slash::Utility
)],
'Slash::DB::Static::MySQL' => [qw(
Slash::DB::Utility
Slash::Utility
)],
'Slash::DB::Utility' => [qw(
Slash::Utility
)],
'Slash::Display' => [qw(
Slash::Display::Provider
Slash::Utility::Data
Slash::Utility::Environment
Slash::Utility::System
)],
'Slash::Display::Plugin' => [qw(
Slash
Slash::Utility
)],
'Slash::Display::Provider' => [qw(
Slash::Utility::Environment
)],
'Slash::Install' => [qw(
Slash
Slash::DB
Slash::DB::Utility
)],
'Slash::Test' => [qw(
Slash
Slash::Constants
Slash::Display
Slash::Utility
Slash::XML
)],
'Slash::Utility' => [qw(
Slash::Utility::Access
Slash::Utility::Anchor
Slash::Utility::Data
Slash::Utility::Display
Slash::Utility::Environment
Slash::Utility::System
)],
'Slash::Utility::Access' => [qw(
Slash::Display
Slash::Utility::Data
Slash::Utility::System
Slash::Utility::Environment
)],
'Slash::Utility::Anchor' => [qw(
Slash::Display
Slash::Utility::Data
Slash::Utility::Display
Slash::Utility::Environment
)],
'Slash::Utility::Data' => [qw(
Slash::Constants
Slash::Utility::Environment
)],
'Slash::Utility::Display' => [qw(
Slash::Display
Slash::Utility::Data
Slash::Utility::Environment
)],
'Slash::Utility::Environment' => [qw(
)],
'Slash::Utility::System' => [qw(
Slash::Utility::Environment
)],
);