-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread-image-deps.pl
50 lines (42 loc) · 902 Bytes
/
read-image-deps.pl
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
#!/usr/bin/env perl
use autodie qw(open);
my $files;
foreach (@ARGV) {
my $png = $_;
if (s{graphics/(icons|technology|entity)/}{graphics/}i) {
my $match = $1;
if ($match == "entity") {
next if m/-(?:shadow|reflection)\.png$/i;
}
} else {
next;
}
next unless s/\.png$/.pov/i;
push @{$files->{$_}}, $png;
}
my @files = keys %$files;
my $seen;
my $deps;
my $incs;
while (my $file = shift @files) {
next unless -r $file;
open my $fh, "<", $file;
while (<$fh>) {
if (m/#include "(.*)"/) {
my $inc = $1;
if (!$seen{$inc}) {
push @files, $inc;
$seen{$inc}++;
}
next unless -r $inc;
$deps->{$file}{$inc} = 1;
}
}
close($fh);
}
foreach my $file (keys %$deps) {
my $deplist = join(" ", sort keys %{$deps->{$file}});
for my $png (@{$files->{$file}}) {
print "\$(OUTPUT_DIR)/$png: $deplist\n";
}
}