source: josm/trunk/geticons.pl@ 3665

Last change on this file since 3665 was 3370, checked in by stoecker, 14 years ago

small fix

  • Property svn:executable set to *
File size: 4.1 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 my $img = "styles/standard/$1";
33 $img = "styles/$1" if((!-f "images/$img") && -f "images/styles/$1");
34 ++$icons{$img};
35 }
36 elsif($l =~ /icon\s*=\s*["'](.*?)["']/)
37 {
38 ++$icons{$1};
39 }
40
41 if($l =~ /ImageProvider\.get\(\"([^\"]*?)\"\)/)
42 {
43 my $i = $1;
44 $i .= ".png" if !($i =~ /\.png$/);
45 ++$icons{$i};
46 }
47 if($l =~ /new\s+ImageLabel\(\"(.*?)\"/)
48 {
49 my $i = "statusline/$1";
50 $i .= ".png" if !($i =~ /\.png$/);
51 ++$icons{$i};
52 }
53 if($l =~ /createPreferenceTab\(\"(.*?)\"/)
54 {
55 my $i = "preferences/$1";
56 $i .= ".png" if !($i =~ /\.png$/);
57 ++$icons{$i};
58 }
59 if($l =~ /ImageProvider\.get\(\"(.*?)\",\s*\"(.*?)\"\s*\)/)
60 {
61 my $i = "$1/$2";
62 $i .= ".png" if !($i =~ /\.png$/);
63 ++$icons{$i};
64 }
65 if($l =~ /ImageProvider\.overlay\(.*?,\s*\"(.*?)\",/)
66 {
67 my $i = $1;
68 $i .= ".png" if !($i =~ /\.png$/);
69 ++$icons{$i};
70 }
71 if($l =~ /getCursor\(\"(.*?)\",\s*\"(.*?)\"/)
72 {
73 my $i = "cursor/modifier/$2";
74 $i .= ".png" if !($i =~ /\.png$/);
75 ++$icons{$i};
76 $i = "cursor/$1";
77 $i .= ".png" if !($i =~ /\.png$/);
78 ++$icons{$i};
79 }
80 if($l =~ /ImageProvider\.getCursor\(\"(.*?)\",\s*null\)/)
81 {
82 my $i = "cursor/$1";
83 $i .= ".png" if !($i =~ /\.png$/);
84 ++$icons{$i};
85 }
86 if($l =~ /super\(\s*tr\(\".*?\"\),\s*\"(.*?)\"/s)
87 {
88 my $i = "$extends$1";
89 $i .= ".png" if !($i =~ /\.png$/);
90 ++$icons{$i};
91 }
92 if($l =~ /super\(\s*trc\(\".*?\",\s*\".*?\"\),\s*\"(.*?)\"/s)
93 {
94 my $i = "$extends$1";
95 $i .= ".png" if !($i =~ /\.png$/);
96 ++$icons{$i};
97 }
98 if($l =~ /audiotracericon\",\s*\"(.*?)\"/s)
99 {
100 my $i = "markers/$1";
101 $i .= ".png" if !($i =~ /\.png$/);
102 ++$icons{$i};
103 }
104 if($l =~ /\"(.*?)\",\s*parentLayer/s)
105 {
106 my $i = "markers/$1";
107 $i .= ".png" if !($i =~ /\.png$/);
108 ++$icons{$i};
109 }
110 if($l =~ /allowedtypes\s+=.*\{(.*)\}/s)
111 {
112 my $t = $1;
113 while($t =~ /\"(.*?)\"/g)
114 {
115 ++$icons{"Mf_$1.png"};
116 }
117 }
118 if($l =~ /MODES\s+=.*\{(.*)\}/s)
119 {
120 my $t = $1;
121 while($t =~ /\"(.*?)\"/g)
122 {
123 ++$icons{"dialogs/autoscale/$1.png"};
124 }
125 }
126 if($l =~ /enum\s+DeleteMode\s*\{(.*)/s)
127 {
128 my $t = $1;
129 while($t =~ /\"(.*?)\"/g)
130 {
131 ++$icons{"cursor/modifier/$1.png"};
132 }
133 }
134 if($l =~ /\.setButtonIcons.*\{(.*)\}/)
135 {
136 my $t = $1;
137 while($t =~ /\"(.*?)\"/g)
138 {
139 my $i = $1;
140 $i .= ".png" if !($i =~ /\.png$/);
141 ++$icons{$i};
142 }
143 }
144 if($l =~ /extends MapMode/)
145 {
146 $extends = "mapmode/";
147 }
148 if($l =~ /extends ToggleDialog/)
149 {
150 $extends = "dialogs/";
151 }
152 }
153 close FILE;
154 }
155}
156
157my %haveicons;
158
159for($i = 1; my @ifiles = glob("images".("/*" x $i).".png"); ++$i)
160{
161 for my $ifile (sort @ifiles)
162 {
163 $ifile =~ s/^images\///;
164 $haveicons{$ifile} = 1;
165 }
166}
167
168for my $img (sort keys %icons)
169{
170 print STDERR "File $img does not exist!\n" if(!-f "images/$img");
171 delete $haveicons{$img};
172}
173
174for my $img (sort keys %haveicons)
175{
176 print "$img\n";
177}
Note: See TracBrowser for help on using the repository browser.