3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
13 if($ARGV[0] eq "-r") {
20 if($ARGV[0] eq "-v") {
25 my $firmdir="$ROOT/firmware";
29 my $target = $ARGV[1];
31 my @depthlist = ( 16, 8, 4, 2, 1 );
34 print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
35 "Run this script in the root of the target build, and it will put all the\n",
36 "stuff in .rockbox/wps/\n";
43 open(GCC
, ">gcctemp");
45 # Get the remote LCD screen size
48 #ifdef HAVE_REMOTE_LCD
49 Height: LCD_REMOTE_HEIGHT
50 Width: LCD_REMOTE_WIDTH
51 Depth: LCD_REMOTE_DEPTH
67 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
75 if($_ =~ /^Height: (\d*)/) {
78 elsif($_ =~ /^Width: (\d*)/) {
81 elsif($_ =~ /^Depth: (\d*)/) {
84 if($height && $width && $depth) {
91 return ($height, $width, $depth);
96 $wpsdir =~ s/\.(r|)wps//;
97 mkdir ".rockbox/wps", 0777;
98 mkdir ".rockbox/themes", 0777;
100 if( -d
".rockbox/wps/$wpsdir") {
101 #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
105 mkdir ".rockbox/wps/$wpsdir", 0777;
110 #copy the backdrop file into the build dir
112 $backdrop =~ /\/(.*backdrops\
/(.*))/i;
113 `cp $ROOT/backdrops/$2 $1`;
117 #copy the font specified by the theme
120 $o =~ s/\.fnt/\.bdf/;
121 `mkdir .rockbox/fonts/ >/dev/null 2>&1`;
122 $cmd ="$ROOT/tools/convbdf -f -o \".rockbox/fonts/$font\" \"$ROOT/fonts/$o\" ";
127 #copy the icon specified by the theme
129 $iconset =~ /\/(.*icons\
/(.*))/i;
130 `cp $ROOT/icons/$2 $1`;
133 sub copythemeviewericon
{
134 #copy the viewer icon specified by the theme
136 $viewericon =~ /\/(.*icons\
/(.*))/i;
137 `cp $ROOT/icons/$2 $1`;
142 # we assume that we copy the WPS files from the same dir the WPSLIST
148 if($wpslist =~ /(.*)WPSLIST/) {
150 # system("cp $dir/$wps .rockbox/wps/");
151 # print "$req_t_wps $req_g_wps\n";
153 if (-e
"$dir/$req_t_wps" ) {
154 system("cp $dir/$req_t_wps .rockbox/wps/$wps");
156 } elsif (-e
"$dir/$req_g_wps") {
157 system("cp $dir/$req_g_wps .rockbox/wps/$wps");
159 open(WPSFILE
, "$dir/$req_g_wps");
161 $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
165 if ($#filelist >= 0) {
166 if (-e
"$dir/$wps_prefix/$req_g") {
167 foreach $file (@filelist) {
168 system("cp $dir/$wps_prefix/$req_g/$file .rockbox/wps/$wps_prefix/");
171 elsif (-e
"$dir/$wps_prefix") {
172 foreach $file (@filelist) {
173 system("cp $dir/$wps_prefix/$file .rockbox/wps/$wps_prefix/");
177 print STDERR
"beep, no dir to copy WPS from!\n";
182 print STDERR
"Skipping $wps - no matching resolution.\n";
185 print STDERR
"No source directory!\n";
193 $cfg =~ s/\.(r|)wps/.cfg/;
197 \# $cfg generated by wpsbuild.pl
198 \# $wps is made by $author
200 wps: /.rockbox/wps/$wps
204 push @out, "font: /.rockbox/fonts/$font\n";
207 push @out, "foreground color: $fgcolor\n";
210 push @out, "background color: $bgcolor\n";
213 push @out, "statusbar: $statusbar\n";
216 push @out, "backdrop: $backdrop\n";
218 if($lineselectstart) {
219 push @out, "line selector start color: $lineselectstart\n";
222 push @out, "line selector end color: $lineselectend\n";
225 push @out, "selector type: $selecttype\n";
228 push @out, "iconset: $iconset\n";
231 push @out, "viewers iconset: $viewericon\n";
233 if($lineselecttextcolor) {
234 push @out, "line selector text color: $lineselecttextcolor\n";
237 push @out, "filetype colours: $filetylecolor\n";
239 if($rwps && $has_remote ) {
240 push @out, "rwps: /.rockbox/wps/$rwps\n";
242 if(-f
".rockbox/wps/$cfg") {
243 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
246 open(CFG
, ">.rockbox/themes/$cfg");
252 # Get the LCD sizes first
253 my ($main_height, $main_width, $main_depth) = getlcdsizes
();
254 my ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
256 #print "LCD: ${main_height}x${main_width}x${main_depth}\n";
257 $has_remote = 1 if ($remote_height && $remote_width && remote_depth
);
259 open(WPS
, "<$wpslist");
266 if($l =~ /^ *<(r|)wps>/i) {
269 # undef is a unary operator (!)
283 undef $lineselectstart;
284 undef $lineselectend;
288 undef $lineselecttextcolor;
289 undef $filetylecolor;
294 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
295 # Get the required width and height
296 my ($rheight, $rwidth, $rdepth);
298 ($rheight, $rwidth, $rdepth) =
299 ($remote_height, $remote_width, $remote_depth);
302 ($rheight, $rwidth, $rdepth) =
303 ($main_height, $main_width, $main_depth);
306 if(!$rheight || !$rwidth) {
307 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
308 #$isrwps?"remote ":"";
312 $wpslist =~ /(.*)WPSLIST/;
314 # If this WPS installable on this platform, one of the following
315 # two files will be present
316 foreach $d (@depthlist) {
317 next if ($d > $rdepth);
319 $req_g = $rwidth . "x" . $rheight . "x" . $d;
321 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
322 last if (-e
"$wpsdir/$req_g_wps");
325 $req_g = $req_g . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
327 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
328 last if (-e
"$wpsdir/$req_g_wps");
331 $req_t_wps = $wps_prefix . ".txt" . ".wps";
333 #print "LCD: $wps wants $height x $width\n";
334 #print "LCD: is $rheight x $rwidth\n";
336 #print "gwps: $wpsdir/$req_g_wps" . "\n";
337 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
339 # The target model has an LCD that is suitable for this
342 #print "Size requirement is fine!\n";
343 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
345 # We only make .cfg files for <wps> sections:
351 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
352 #print "Skip $wps due to size restraints\n";
356 elsif($l =~ /^Name: (.*)/i) {
357 # Note that in the case this is within <rwps>, $wps will contain the
358 # name of the rwps. Use $isrwps to figure out what type it is.
359 $wps = $wps_prefix = $1;
360 $wps_prefix =~ s/\.(r|)wps//;
361 # print $wps_prefix . "\n";
363 elsif($l =~ /^RWPS: (.*)/i) {
366 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: (.*)/i) {
369 elsif($l =~ /^Author: (.*)/i) {
372 elsif($l =~ /^Width: (.*)/i) {
375 elsif($l =~ /^Width\.${main_width}x${main_height}x$main_depth: (.*)/i) {
378 elsif($l =~ /^Height: (.*)/i) {
381 elsif($l =~ /^Height\.${main_width}x${main_height}x$main_depth: (.*)/i) {
384 elsif($l =~ /^Font: (.*)/i) {
387 elsif($l =~ /^Foreground Color: (.*)/i) {
390 elsif($l =~ /^Background Color: (.*)/i) {
393 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: (.*)/i) {
397 elsif($l =~ /^Statusbar: (.*)/i) {
400 elsif($l =~ /^Statusbar\.${main_width}x${main_height}x$main_depth: (.*)/i) {
403 elsif($l =~ /^Backdrop: (.*)/i) {
407 elsif($l =~ /^Backdrop\.${main_width}x${main_height}x$main_depth: (.*)/i) {
411 elsif($l =~ /^line selector start color: (.*)/i) {
412 $lineselectstart = $1;
414 elsif($l =~ /^line selector end color: (.*)/i) {
417 elsif($l =~ /^selector type: (.*)/i) {
420 elsif($l =~ /^selector type\.${main_width}x${main_height}x$main_depth: (.*)/i) {
423 elsif($l =~ /^iconset: (.*)/i) {
427 elsif($l =~ /^iconset\.${main_width}x${main_height}x$main_depth: (.*)/i) {
431 elsif($l =~ /^viewers iconset: (.*)/i) {
433 copythemeviewericon
();
435 elsif($l =~ /^viewers iconset\.${main_width}x${main_height}x$main_depth: (.*)/i) {
437 copythemeviewericon
();
439 elsif($l =~ /^line selector text color: (.*)/i) {
440 $lineselecttextcolor = $1;
442 elsif($l =~ /^filetype colours: (.*)/i) {
446 #print "Unknown line: $l!\n";