aboutsummaryrefslogtreecommitdiff
path: root/tools/star/analyze_module_dependencies.p6
blob: 44f027f79bdb27bb40712dadf1a7083b428e16d7 (plain)
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
my %depended-on := SetHash.new;
my @has-names;
my %revdeps;

use JSON::Fast;

for qx{ ls modules/*/META* }.lines -> $jf {

    my $data = from-json(slurp($jf));

    # list module as available
    @has-names.push($data<name>);

    # these three can contain dependencies
    for <depends test-depends build-depends> -> $_ {
        # but some of them are optional
        next unless $data{$_}:exists;
        my $val = $data{$_};
        # and sometimes they are just an empty array in the json blob.
        next if $val.elems == 0;

        # record every dependency in our set
        %depended-on{@$val}>>++;
        %revdeps{$data<name>}.append: @$val;
    }
}

say "reverse dependencies:";
say "";
.say for %revdeps;
say "";
say "";

# exclude a few modules:
# Panda doesn't have a META.info
# Test is shipped with Rakudo
# NativeCall is also shipped with rakudo
# nqp isn't really a module.
my @missing = (%depended-on (-) @has-names (-) <Panda Test NativeCall nqp>).list;

if @missing {
    say "There are some modules that are depended on, but not in the modules list.";
    .say for @missing;
} else {
    say "the modules seem to be sane.";
}