3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
12 use Getopt
::Long
qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
21 GetOptions
( 'r|root=s' => \
$ROOT,
22 'v|verbose' => \
$verbose,
23 'rbdir=s' => \
$rbdir, # If we want to put in a different directory
26 ($wpslist, $target) = @ARGV;
28 my $firmdir="$ROOT/firmware";
30 my @depthlist = ( 16, 8, 4, 2, 1 );
32 # These parameters are filled in as we parse wpslist
52 my $lineselecttextcolor;
56 my ($main_height, $main_width, $main_depth);
57 my ($remote_height, $remote_width, $remote_depth);
62 print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
63 "Run this script in the root of the target build, and it will put all the\n",
64 "stuff in $rbdir/wps/\n";
72 open(GCC
, ">gcctemp");
74 # Get the remote LCD screen size
77 #ifdef HAVE_REMOTE_LCD
78 Height: LCD_REMOTE_HEIGHT
79 Width: LCD_REMOTE_WIDTH
80 Depth: LCD_REMOTE_DEPTH
96 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
100 open(GETSIZE
, "$c|");
102 my ($height, $width, $depth);
104 if($_ =~ /^Height: (\d*)/) {
107 elsif($_ =~ /^Width: (\d*)/) {
110 elsif($_ =~ /^Depth: (\d*)/) {
113 if($height && $width && $depth) {
120 return ($height, $width, $depth);
126 $wpsdir =~ s/\.(r|)wps//;
127 mkdir "$rbdir/wps", 0777;
128 mkdir "$rbdir/themes", 0777;
130 if( -d
"$rbdir/wps/$wpsdir") {
131 #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
135 mkdir "$rbdir/wps/$wpsdir", 0777;
141 #copy the backdrop file into the build dir
142 if ($backdrop ne '') {
144 $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
145 my $cmd = "cp $ROOT/$backdrop $rbdir/$dst";
152 #copy the font specified by the theme
155 $o =~ s/\.fnt/\.bdf/;
156 mkdir "$rbdir/fonts";
157 my $cmd ="$ROOT/tools/convbdf -f -o \"$rbdir/fonts/$font\" \"$ROOT/fonts/$o\" ";
163 #copy the icon specified by the theme
165 if ($iconset ne '') {
166 $iconset =~ s/.rockbox/$rbdir/;
167 $iconset =~ /\/(.*icons\
/(.*))/i;
168 `cp $ROOT/icons/$2 $1`;
172 sub copythemeviewericon
174 #copy the viewer icon specified by the theme
176 if ($viewericon ne '') {
177 $viewericon =~ s/.rockbox/$rbdir/;
178 $viewericon =~ /\/(.*icons\
/(.*))/i;
179 `cp $ROOT/icons/$2 $1`;
185 # we assume that we copy the WPS files from the same dir the WPSLIST
191 if($wpslist =~ /(.*)WPSLIST/) {
193 # system("cp $dir/$wps .rockbox/wps/");
194 # print "$req_t_wps $req_g_wps\n";
196 if (-e
"$dir/$req_t_wps" ) {
197 system("cp $dir/$req_t_wps $rbdir/wps/$wps");
199 } elsif (-e
"$dir/$req_g_wps") {
200 system("cp $dir/$req_g_wps $rbdir/wps/$wps");
202 open(WPSFILE
, "$dir/$req_g_wps");
204 $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
208 if ($#filelist >= 0) {
209 if (-e
"$dir/$wps_prefix/$req_g") {
210 foreach $file (@filelist) {
211 system("cp $dir/$wps_prefix/$req_g/$file $rbdir/wps/$wps_prefix/");
214 elsif (-e
"$dir/$wps_prefix") {
215 foreach $file (@filelist) {
216 system("cp $dir/$wps_prefix/$file $rbdir/wps/$wps_prefix/");
220 print STDERR
"beep, no dir to copy WPS from!\n";
225 print STDERR
"Skipping $wps - no matching resolution.\n";
228 print STDERR
"No source directory!\n";
236 $cfg =~ s/\.(r|)wps/.cfg/;
240 \# $cfg generated by wpsbuild.pl
241 \# $wps is made by $author
243 wps: /$rbdir/wps/$wps
247 push @out, "font: /$rbdir/fonts/$font\n";
249 if($fgcolor && $main_depth > 2) {
250 push @out, "foreground color: $fgcolor\n";
252 if($bgcolor && $main_depth > 2) {
253 push @out, "background color: $bgcolor\n";
256 push @out, "statusbar: $statusbar\n";
258 if(defined($backdrop)) {
259 if ($backdrop eq '') {
260 push @out, "backdrop:\n";
262 # clip resolution from filename
263 $backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
264 push @out, "backdrop: /$rbdir/$backdrop\n";
267 if($lineselectstart && $main_depth > 2) {
268 push @out, "line selector start color: $lineselectstart\n";
270 if($lineselectend && $main_depth > 2) {
271 push @out, "line selector end color: $lineselectend\n";
274 push @out, "selector type: $selecttype\n";
276 if(defined($iconset)) {
277 push @out, "iconset: $iconset\n";
279 if(defined($viewericon)) {
280 push @out, "viewers iconset: $viewericon\n";
282 if($lineselecttextcolor && $main_depth > 2 ) {
283 push @out, "line selector text color: $lineselecttextcolor\n";
285 if($filetylecolor && $main_depth > 2) {
286 push @out, "filetype colours: $filetylecolor\n";
288 if($rwps && $has_remote ) {
289 push @out, "rwps: /$rbdir/wps/$rwps\n";
291 if(-f
"$rbdir/wps/$cfg") {
292 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
295 open(CFG
, ">$rbdir/themes/$cfg");
301 # Get the LCD sizes first
302 ($main_height, $main_width, $main_depth) = getlcdsizes
();
303 ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
305 #print "LCD: ${main_height}x${main_width}x${main_depth}\n";
306 $has_remote = 1 if ($remote_height && $remote_width && $remote_depth);
311 open(WPS
, "<$wpslist");
321 if($l =~ /^ *<(r|)wps>/i) {
324 # undef is a unary operator (!)
338 undef $lineselectstart;
339 undef $lineselectend;
343 undef $lineselecttextcolor;
344 undef $filetylecolor;
349 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
350 # Get the required width and height
351 my ($rheight, $rwidth, $rdepth);
353 ($rheight, $rwidth, $rdepth) =
354 ($remote_height, $remote_width, $remote_depth);
357 ($rheight, $rwidth, $rdepth) =
358 ($main_height, $main_width, $main_depth);
361 if(!$rheight || !$rwidth) {
362 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
363 #$isrwps?"remote ":"";
367 $wpslist =~ /(.*)WPSLIST/;
369 # If this WPS installable on this platform, one of the following
370 # two files will be present
371 foreach my $d (@depthlist) {
372 next if ($d > $rdepth);
374 $req_g = $rwidth . "x" . $rheight . "x" . $d;
376 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
377 last if (-e
"$wpsdir/$req_g_wps");
380 $req_g = $req_g . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
382 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
383 last if (-e
"$wpsdir/$req_g_wps");
386 $req_t_wps = $wps_prefix . ".txt" . ".wps";
388 #print "LCD: $wps wants $height x $width\n";
389 #print "LCD: is $rheight x $rwidth\n";
391 #print "gwps: $wpsdir/$req_g_wps" . "\n";
392 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
394 # The target model has an LCD that is suitable for this
397 #print "Size requirement is fine!\n";
398 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
400 # We only make .cfg files for <wps> sections:
406 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
407 #print "Skip $wps due to size restraints\n";
411 elsif($l =~ /^Name: *(.*)/i) {
412 # Note that in the case this is within <rwps>, $wps will contain the
413 # name of the rwps. Use $isrwps to figure out what type it is.
414 $wps = $wps_prefix = $1;
415 $wps_prefix =~ s/\.(r|)wps//;
416 # print $wps_prefix . "\n";
418 elsif($l =~ /^RWPS: *(.*)/i) {
421 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
424 elsif($l =~ /^Author: *(.*)/i) {
427 elsif($l =~ /^Width: *(.*)/i) {
430 elsif($l =~ /^Width\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
433 elsif($l =~ /^Height: *(.*)/i) {
436 elsif($l =~ /^Height\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
439 elsif($l =~ /^Font: *(.*)/i) {
442 elsif($l =~ /^Foreground Color: *(.*)/i) {
445 elsif($l =~ /^Background Color: *(.*)/i) {
448 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
452 elsif($l =~ /^Statusbar: *(.*)/i) {
455 elsif($l =~ /^Statusbar\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
458 elsif($l =~ /^Backdrop: *(.*)/i) {
462 elsif($l =~ /^Backdrop\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
466 elsif($l =~ /^line selector start color: *(.*)/i) {
467 $lineselectstart = $1;
469 elsif($l =~ /^line selector end color: *(.*)/i) {
472 elsif($l =~ /^selector type: *(.*)/i) {
475 elsif($l =~ /^selector type\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
478 elsif($l =~ /^iconset: *(.*)/i) {
482 elsif($l =~ /^iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
486 elsif($l =~ /^viewers iconset: *(.*)/i) {
488 copythemeviewericon
();
490 elsif($l =~ /^viewers iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
492 copythemeviewericon
();
494 elsif($l =~ /^line selector text color: *(.*)/i) {
495 $lineselecttextcolor = $1;
497 elsif($l =~ /^filetype colours: *(.*)/i) {
501 #print "Unknown line: $l!\n";