summaryrefslogtreecommitdiff
path: root/wps/wpsbuild.pl
diff options
context:
space:
mode:
Diffstat (limited to 'wps/wpsbuild.pl')
-rwxr-xr-xwps/wpsbuild.pl99
1 files changed, 74 insertions, 25 deletions
diff --git a/wps/wpsbuild.pl b/wps/wpsbuild.pl
index 548b46974f..9d2f122227 100755
--- a/wps/wpsbuild.pl
+++ b/wps/wpsbuild.pl
@@ -28,7 +28,7 @@ my $wpslist=$ARGV[0];
28 28
29my $target = $ARGV[1]; 29my $target = $ARGV[1];
30my $cppdef = $target; 30my $cppdef = $target;
31 31my @depthlist = ( 16, 8, 4, 2, 1 );
32 32
33if(!$wpslist) { 33if(!$wpslist) {
34 print "Usage: wpsbuilds.pl <WPSLIST> <target>\n", 34 print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
@@ -48,6 +48,7 @@ sub getlcdsizes {
48#ifdef HAVE_REMOTE_LCD 48#ifdef HAVE_REMOTE_LCD
49Height: LCD_REMOTE_HEIGHT 49Height: LCD_REMOTE_HEIGHT
50Width: LCD_REMOTE_WIDTH 50Width: LCD_REMOTE_WIDTH
51Depth: LCD_REMOTE_DEPTH
51#endif 52#endif
52STOP 53STOP
53; 54;
@@ -58,6 +59,7 @@ STOP
58#ifdef HAVE_LCD_BITMAP 59#ifdef HAVE_LCD_BITMAP
59Height: LCD_HEIGHT 60Height: LCD_HEIGHT
60Width: LCD_WIDTH 61Width: LCD_WIDTH
62Depth: LCD_DEPTH
61#endif 63#endif
62STOP 64STOP
63; 65;
@@ -78,14 +80,17 @@ STOP
78 elsif($_ =~ /^Width: (\d*)/) { 80 elsif($_ =~ /^Width: (\d*)/) {
79 $width = $1; 81 $width = $1;
80 } 82 }
81 if($height && $width) { 83 elsif($_ =~ /^Depth: (\d*)/) {
84 $depth = $1;
85 }
86 if($height && $width && $depth) {
82 last; 87 last;
83 } 88 }
84 } 89 }
85 close(GETSIZE); 90 close(GETSIZE);
86 unlink("gcctemp"); 91 unlink("gcctemp");
87 92
88 return ($height, $width); 93 return ($height, $width, $depth);
89} 94}
90 95
91sub mkdirs { 96sub mkdirs {
@@ -97,8 +102,9 @@ sub mkdirs {
97 if( -d ".rockbox/wps/$wpsdir") { 102 if( -d ".rockbox/wps/$wpsdir") {
98 #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n"; 103 #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
99 } 104 }
100 else { 105 else
101 mkdir ".rockbox/wps/$wpsdir", 0777; 106 {
107 mkdir ".rockbox/wps/$wpsdir", 0777;
102 } 108 }
103} 109}
104 110
@@ -106,19 +112,40 @@ sub copywps {
106 # we assume that we copy the WPS files from the same dir the WPSLIST 112 # we assume that we copy the WPS files from the same dir the WPSLIST
107 # file is located in 113 # file is located in
108 my $dir; 114 my $dir;
115 my @filelist;
116 my $file;
109 117
110 if($wpslist =~ /(.*)WPSLIST/) { 118 if($wpslist =~ /(.*)WPSLIST/) {
111 $dir = $1; 119 $dir = $1;
112 my $wpsdir = $wps; 120# system("cp $dir/$wps .rockbox/wps/");
113 $wpsdir =~ s/\.(r|)wps//; 121 # print "$req_t_wps $req_g_wps\n";
114 system("cp $dir/$wps .rockbox/wps/");
115 122
116 if (-e "$dir/$wpsdir") { 123 if (-e "$dir/$req_t_wps" ) {
117 system("cp $dir/$wpsdir/*.bmp .rockbox/wps/$wpsdir/"); 124 system("cp $dir/$req_t_wps .rockbox/wps/$wps");
118 } 125
119 } 126 } elsif (-e "$dir/$req_g_wps") {
120 else { 127 system("cp $dir/$req_g_wps .rockbox/wps/$wps");
121 print STDERR "beep, no dir to copy WPS from!\n"; 128
129 open(WPSFILE, "$dir/$req_g_wps");
130 while (<WPSFILE>) {
131 $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
132 }
133 close(WPSFILE);
134
135 if (-e "$dir/$wpsdir") {
136 foreach $file (@filelist) {
137 system("cp $dir/$wps_prefix/$file .rockbox/wps/$wps_prefix/");
138 }
139 }
140 else {
141 print STDERR "beep, no dir to copy WPS from!\n";
142 }
143
144 } else {
145 print STDERR "Skipping $wps - no matching resolution.\n";
146 }
147 } else {
148 print STDERR "No source directory!\n";
122 } 149 }
123} 150}
124 151
@@ -157,10 +184,11 @@ MOO
157} 184}
158 185
159# Get the LCD sizes first 186# Get the LCD sizes first
160my ($main_height, $main_width) = getlcdsizes(); 187my ($main_height, $main_width, $main_depth) = getlcdsizes();
161my ($remote_height, $remote_width) = getlcdsizes(1); 188my ($remote_height, $remote_width, $remote_depth) = getlcdsizes(1);
162 189
163$has_remote = true if ($remote_height && $remote_width); 190#print "LCD: ${main_height}x${main_width}x${main_depth}\n";
191$has_remote = true if ($remote_height && $remote_width && remote_depth);
164 192
165open(WPS, "<$wpslist"); 193open(WPS, "<$wpslist");
166while(<WPS>) { 194while(<WPS>) {
@@ -174,23 +202,28 @@ while(<WPS>) {
174 $within = 1; 202 $within = 1;
175 # undef is a unary operator (!) 203 # undef is a unary operator (!)
176 undef $wps; 204 undef $wps;
205 undef $wps_prefix;
177 undef $rwps; 206 undef $rwps;
178 undef $width; 207 undef $width;
179 undef $height; 208 undef $height;
180 undef $font; 209 undef $font;
181 undef $statusbar; 210 undef $statusbar;
182 undef $author; 211 undef $author;
212 undef $req_g_wps;
213 undef $req_t_wps;
183 next; 214 next;
184 } 215 }
185 if($within) { 216 if($within) {
186 if($l =~ /^ *<\/${isrwps}wps>/i) { 217 if($l =~ /^ *<\/${isrwps}wps>/i) {
187 # Get the required width and height 218 # Get the required width and height
188 my ($rheight, $rwidth); 219 my ($rheight, $rwidth, $rdepth);
189 if($isrwps) { 220 if($isrwps) {
190 ($rheight, $rwidth) = ($remote_height, $remote_width); 221 ($rheight, $rwidth, $rdepth) =
222 ($remote_height, $remote_width, $remote_depth);
191 } 223 }
192 else { 224 else {
193 ($rheight, $rwidth) = ($main_height, $main_width); 225 ($rheight, $rwidth, $rdepth) =
226 ($main_height, $main_width, $main_depth);
194 } 227 }
195 228
196 if(!$rheight || !$rwidth) { 229 if(!$rheight || !$rwidth) {
@@ -199,17 +232,30 @@ while(<WPS>) {
199 $within = 0; 232 $within = 0;
200 next; 233 next;
201 } 234 }
235 $wpslist =~ /(.*)WPSLIST/;
236 my $wpsdir = $1;
237 # If this WPS installable on this platform, one of the following
238 # two files will be present
239 foreach $d (@depthlist) {
240 next if ($d > $rdepth);
241
242 $req_g_wps = $wps_prefix . "." . $rwidth . "x" . $rheight
243 . "x" . $d . ".wps";
244 last if (-e "$wpsdir/$req_g_wps");
245 }
246 $req_t_wps = $wps_prefix . ".txt" . ".wps";
202 247
203 #print "LCD: $wps wants $height x $width\n"; 248 #print "LCD: $wps wants $height x $width\n";
204 #print "LCD: is $rheight x $rwidth\n"; 249 #print "LCD: is $rheight x $rwidth\n";
205 250
206 if(($height <= $rheight) && ($width <= $rwidth)) { 251 #print "gwps: $wpsdir/$req_g_wps" . "\n";
252 if (-e "$wpsdir/$req_g_wps" || -e "$wpsdir/$req_t_wps" ) {
207 # 253 #
208 # The target model has an LCD that is suitable for this 254 # The target model has an LCD that is suitable for this
209 # WPS 255 # WPS
210 # 256 #
211 #print "Size requirement is fine!\n"; 257 #print "Size requirement is fine!\n";
212 mkdirs(); 258 mkdirs() if (-e "$wpsdir/$req_g_wps");
213 if(!$isrwps) { 259 if(!$isrwps) {
214 # We only make .cfg files for <wps> sections: 260 # We only make .cfg files for <wps> sections:
215 buildcfg(); 261 buildcfg();
@@ -217,14 +263,17 @@ while(<WPS>) {
217 copywps(); 263 copywps();
218 } 264 }
219 else { 265 else {
220 #print "Skip $wps due to size restraints\n"; 266 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
267 print "Skip $wps due to size restraints\n";
221 } 268 }
222 $within = 0; 269 $within = 0;
223 } 270 }
224 elsif($l =~ /^Name: (.*)/i) { 271 elsif($l =~ /^Name: (.*)/i) {
225 # Note that in the case this is within <rwps>, $wps will contain the 272 # Note that in the case this is within <rwps>, $wps will contain the
226 # name of the rwps. Use $isrwps to figure out what type it is. 273 # name of the rwps. Use $isrwps to figure out what type it is.
227 $wps = $1; 274 $wps = $wps_prefix = $1;
275 $wps_prefix =~ s/\.(r|)wps//;
276 # print $wps_prefix . "\n";
228 } 277 }
229 elsif($l =~ /^RWPS: (.*)/i) { 278 elsif($l =~ /^RWPS: (.*)/i) {
230 $rwps = $1; 279 $rwps = $1;
@@ -247,4 +296,4 @@ while(<WPS>) {
247 } 296 }
248} 297}
249 298
250close(WPS) 299close(WPS);