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
54 my $lineselecttextcolor;
57 my $remotelistviewport;
60 my ($main_height, $main_width, $main_depth);
61 my ($remote_height, $remote_width, $remote_depth);
66 print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
67 "Run this script in the root of the target build, and it will put all the\n",
68 "stuff in $rbdir/wps/\n";
76 open(GCC
, ">gcctemp");
78 # Get the remote LCD screen size
81 #ifdef HAVE_REMOTE_LCD
82 Height: LCD_REMOTE_HEIGHT
83 Width: LCD_REMOTE_WIDTH
84 Depth: LCD_REMOTE_DEPTH
100 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
104 open(GETSIZE
, "$c|");
106 my ($height, $width, $depth);
108 if($_ =~ /^Height: (\d*)/) {
111 elsif($_ =~ /^Width: (\d*)/) {
114 elsif($_ =~ /^Depth: (\d*)/) {
117 if($height && $width && $depth) {
124 return ($height, $width, $depth);
130 $wpsdir =~ s/\.(r|)wps//;
131 mkdir "$rbdir/wps", 0777;
132 mkdir "$rbdir/themes", 0777;
134 if( -d
"$rbdir/wps/$wpsdir") {
135 #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
139 mkdir "$rbdir/wps/$wpsdir", 0777;
145 #copy the backdrop file into the build dir
146 if ($backdrop ne '') {
148 $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
149 my $cmd = "cp $ROOT/$backdrop $rbdir/$dst";
156 #copy the font specified by the theme
159 $o =~ s/\.fnt/\.bdf/;
160 mkdir "$rbdir/fonts";
161 my $cmd ="$ROOT/tools/convbdf -f -o \"$rbdir/fonts/$font\" \"$ROOT/fonts/$o\" ";
167 #copy the icon specified by the theme
169 if ($iconset ne '') {
170 $iconset =~ s/.rockbox/$rbdir/;
171 $iconset =~ /\/(.*icons\
/(.*))/i;
172 `cp $ROOT/icons/$2 $1`;
176 sub copythemeviewericon
178 #copy the viewer icon specified by the theme
180 if ($viewericon ne '') {
181 $viewericon =~ s/.rockbox/$rbdir/;
182 $viewericon =~ /\/(.*icons\
/(.*))/i;
183 `cp $ROOT/icons/$2 $1`;
189 # we assume that we copy the WPS files from the same dir the WPSLIST
195 if($wpslist =~ /(.*)WPSLIST/) {
197 # system("cp $dir/$wps .rockbox/wps/");
198 #print "$req_t_wps $req_g_wps\n";
200 if (-e
"$dir/$req_t_wps" ) {
201 system("cp $dir/$req_t_wps $rbdir/wps/$wps");
203 } elsif (-e
"$dir/$req_g_wps") {
204 system("cp $dir/$req_g_wps $rbdir/wps/$wps");
206 open(WPSFILE
, "$dir/$req_g_wps");
208 $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
212 if ($#filelist >= 0) {
213 if (-e
"$dir/$wps_prefix/$req_g") {
214 foreach $file (@filelist) {
215 system("cp $dir/$wps_prefix/$req_g/$file $rbdir/wps/$wps_prefix/");
218 elsif (-e
"$dir/$wps_prefix") {
219 foreach $file (@filelist) {
220 system("cp $dir/$wps_prefix/$file $rbdir/wps/$wps_prefix/");
224 print STDERR
"beep, no dir to copy WPS from!\n";
229 print STDERR
"Skipping $wps - no matching resolution.\n";
232 print STDERR
"No source directory!\n";
240 $cfg =~ s/\.(r|)wps/.cfg/;
244 \# $cfg generated by wpsbuild.pl
245 \# $wps is made by $author
247 wps: /$rbdir/wps/$wps
251 push @out, "font: /$rbdir/fonts/$font\n";
253 if($fgcolor && $main_depth > 2) {
254 push @out, "foreground color: $fgcolor\n";
256 if($bgcolor && $main_depth > 2) {
257 push @out, "background color: $bgcolor\n";
260 if($rwps && $has_remote ) {
261 push @out, "remote statusbar: $statusbar\n";
263 push @out, "statusbar: $statusbar\n";
265 if(defined($backdrop)) {
266 if ($backdrop eq '') {
267 push @out, "backdrop:\n";
269 # clip resolution from filename
270 $backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
271 push @out, "backdrop: /$rbdir/$backdrop\n";
274 if($lineselectstart && $main_depth > 2) {
275 push @out, "line selector start color: $lineselectstart\n";
277 if($lineselectend && $main_depth > 2) {
278 push @out, "line selector end color: $lineselectend\n";
281 push @out, "selector type: $selecttype\n";
283 if(defined($iconset)) {
284 push @out, "iconset: $iconset\n";
286 if(defined($viewericon)) {
287 push @out, "viewers iconset: $viewericon\n";
289 if($lineselecttextcolor && $main_depth > 2 ) {
290 push @out, "line selector text color: $lineselecttextcolor\n";
292 if($filetylecolor && $main_depth > 2) {
293 push @out, "filetype colours: $filetylecolor\n";
295 if($rwps && $has_remote ) {
296 push @out, "rwps: /$rbdir/wps/$rwps\n";
298 if(defined($listviewport)) {
299 push @out, "ui viewport: $listviewport\n";
301 if(defined($remotelistviewport) && $has_remote) {
302 push @out, "remote ui viewport: $listviewport\n";
304 if(-f
"$rbdir/wps/$cfg") {
305 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
308 open(CFG
, ">$rbdir/themes/$cfg");
314 # Get the LCD sizes first
315 ($main_height, $main_width, $main_depth) = getlcdsizes
();
316 ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
318 #print "LCD: ${main_width}x${main_height}x${main_depth}\n";
319 $has_remote = 1 if ($remote_height && $remote_width && $remote_depth);
324 open(WPS
, "<$wpslist");
334 if($l =~ /^ *<(r|)wps>/i) {
337 # undef is a unary operator (!)
351 undef $lineselectstart;
352 undef $lineselectend;
356 undef $lineselecttextcolor;
357 undef $filetylecolor;
359 undef $remotelistviewport;
364 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
365 # Get the required width and height
366 my ($rheight, $rwidth, $rdepth);
368 ($rheight, $rwidth, $rdepth) =
369 ($remote_height, $remote_width, $remote_depth);
372 ($rheight, $rwidth, $rdepth) =
373 ($main_height, $main_width, $main_depth);
376 if(!$rheight || !$rwidth) {
377 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
378 #$isrwps?"remote ":"";
382 $wpslist =~ /(.*)WPSLIST/;
384 # If this WPS installable on this platform, one of the following
385 # two files will be present
386 foreach my $d (@depthlist) {
387 next if ($d > $rdepth);
389 $req_g = $rwidth . "x" . $rheight . "x" . $d;
391 # check for model specific wps
392 $req_g_wps = $wps_prefix . "." . $req_g . "." . $modelname . ".wps";
393 last if (-e
"$wpsdir/$req_g_wps");
395 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
396 last if (-e
"$wpsdir/$req_g_wps");
399 $req_g = $req_g . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
401 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
402 last if (-e
"$wpsdir/$req_g_wps");
405 $req_t_wps = $wps_prefix . ".txt" . ".wps";
407 #print "LCD: $wps wants $width x $height\n";
408 #print "LCD: is $rwidth x $rheight\n";
410 #print "gwps: $wpsdir/$req_g_wps" . "\n";
411 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
413 # The target model has an LCD that is suitable for this
416 #print "Size requirement is fine!\n";
417 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
418 # Do the copying before building the .cfg - buildcfg()
419 # mangles some filenames
427 copythemeviewericon
();
433 # We only make .cfg files for <wps> sections:
439 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
440 #print "Skip $wps due to size restraints\n";
444 elsif($l =~ /^Name: *(.*)/i) {
445 # Note that in the case this is within <rwps>, $wps will contain the
446 # name of the rwps. Use $isrwps to figure out what type it is.
447 $wps = $wps_prefix = $1;
448 $wps_prefix =~ s/\.(r|)wps//;
449 #print $wps_prefix . "\n";
451 elsif($l =~ /^RWPS: *(.*)/i) {
454 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
457 elsif($l =~ /^Author: *(.*)/i) {
460 elsif($l =~ /^Width: *(.*)/i) {
463 elsif($l =~ /^Width\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
466 elsif($l =~ /^Height: *(.*)/i) {
469 elsif($l =~ /^Height\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
472 elsif($l =~ /^Font: *(.*)/i) {
475 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
478 elsif($l =~ /^Foreground Color: *(.*)/i) {
481 elsif($l =~ /^Background Color: *(.*)/i) {
484 elsif($l =~ /^Statusbar: *(.*)/i) {
487 elsif($l =~ /^Statusbar\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
490 elsif($l =~ /^Backdrop: *(.*)/i) {
493 elsif($l =~ /^Backdrop\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
496 elsif($l =~ /^line selector start color: *(.*)/i) {
497 $lineselectstart = $1;
499 elsif($l =~ /^line selector end color: *(.*)/i) {
502 elsif($l =~ /^selector type: *(.*)/i) {
505 elsif($l =~ /^selector type\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
508 elsif($l =~ /^iconset: *(.*)/i) {
511 elsif($l =~ /^iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
514 elsif($l =~ /^viewers iconset: *(.*)/i) {
517 elsif($l =~ /^viewers iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
520 elsif($l =~ /^line selector text color: *(.*)/i) {
521 $lineselecttextcolor = $1;
523 elsif($l =~ /^filetype colours: *(.*)/i) {
526 elsif($l =~ /^ui viewport: *(.*)/i) {
529 elsif($l =~ /^remote ui viewport: *(.*)/i) {
530 $remotelistviewport = $1;
533 #print "Unknown line: $l!\n";