3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
12 use Getopt
::Long
qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
22 GetOptions
( 'r|root=s' => \
$ROOT,
23 'm|modelname=s' => \
$modelname,
24 'v|verbose' => \
$verbose,
25 'rbdir=s' => \
$rbdir, # If we want to put in a different directory
28 ($wpslist, $target) = @ARGV;
30 my $firmdir="$ROOT/firmware";
32 my @depthlist = ( 16, 8, 4, 2, 1 );
34 # These parameters are filled in as we parse wpslist
61 my $lineselecttextcolor;
64 my $remotelistviewport;
67 my ($main_height, $main_width, $main_depth);
68 my ($remote_height, $remote_width, $remote_depth);
73 print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
74 "Run this script in the root of the target build, and it will put all the\n",
75 "stuff in $rbdir/wps/\n";
83 open(GCC
, ">gcctemp");
85 # Get the remote LCD screen size
88 #ifdef HAVE_REMOTE_LCD
89 Height: LCD_REMOTE_HEIGHT
90 Width: LCD_REMOTE_WIDTH
91 Depth: LCD_REMOTE_DEPTH
107 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
111 open(GETSIZE
, "$c|");
113 my ($height, $width, $depth);
115 if($_ =~ /^Height: (\d*)/) {
118 elsif($_ =~ /^Width: (\d*)/) {
121 elsif($_ =~ /^Depth: (\d*)/) {
124 if($height && $width && $depth) {
131 return ($height, $width, $depth);
137 $wpsdir =~ s/\.(r|)wps//;
138 mkdir "$rbdir/wps", 0777;
139 mkdir "$rbdir/themes", 0777;
141 if( -d
"$rbdir/wps/$wpsdir") {
142 #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
146 mkdir "$rbdir/wps/$wpsdir", 0777;
152 #copy the backdrop file into the build dir
153 if ($backdrop ne '') {
155 $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
156 my $cmd = "cp $ROOT/$backdrop $rbdir/$dst";
163 #copy the font specified by the theme
166 $o =~ s/\.fnt/\.bdf/;
167 mkdir "$rbdir/fonts";
168 my $cmd ="$ROOT/tools/convbdf -f -o \"$rbdir/fonts/$_[0]\" \"$ROOT/fonts/$o\" ";
174 #copy the icon specified by the theme
176 if ($iconset ne '') {
177 $iconset =~ s/.rockbox/$rbdir/;
178 $iconset =~ /\/(.*icons\
/(.*))/i;
179 `cp $ROOT/icons/$2 $1`;
183 sub copythemeviewericon
185 #copy the viewer icon specified by the theme
187 if ($viewericon ne '') {
188 $viewericon =~ s/.rockbox/$rbdir/;
189 $viewericon =~ /\/(.*icons\
/(.*))/i;
190 `cp $ROOT/icons/$2 $1`;
196 # we assume that we copy the WPS files from the same dir the WPSLIST
203 if($wpslist =~ /(.*)WPSLIST/) {
205 $__sb = $sbs_prefix . "." . $req_size . ".sbs";
206 #print "$req_t_wps $req_g_wps $sbs_prefix\n";
207 #print "$dir/$__sb\n";
209 # system("cp $dir/$wps .rockbox/wps/");
210 # check for <name>.WIDTHxHEIGHTxDEPTH.sbs
211 if (-e
"$dir/$__sb") {
212 system("cp $dir/$__sb $rbdir/wps/$sbs");
214 # check for <name>.WIDTHxHEIGHTxDEPTH.<model>.sbs and overwrite the
215 # previous sb if needed
216 $__sb = $sbs_prefix . "." . $req_size . "." . $modelname . ".sbs";
217 if (-e
"$dir/$__sb") {
218 system("cp $dir/$__sb $rbdir/wps/$sbs");
221 if (-e
"$dir/$req_t_wps" ) {
222 system("cp $dir/$req_t_wps $rbdir/wps/$wps");
224 } elsif (-e
"$dir/$req_g_wps") {
225 system("cp $dir/$req_g_wps $rbdir/wps/$wps");
227 open(WPSFILE
, "$dir/$req_g_wps");
229 $filelist[$#filelist + 1] = $1 if (/[\(,]([^,]*?.bmp)[\),]/);
233 if ($#filelist >= 0) {
234 if (-e
"$dir/$wps_prefix/$req_size") {
235 foreach $file (@filelist) {
236 system("cp $dir/$wps_prefix/$req_size/$file $rbdir/wps/$wps_prefix/");
239 elsif (-e
"$dir/$wps_prefix") {
240 foreach $file (@filelist) {
241 system("cp $dir/$wps_prefix/$file $rbdir/wps/$wps_prefix/");
245 print STDERR
"beep, no dir to copy WPS from!\n";
250 print STDERR
"Skipping $wps - no matching resolution.\n";
253 print STDERR
"No source directory!\n";
261 $cfg =~ s/\.(r|)wps/.cfg/;
265 \# $cfg generated by wpsbuild.pl
266 \# $wps is made by $author
268 wps: /$rbdir/wps/$wps
273 push @out, "sbs: -\n";
275 push @out, "sbs: /$rbdir/wps/$sbs\n";
278 if(defined($rsbs) && $has_remote) {
280 push @out, "rsbs: -\n";
282 push @out, "rsbs: /$rbdir/wps/$rsbs\n";
287 push @out, "font: -\n";
289 push @out, "font: /$rbdir/fonts/$font\n";
292 if(defined($remotefont) && $has_remote) {
293 if ($remotefont eq '') {
294 push @out, "remote font: -\n";
296 push @out, "remote font: /$rbdir/fonts/$remotefont\n";
299 if($fgcolor && $main_depth > 2) {
300 push @out, "foreground color: $fgcolor\n";
302 if($bgcolor && $main_depth > 2) {
303 push @out, "background color: $bgcolor\n";
306 if($rwps && $has_remote ) {
307 push @out, "remote statusbar: $statusbar\n";
309 push @out, "statusbar: $statusbar\n";
311 if(defined($backdrop)) {
312 if ($backdrop eq '') {
313 push @out, "backdrop: -\n";
315 # clip resolution from filename
316 $backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
317 push @out, "backdrop: /$rbdir/$backdrop\n";
320 if($lineselectstart && $main_depth > 2) {
321 push @out, "line selector start color: $lineselectstart\n";
323 if($lineselectend && $main_depth > 2) {
324 push @out, "line selector end color: $lineselectend\n";
327 push @out, "selector type: $selecttype\n";
329 if(defined($iconset)) {
330 if ($iconset eq '') {
331 push @out, "iconset: -\n";
333 push @out, "iconset: $iconset\n";
336 if(defined($viewericon)) {
337 if ($viewericon eq '') {
338 push @out, "viewers iconset: -\n";
340 push @out, "viewers iconset: $viewericon\n";
343 if($lineselecttextcolor && $main_depth > 2 ) {
344 push @out, "line selector text color: $lineselecttextcolor\n";
346 if($filetylecolor && $main_depth > 2) {
347 if ($filetylecolor eq '') {
348 push @out, "filetype colours: -\n";
350 push @out, "filetype colours: $filetylecolor\n";
353 if($rwps && $has_remote ) {
355 push @out, "rwps: -\n";
357 push @out, "rwps: /$rbdir/wps/$rwps\n";
360 if(defined($listviewport)) {
361 if ($listviewport eq '') {
362 push @out, "ui viewport: -\n";
364 push @out, "ui viewport: $listviewport\n";
367 if(defined($remotelistviewport) && $has_remote) {
368 if ($remotelistviewport eq '') {
369 push @out, "remote ui viewport: -\n";
371 push @out, "remote ui viewport: $listviewport\n";
374 if(-f
"$rbdir/wps/$cfg") {
375 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
378 open(CFG
, ">$rbdir/themes/$cfg");
384 # Get the LCD sizes first
385 ($main_height, $main_width, $main_depth) = getlcdsizes
();
386 ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
388 #print "LCD: ${main_width}x${main_height}x${main_depth}\n";
389 $has_remote = 1 if ($remote_height && $remote_width && $remote_depth);
394 open(WPS
, "<$wpslist");
404 if($l =~ /^ *<(r|)wps>/i) {
407 # undef is a unary operator (!)
424 undef $lineselectstart;
425 undef $lineselectend;
429 undef $lineselecttextcolor;
430 undef $filetylecolor;
432 undef $remotelistviewport;
437 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
438 # Get the required width and height
439 my ($rheight, $rwidth, $rdepth);
441 ($rheight, $rwidth, $rdepth) =
442 ($remote_height, $remote_width, $remote_depth);
445 ($rheight, $rwidth, $rdepth) =
446 ($main_height, $main_width, $main_depth);
449 if(!$rheight || !$rwidth) {
450 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
451 #$isrwps?"remote ":"";
455 $wpslist =~ /(.*)WPSLIST/;
457 # If this WPS installable on this platform, one of the following
458 # two files will be present
459 foreach my $d (@depthlist) {
460 next if ($d > $rdepth);
462 $req_size = $rwidth . "x" . $rheight . "x" . $d;
464 # check for model specific wps
465 $req_g_wps = $wps_prefix . "." . $req_size . "." . $modelname . ".wps";
466 last if (-e
"$wpsdir/$req_g_wps");
468 # check for normal wps (with WIDTHxHEIGHTxDEPTH)
469 $req_g_wps = $wps_prefix . "." . $req_size . ".wps";
470 last if (-e
"$wpsdir/$req_g_wps");
473 $req_size = $req_size . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
475 $req_g_wps = $wps_prefix . "." . $req_size . ".wps";
476 last if (-e
"$wpsdir/$req_g_wps");
479 $req_t_wps = $wps_prefix . ".txt" . ".wps";
481 #print "LCD: $wps wants $width x $height\n";
482 #print "LCD: is $rwidth x $rheight\n";
484 #print "gwps: $wpsdir/$req_g_wps" . "\n";
485 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
487 # The target model has an LCD that is suitable for this
490 #print "Size requirement is fine!\n";
491 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
492 # Do the copying before building the .cfg - buildcfg()
493 # mangles some filenames
501 copythemeviewericon
();
504 copythemefont
($font);
507 copythemefont
($remotefont);
510 # We only make .cfg files for <wps> sections:
516 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
517 #print "Skip $wps due to size restraints\n";
521 elsif($l =~ /^Name: *(.*)/i) {
522 # Note that in the case this is within <rwps>, $wps will contain the
523 # name of the rwps. Use $isrwps to figure out what type it is.
524 $wps = $wps_prefix = $1;
525 $wps_prefix =~ s/\.(r|)wps//;
526 #print $wps_prefix . "\n";
528 elsif($l =~ /^RWPS: *(.*)/i) {
531 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
534 elsif($l =~ /^SBS: *(.*)/i) {
535 $sbs = $sbs_prefix = $1;
536 $sbs_prefix =~ s/\.(r|)sbs//;
538 elsif($l =~ /^SBS\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
539 $sbs = $sbs_prefix = $1;
540 $sbs_prefix =~ s/\.(r|)sbs//;
542 elsif($l =~ /^RSBS: *(.*)/i) {
545 elsif($l =~ /^RSBS\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
548 elsif($l =~ /^Author: *(.*)/i) {
551 elsif($l =~ /^Width: *(.*)/i) {
554 elsif($l =~ /^Width\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
557 elsif($l =~ /^Height: *(.*)/i) {
560 elsif($l =~ /^Height\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
563 elsif($l =~ /^Font: *(.*)/i) {
566 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
569 elsif($l =~ /^Remote Font\.${remote_width}x${remote_height}x$remote_depth: *(.*)/i) {
572 elsif($l =~ /^Remote Font: *(.*)/i) {
575 elsif($l =~ /^Foreground Color: *(.*)/i) {
578 elsif($l =~ /^Background Color: *(.*)/i) {
581 elsif($l =~ /^Statusbar: *(.*)/i) {
584 elsif($l =~ /^Statusbar\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
587 elsif($l =~ /^Backdrop: *(.*)/i) {
590 elsif($l =~ /^Backdrop\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
593 elsif($l =~ /^line selector start color: *(.*)/i) {
594 $lineselectstart = $1;
596 elsif($l =~ /^line selector end color: *(.*)/i) {
599 elsif($l =~ /^selector type: *(.*)/i) {
602 elsif($l =~ /^selector type\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
605 elsif($l =~ /^iconset: *(.*)/i) {
608 elsif($l =~ /^iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
611 elsif($l =~ /^viewers iconset: *(.*)/i) {
614 elsif($l =~ /^viewers iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
617 elsif($l =~ /^line selector text color: *(.*)/i) {
618 $lineselecttextcolor = $1;
620 elsif($l =~ /^filetype colours: *(.*)/i) {
623 elsif($l =~ /^ui viewport: *(.*)/i) {
626 elsif($l =~ /^ui viewport\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
629 elsif($l =~ /^remote ui viewport: *(.*)/i) {
630 $remotelistviewport = $1;
632 elsif($l =~ /^remote ui viewport\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
633 $remotelistviewport = $1;
636 #print "Unknown line: $l!\n";