3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
12 use Getopt
::Long
qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
18 my $tempdir=".rockbox";
24 GetOptions
( 'r|root=s' => \
$ROOT,
25 'm|modelname=s' => \
$modelname,
26 'v|verbose' => \
$verbose,
27 'rbdir=s' => \
$rbdir, # If we want to put in a different directory
28 'tempdir=s' => \
$tempdir, # override .rockbox temporary dir
31 ($wpslist, $target) = @ARGV;
33 my $firmdir="$ROOT/firmware";
36 # These parameters are filled in as we parse wpslist
68 my $lineselecttextcolor;
71 my $remotelistviewport;
74 my ($main_height, $main_width, $main_depth);
75 my ($remote_height, $remote_width, $remote_depth);
80 print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
81 "Run this script in the root of the target build, and it will put all the\n",
82 "stuff in $tempdir/wps/\n and build the cfg according to $rbdir";
90 open(GCC
, ">gcctemp");
92 # Get the remote LCD screen size
95 #ifdef HAVE_REMOTE_LCD
96 Height: LCD_REMOTE_HEIGHT
97 Width: LCD_REMOTE_WIDTH
98 Depth: LCD_REMOTE_DEPTH
114 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
118 open(GETSIZE
, "$c|");
120 my ($height, $width, $depth);
122 if($_ =~ /^Height: (\d*)/) {
125 elsif($_ =~ /^Width: (\d*)/) {
128 elsif($_ =~ /^Depth: (\d*)/) {
131 if($height && $width && $depth) {
138 return ($height, $width, $depth);
143 mkdir "$tempdir/wps", 0777;
144 mkdir "$tempdir/themes", 0777;
145 mkdir "$tempdir/icons", 0777;
147 if( -d
"$tempdir/wps/$theme") {
148 #print STDERR "wpsbuild warning: directory wps/$theme already exists!\n";
152 mkdir "$tempdir/wps/$theme", 0777;
160 $in =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
166 #copy the backdrop file into the build dir
167 if ($backdrop ne '') {
168 my $dst = normalize
($backdrop);
169 system("cp $ROOT/$backdrop $tempdir/$dst");
175 #copy the font specified by the theme
178 $o =~ s/\.fnt/\.bdf/;
179 mkdir "$tempdir/fonts";
180 system("$ROOT/tools/convbdf -f -o \"$tempdir/fonts/$_[0]\" \"$ROOT/fonts/$o\" ");
186 #copy the icon specified by the theme
188 my $tempicon = $tempdir . "/" . $i;
189 $tempicon =~ /\/.*icons\
/(.*)/i;
190 system("cp $ROOT/icons/$1 $tempicon");
208 # we assume that we copy the WPS files from the same dir the WPSLIST
211 my %skinfiles = ("wps", $wps,
220 if($wpslist =~ /(.*)\/WPSLIST
/) {
223 # copy fully-fledged wps, sbs, etc. including graphics
224 foreach my $ext (keys %skinfiles) {
225 next unless ($skinfiles{$ext});
226 $file = $skinfiles{$ext};
227 system("cp $dir/$file $tempdir/wps/$theme.$ext");
228 open(SKIN
, "$dir/$file");
230 $filelist[$#filelist + 1] = $1 if (/[\(,]([^,]*?.bmp)[\),]/);
235 if ($#filelist >= 0) {
236 if (-e
"$dir/$theme") {
237 foreach $file (uniq
(@filelist)) {
238 system("cp $dir/$theme/$file $tempdir/wps/$theme/");
242 print STDERR
"beep, no dir to copy WPS from!\n";
246 print STDERR
"No source directory!\n";
251 my $cfg = $theme . ".cfg";
256 \# $cfg generated by wpsbuild.pl
257 \# $wps is made by $author
262 my %skinfiles = ("wps" => $wps,
268 for my $skin (keys %skinfiles) {
269 my $val = $skinfiles{$skin};
270 if (!defined($val)) {
271 # dont put value if not defined (e.g. rwps when there's no remote)
273 } elsif ($val eq '') {
274 # empty resets to built-in
275 push @out, "$skin: -\n";
277 # file name is always <theme>.{wps,rwps,...} (see copywps())
278 push @out, "$skin: $rbdir/wps/$theme.$skin\n";
282 push @out, "selector type: $selecttype\n" if (defined($selecttype));
283 push @out, "backdrop: $backdrop\n" if (defined($backdrop));
284 push @out, "filetype colours: $filetylecolor\n" if (defined($filetylecolor));
286 if ($main_depth > 2) {
287 push @out, "foreground color: $fgcolor\n" if($fgcolor);
288 push @out, "background color: $bgcolor\n" if($bgcolor);
289 push @out, "line selector start color: $lineselectstart\n" if($lineselectstart);
290 push @out, "line selector end color: $lineselectend\n" if($lineselectend);;
291 push @out, "line selector text color: $lineselecttextcolor\n" if($lineselecttextcolor);
294 push @out, "font: $font\n" if (defined($font));
295 push @out, "statusbar: $statusbar\n" if (defined($statusbar));
296 push @out, "iconset: $iconset\n" if (defined($iconset));
297 push @out, "viewers iconset: $viewericon\n" if (defined($viewericon));
298 push @out, "ui viewport: $listviewport\n" if (defined($listviewport));
301 push @out, "remote font: $remotefont\n" if (defined($remotefont));
302 push @out, "remote statusbar: $remotestatusbar\n" if (defined($remotestatusbar));
303 push @out, "remote iconset: $remoteiconset\n" if (defined($remoteiconset));
304 push @out, "remote viewers iconset: $remoteviewericon\n" if (defined($remoteviewericon));
305 push @out, "remote ui viewport: $remotelistviewport\n" if (defined($remotelistviewport));
308 if(-f
"$tempdir/wps/$cfg") {
309 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
312 open(CFG
, ">$tempdir/themes/$cfg");
318 # Get the LCD sizes first
319 ($main_height, $main_width, $main_depth) = getlcdsizes
();
320 ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
322 #print "LCD: ${main_width}x${main_height}x${main_depth}\n";
323 $has_remote = 1 if ($remote_height && $remote_width && $remote_depth);
326 # check if line matches the setting string or if it contains a regex
327 # that contains the targets resolution
329 my ($line, $string, $remote) = @_;
330 if ($line =~ /^${string}: *(.*)/i) {
333 elsif($line =~ /^${string}.(.*): *(.*)/i) {
334 # $1 is a resolution regex, $2 the filename incl. resolution
336 my $size_str = "${main_width}x${main_height}x${main_depth}";
338 $size_str = "${remote_width}x${remote_height}x${remote_depth}";
340 if ($size_str =~ /$1$/) {
347 # check if <theme>.<model>.<ext> exists. If not, check if <theme>.<ext> exists
350 my $req_skin = $theme . "." . $modelname . ".$ext";
351 if (-e
"$wpsdir/$req_skin") {
354 $req_skin = $theme . ".$ext";
355 if (-e
"$wpsdir/$req_skin") {
363 # Infer WPS (etc.) filename from the the if it wasnt given
364 $wpslist =~ /(.*)WPSLIST/;
367 open(WPS
, "<$wpslist");
378 # prefix $rbdir with / if needed (needed for the theme.cfg)
379 unless ($rbdir =~ m/^\/.*/) {
380 $rbdir = "/" . $rbdir;
383 if($l =~ /^ *<theme>/i) {
384 # undef is a unary operator (!)
405 undef $remotestatusbar;
408 undef $lineselectstart;
409 undef $lineselectend;
412 undef $remoteiconset;
414 undef $remoteviewericon;
415 undef $lineselecttextcolor;
416 undef $filetylecolor;
418 undef $remotelistviewport;
420 elsif($l =~ /^Name: *(.*)/i) {
423 elsif($l =~ /^Authors: *(.*)/i) {
426 elsif ($l =~ /^WPS: *(yes|no)/i) {
429 elsif ($l =~ /^RWPS: *(yes|no)/i) {
432 elsif ($l =~ /^SBS: *(yes|no)/i) {
435 elsif ($l =~ /^RSBS: *(yes|no)/i) {
438 elsif ($l =~ /^FMS: *(yes|no)/i) {
441 elsif ($l =~ /^RFMS: *(yes|no)/i) {
444 elsif($l =~ /^ *<main>/i) {
445 # parse main unit settings
448 if ($l =~ /^ *<\/main
>/i
) {
451 elsif($_ = check_res
($l, "wps")) {
454 elsif($_ = check_res
($l, "sbs")) {
457 elsif($_ = check_res
($l, "fms")) {
460 elsif($_ = check_res
($l, "Font")) {
463 elsif($_ = check_res
($l, "Statusbar")) {
466 elsif($_ = check_res
($l, "Backdrop")) {
469 elsif($l =~ /^Foreground Color: *(.*)/i) {
472 elsif($l =~ /^Background Color: *(.*)/i) {
475 elsif($l =~ /^line selector start color: *(.*)/i) {
476 $lineselectstart = $1;
478 elsif($l =~ /^line selector end color: *(.*)/i) {
481 elsif($_ = check_res
($l, "selector type")) {
484 elsif($_ = check_res
($l, "iconset")) {
487 elsif($_ = check_res
($l, "viewers iconset")) {
490 elsif($l =~ /^line selector text color: *(.*)/i) {
491 $lineselecttextcolor = $1;
493 elsif($l =~ /^filetype colours: *(.*)/i) {
496 elsif($_ = check_res
($l, "ui viewport")) {
501 elsif($l =~ /^ *<remote>/i) {
503 # parse remote settings
505 if ($l =~ /^ *<\/remote
>/i
) {
508 elsif(!$has_remote) {
509 next; # dont parse <remote> section
511 elsif($_ = check_res
($l, "rwps", 1)) {
514 elsif($_ = check_res
($l, "rsbs", 1)) {
517 elsif($_ = check_res
($l, "rfms", 1)) {
520 elsif($_ = check_res
($l, "Font", 1)) {
523 elsif($_ = check_res
($l, "iconset", 1)) {
526 elsif($_ = check_res
($l, "viewers iconset", 1)) {
527 $remoteviewericon = $_;
529 elsif($_ = check_res
($l, "statusbar", 1)) {
530 $remotestatusbar = $_;
532 elsif($_ = check_res
($l, "ui viewport", 1)) {
533 $remotelistviewport = $_;
537 elsif($l =~ /^ *<\/theme
>/i
) {
538 # for each wps,sbs,fms (+ remote variants) check if <theme>[.<model>].wps
539 # exists if no filename was specified in WPSLIST
542 if ($has_wps eq "yes" && !$wps) {
543 $wps = check_skinfile
("wps");
544 } elsif ($has_wps eq "no") {
548 if ($has_sbs eq "yes" && !$sbs) {
549 $sbs = check_skinfile
("sbs");
550 } elsif ($has_sbs eq "no") {
554 if ($has_fms eq "yes" && !$fms) {
555 $fms = check_skinfile
("fms");
556 } elsif ($has_fms eq "no") {
560 # now check for remote skin files (use main screen's extension)
562 if ($has_rwps eq "yes" && !$rwps) {
563 $rwps = check_skinfile
("wps");
564 } elsif ($has_rwps eq "no") {
568 if ($has_rsbs eq "yes" && !$rsbs) {
569 $rsbs = check_skinfile
("sbs");
570 } elsif ($has_rsbs eq "no") {
574 if ($has_rfms eq "yes" && !$rfms) {
575 $rfms = check_skinfile
("fms");
576 } elsif ($has_rfms eq "no") {
580 #print "LCD: $wps wants $width x $height\n";
583 # The target model has an LCD that is suitable for this
586 #print "Size requirement is fine!\n";
587 mkdirs
() if (-e
"$wpsdir/$theme");
588 # Do the copying before building the .cfg - buildcfg()
589 # mangles some filenames
590 if (defined($backdrop) && $backdrop ne "-") {
592 $backdrop = "$rbdir/" . normalize
($backdrop);
594 foreach my $i ($iconset, $viewericon, $remoteiconset, $remoteviewericon) {
595 if (defined($i) && $i ne "-") {
600 foreach my $i ($font, $remotefont) {
601 if (defined($i) && $i ne "-") {
602 copythemefont
($font);
603 $i = "$rbdir/fonts/$font";
610 #print "Unknown line: $l!\n";