source: josm/trunk/geticons.pl@ 2982

Last change on this file since 2982 was 2981, checked in by stoecker, 15 years ago

images cleanup

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1#! /usr/bin/perl -w
2# short tool to find out all used icons and allows deleting unused icons
3# when building release files
4
5my @default = (
6 "styles/standard/*.xml",
7 "data/*.xml",
8 "src/org/openstreetmap/josm/*.java",
9 "src/org/openstreetmap/josm/*/*.java",
10 "src/org/openstreetmap/josm/*/*/*.java",
11 "src/org/openstreetmap/josm/*/*/*/*.java",
12 "src/org/openstreetmap/josm/*/*/*/*/*.java",
13 "src/org/openstreetmap/josm/*/*/*/*/*/*.java"
14);
15
16my %icons;
17
18my $o = $/;
19
20for my $arg (@ARGV ? @ARGV : @default)
21{
22 for my $file (glob($arg))
23 {
24 open(FILE,"<",$file) or die "Could not open $file\n";
25 #print "Read file $file\n";
26 $/ = $file =~ /\.java$/ ? ";" : $o;
27 my $extends = "";
28 while(my $l = <FILE>)
29 {
30 if($l =~ /src\s*=\s*["'](.*?)["']/)
31 {
32 ++$icons{"styles/standard/$1"};
33 }
34 elsif($l =~ /icon\s*=\s*["'](.*?)["']/)
35 {
36 ++$icons{$1};
37 }
38
39 if($l =~ /ImageProvider\.get\(\"([^\"]*?)\"\)/)
40 {
41 my $i = $1;
42 $i .= ".png" if !($i =~ /\.png$/);
43 ++$icons{$i};
44 }
45 if($l =~ /new\s+ImageLabel\(\"(.*?)\"/)
46 {
47 my $i = "statusline/$1";
48 $i .= ".png" if !($i =~ /\.png$/);
49 ++$icons{$i};
50 }
51 if($l =~ /createPreferenceTab\(\"(.*?)\"/)
52 {
53 my $i = "preferences/$1";
54 $i .= ".png" if !($i =~ /\.png$/);
55 ++$icons{$i};
56 }
57 if($l =~ /ImageProvider\.get\(\"(.*?)\",\s*\"(.*?)\"\s*\)/)
58 {
59 my $i = "$1/$2";
60 $i .= ".png" if !($i =~ /\.png$/);
61 ++$icons{$i};
62 }
63 if($l =~ /ImageProvider\.overlay\(.*?,\s*\"(.*?)\",/)
64 {
65 my $i = $1;
66 $i .= ".png" if !($i =~ /\.png$/);
67 ++$icons{$i};
68 }
69 if($l =~ /getCursor\(\"(.*?)\",\s*\"(.*?)\"/)
70 {
71 my $i = "cursor/modifier/$2";
72 $i .= ".png" if !($i =~ /\.png$/);
73 ++$icons{$i};
74 $i = "cursor/$1";
75 $i .= ".png" if !($i =~ /\.png$/);
76 ++$icons{$i};
77 }
78 if($l =~ /ImageProvider\.getCursor\(\"(.*?)\",\s*null\)/)
79 {
80 my $i = "cursor/$1";
81 $i .= ".png" if !($i =~ /\.png$/);
82 ++$icons{$i};
83 }
84 if($l =~ /super\(\s*tr\(\".*?\"\),\s*\"(.*?)\"/s)
85 {
86 my $i = "$extends$1";
87 $i .= ".png" if !($i =~ /\.png$/);
88 ++$icons{$i};
89 }
90 if($l =~ /super\(\s*trc\(\".*?\",\s*\".*?\"\),\s*\"(.*?)\"/s)
91 {
92 my $i = "$extends$1";
93 $i .= ".png" if !($i =~ /\.png$/);
94 ++$icons{$i};
95 }
96 if($l =~ /audiotracericon\",\s*\"(.*?)\"/s)
97 {
98 my $i = "markers/$1";
99 $i .= ".png" if !($i =~ /\.png$/);
100 ++$icons{$i};
101 }
102 if($l =~ /\"(.*?)\",\s*parentLayer/s)
103 {
104 my $i = "markers/$1";
105 $i .= ".png" if !($i =~ /\.png$/);
106 ++$icons{$i};
107 }
108 if($l =~ /allowedtypes\s+=.*\{(.*)\}/s)
109 {
110 my $t = $1;
111 while($t =~ /\"(.*?)\"/g)
112 {
113 ++$icons{"Mf_$1.png"};
114 }
115 }
116 if($l =~ /MODES\s+=.*\{(.*)\}/s)
117 {
118 my $t = $1;
119 while($t =~ /\"(.*?)\"/g)
120 {
121 ++$icons{"dialogs/autoscale/$1.png"};
122 }
123 }
124 if($l =~ /enum\s+DeleteMode\s*\{(.*)/s)
125 {
126 my $t = $1;
127 while($t =~ /\"(.*?)\"/g)
128 {
129 ++$icons{"cursor/modifier/$1.png"};
130 }
131 }
132 if($l =~ /\.setButtonIcons.*\{(.*)\}/)
133 {
134 my $t = $1;
135 while($t =~ /\"(.*?)\"/g)
136 {
137 my $i = $1;
138 $i .= ".png" if !($i =~ /\.png$/);
139 ++$icons{$i};
140 }
141 }
142 if($l =~ /extends MapMode/)
143 {
144 $extends = "mapmode/";
145 }
146 if($l =~ /extends ToggleDialog/)
147 {
148 $extends = "dialogs/";
149 }
150 }
151 close FILE;
152 }
153}
154
155my %haveicons;
156
157for($i = 1; my @ifiles = glob("images".("/*" x $i).".png"); ++$i)
158{
159 for my $ifile (sort @ifiles)
160 {
161 $ifile =~ s/^images\///;
162 $haveicons{$ifile} = 1;
163 }
164}
165
166for my $img (sort keys %icons)
167{
168 print STDERR "File $img does not exist!\n" if(!-f "images/$img");
169 delete $haveicons{$img};
170}
171
172for my $img (sort keys %haveicons)
173{
174 print "$img\n";
175}
Note: See TracBrowser for help on using the repository browser.