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
60 my $lineselecttextcolor;
63 my $remotelistviewport;
66 my ($main_height, $main_width, $main_depth);
67 my ($remote_height, $remote_width, $remote_depth);
72 print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
73 "Run this script in the root of the target build, and it will put all the\n",
74 "stuff in $rbdir/wps/\n";
82 open(GCC
, ">gcctemp");
84 # Get the remote LCD screen size
87 #ifdef HAVE_REMOTE_LCD
88 Height: LCD_REMOTE_HEIGHT
89 Width: LCD_REMOTE_WIDTH
90 Depth: LCD_REMOTE_DEPTH
106 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
110 open(GETSIZE
, "$c|");
112 my ($height, $width, $depth);
114 if($_ =~ /^Height: (\d*)/) {
117 elsif($_ =~ /^Width: (\d*)/) {
120 elsif($_ =~ /^Depth: (\d*)/) {
123 if($height && $width && $depth) {
130 return ($height, $width, $depth);
136 $wpsdir =~ s/\.(r|)wps//;
137 mkdir "$rbdir/wps", 0777;
138 mkdir "$rbdir/themes", 0777;
140 if( -d
"$rbdir/wps/$wpsdir") {
141 #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
145 mkdir "$rbdir/wps/$wpsdir", 0777;
151 #copy the backdrop file into the build dir
152 if ($backdrop ne '') {
154 $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
155 my $cmd = "cp $ROOT/$backdrop $rbdir/$dst";
162 #copy the font specified by the theme
165 $o =~ s/\.fnt/\.bdf/;
166 mkdir "$rbdir/fonts";
167 my $cmd ="$ROOT/tools/convbdf -f -o \"$rbdir/fonts/$font\" \"$ROOT/fonts/$o\" ";
173 #copy the icon specified by the theme
175 if ($iconset ne '') {
176 $iconset =~ s/.rockbox/$rbdir/;
177 $iconset =~ /\/(.*icons\
/(.*))/i;
178 `cp $ROOT/icons/$2 $1`;
182 sub copythemeviewericon
184 #copy the viewer icon specified by the theme
186 if ($viewericon ne '') {
187 $viewericon =~ s/.rockbox/$rbdir/;
188 $viewericon =~ /\/(.*icons\
/(.*))/i;
189 `cp $ROOT/icons/$2 $1`;
195 # we assume that we copy the WPS files from the same dir the WPSLIST
202 if($wpslist =~ /(.*)WPSLIST/) {
204 $__sb = $sbs_prefix . "." . $req_size . ".sbs";
205 #print "$req_t_wps $req_g_wps $sbs_prefix\n";
206 #print "$dir/$__sb\n";
208 # system("cp $dir/$wps .rockbox/wps/");
209 # check for <name>.WIDTHxHEIGHTxDEPTH.sbs
210 if (-e
"$dir/$__sb") {
211 system("cp $dir/$__sb $rbdir/wps/$sbs");
213 # check for <name>.WIDTHxHEIGHTxDEPTH.<model>.sbs and overwrite the
214 # previous sb if needed
215 $__sb = $sbs_prefix . "." . $req_size . "." . $modelname . ".sbs";
216 if (-e
"$dir/$__sb") {
217 system("cp $dir/$__sb $rbdir/wps/$sbs");
220 if (-e
"$dir/$req_t_wps" ) {
221 system("cp $dir/$req_t_wps $rbdir/wps/$wps");
223 } elsif (-e
"$dir/$req_g_wps") {
224 system("cp $dir/$req_g_wps $rbdir/wps/$wps");
226 open(WPSFILE
, "$dir/$req_g_wps");
228 $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
232 if ($#filelist >= 0) {
233 if (-e
"$dir/$wps_prefix/$req_size") {
234 foreach $file (@filelist) {
235 system("cp $dir/$wps_prefix/$req_size/$file $rbdir/wps/$wps_prefix/");
238 elsif (-e
"$dir/$wps_prefix") {
239 foreach $file (@filelist) {
240 system("cp $dir/$wps_prefix/$file $rbdir/wps/$wps_prefix/");
244 print STDERR
"beep, no dir to copy WPS from!\n";
249 print STDERR
"Skipping $wps - no matching resolution.\n";
252 print STDERR
"No source directory!\n";
260 $cfg =~ s/\.(r|)wps/.cfg/;
264 \# $cfg generated by wpsbuild.pl
265 \# $wps is made by $author
267 wps: /$rbdir/wps/$wps
272 push @out, "sbs: -\n";
274 push @out, "sbs: /$rbdir/wps/$sbs\n";
277 if(defined($sbs) && $has_remote) {
279 push @out, "rsbs: -\n";
281 push @out, "rsbs: /$rbdir/wps/$rsbs\n";
285 push @out, "font: /$rbdir/fonts/$font\n";
287 if($fgcolor && $main_depth > 2) {
288 push @out, "foreground color: $fgcolor\n";
290 if($bgcolor && $main_depth > 2) {
291 push @out, "background color: $bgcolor\n";
294 if($rwps && $has_remote ) {
295 push @out, "remote statusbar: $statusbar\n";
297 push @out, "statusbar: $statusbar\n";
299 if(defined($backdrop)) {
300 if ($backdrop eq '') {
301 push @out, "backdrop: -\n";
303 # clip resolution from filename
304 $backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
305 push @out, "backdrop: /$rbdir/$backdrop\n";
308 if($lineselectstart && $main_depth > 2) {
309 push @out, "line selector start color: $lineselectstart\n";
311 if($lineselectend && $main_depth > 2) {
312 push @out, "line selector end color: $lineselectend\n";
315 push @out, "selector type: $selecttype\n";
317 if(defined($iconset)) {
318 push @out, "iconset: $iconset\n";
320 if(defined($viewericon)) {
321 push @out, "viewers iconset: $viewericon\n";
323 if($lineselecttextcolor && $main_depth > 2 ) {
324 push @out, "line selector text color: $lineselecttextcolor\n";
326 if($filetylecolor && $main_depth > 2) {
327 push @out, "filetype colours: $filetylecolor\n";
329 if($rwps && $has_remote ) {
330 push @out, "rwps: /$rbdir/wps/$rwps\n";
332 if(defined($listviewport)) {
333 push @out, "ui viewport: $listviewport\n";
335 if(defined($remotelistviewport) && $has_remote) {
336 push @out, "remote ui viewport: $listviewport\n";
338 if(-f
"$rbdir/wps/$cfg") {
339 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
342 open(CFG
, ">$rbdir/themes/$cfg");
348 # Get the LCD sizes first
349 ($main_height, $main_width, $main_depth) = getlcdsizes
();
350 ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
352 #print "LCD: ${main_width}x${main_height}x${main_depth}\n";
353 $has_remote = 1 if ($remote_height && $remote_width && $remote_depth);
358 open(WPS
, "<$wpslist");
368 if($l =~ /^ *<(r|)wps>/i) {
371 # undef is a unary operator (!)
387 undef $lineselectstart;
388 undef $lineselectend;
392 undef $lineselecttextcolor;
393 undef $filetylecolor;
395 undef $remotelistviewport;
400 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
401 # Get the required width and height
402 my ($rheight, $rwidth, $rdepth);
404 ($rheight, $rwidth, $rdepth) =
405 ($remote_height, $remote_width, $remote_depth);
408 ($rheight, $rwidth, $rdepth) =
409 ($main_height, $main_width, $main_depth);
412 if(!$rheight || !$rwidth) {
413 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
414 #$isrwps?"remote ":"";
418 $wpslist =~ /(.*)WPSLIST/;
420 # If this WPS installable on this platform, one of the following
421 # two files will be present
422 foreach my $d (@depthlist) {
423 next if ($d > $rdepth);
425 $req_size = $rwidth . "x" . $rheight . "x" . $d;
427 # check for model specific wps
428 $req_g_wps = $wps_prefix . "." . $req_size . "." . $modelname . ".wps";
429 last if (-e
"$wpsdir/$req_g_wps");
431 # check for normal wps (with WIDTHxHEIGHTxDEPTH)
432 $req_g_wps = $wps_prefix . "." . $req_size . ".wps";
433 last if (-e
"$wpsdir/$req_g_wps");
436 $req_size = $req_size . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
438 $req_g_wps = $wps_prefix . "." . $req_size . ".wps";
439 last if (-e
"$wpsdir/$req_g_wps");
442 $req_t_wps = $wps_prefix . $req_t . ".wps";
444 #print "LCD: $wps wants $width x $height\n";
445 #print "LCD: is $rwidth x $rheight\n";
447 #print "gwps: $wpsdir/$req_g_wps" . "\n";
448 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
450 # The target model has an LCD that is suitable for this
453 #print "Size requirement is fine!\n";
454 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
455 # Do the copying before building the .cfg - buildcfg()
456 # mangles some filenames
464 copythemeviewericon
();
470 # We only make .cfg files for <wps> sections:
476 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
477 #print "Skip $wps due to size restraints\n";
481 elsif($l =~ /^Name: *(.*)/i) {
482 # Note that in the case this is within <rwps>, $wps will contain the
483 # name of the rwps. Use $isrwps to figure out what type it is.
484 $wps = $wps_prefix = $1;
485 $wps_prefix =~ s/\.(r|)wps//;
486 #print $wps_prefix . "\n";
488 elsif($l =~ /^RWPS: *(.*)/i) {
491 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
494 elsif($l =~ /^SBS: *(.*)/i) {
495 $sbs = $sbs_prefix = $1;
496 $sbs_prefix =~ s/\.(r|)sbs//;
498 elsif($l =~ /^SBS\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
499 $sbs = $sbs_prefix = $1;
500 $sbs_prefix =~ s/\.(r|)sbs//;
502 elsif($l =~ /^RSBS: *(.*)/i) {
505 elsif($l =~ /^RSBS\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
508 elsif($l =~ /^Author: *(.*)/i) {
511 elsif($l =~ /^Width: *(.*)/i) {
514 elsif($l =~ /^Width\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
517 elsif($l =~ /^Height: *(.*)/i) {
520 elsif($l =~ /^Height\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
523 elsif($l =~ /^Font: *(.*)/i) {
526 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
529 elsif($l =~ /^Foreground Color: *(.*)/i) {
532 elsif($l =~ /^Background Color: *(.*)/i) {
535 elsif($l =~ /^Statusbar: *(.*)/i) {
538 elsif($l =~ /^Statusbar\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
541 elsif($l =~ /^Backdrop: *(.*)/i) {
544 elsif($l =~ /^Backdrop\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
547 elsif($l =~ /^line selector start color: *(.*)/i) {
548 $lineselectstart = $1;
550 elsif($l =~ /^line selector end color: *(.*)/i) {
553 elsif($l =~ /^selector type: *(.*)/i) {
556 elsif($l =~ /^selector type\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
559 elsif($l =~ /^iconset: *(.*)/i) {
562 elsif($l =~ /^iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
565 elsif($l =~ /^viewers iconset: *(.*)/i) {
568 elsif($l =~ /^viewers iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
571 elsif($l =~ /^line selector text color: *(.*)/i) {
572 $lineselecttextcolor = $1;
574 elsif($l =~ /^filetype colours: *(.*)/i) {
577 elsif($l =~ /^ui viewport: *(.*)/i) {
580 elsif($l =~ /^ui viewport\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
583 elsif($l =~ /^remote ui viewport: *(.*)/i) {
584 $remotelistviewport = $1;
586 elsif($l =~ /^remote ui viewport\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
587 $remotelistviewport = $1;
590 #print "Unknown line: $l!\n";