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;
58 my ($main_height, $main_width, $main_depth);
59 my ($remote_height, $remote_width, $remote_depth);
64 print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
65 "Run this script in the root of the target build, and it will put all the\n",
66 "stuff in $rbdir/wps/\n";
74 open(GCC
, ">gcctemp");
76 # Get the remote LCD screen size
79 #ifdef HAVE_REMOTE_LCD
80 Height: LCD_REMOTE_HEIGHT
81 Width: LCD_REMOTE_WIDTH
82 Depth: LCD_REMOTE_DEPTH
98 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
102 open(GETSIZE
, "$c|");
104 my ($height, $width, $depth);
106 if($_ =~ /^Height: (\d*)/) {
109 elsif($_ =~ /^Width: (\d*)/) {
112 elsif($_ =~ /^Depth: (\d*)/) {
115 if($height && $width && $depth) {
122 return ($height, $width, $depth);
128 $wpsdir =~ s/\.(r|)wps//;
129 mkdir "$rbdir/wps", 0777;
130 mkdir "$rbdir/themes", 0777;
132 if( -d
"$rbdir/wps/$wpsdir") {
133 #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
137 mkdir "$rbdir/wps/$wpsdir", 0777;
143 #copy the backdrop file into the build dir
144 if ($backdrop ne '') {
146 $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
147 my $cmd = "cp $ROOT/$backdrop $rbdir/$dst";
154 #copy the font specified by the theme
157 $o =~ s/\.fnt/\.bdf/;
158 mkdir "$rbdir/fonts";
159 my $cmd ="$ROOT/tools/convbdf -f -o \"$rbdir/fonts/$font\" \"$ROOT/fonts/$o\" ";
165 #copy the icon specified by the theme
167 if ($iconset ne '') {
168 $iconset =~ s/.rockbox/$rbdir/;
169 $iconset =~ /\/(.*icons\
/(.*))/i;
170 `cp $ROOT/icons/$2 $1`;
174 sub copythemeviewericon
176 #copy the viewer icon specified by the theme
178 if ($viewericon ne '') {
179 $viewericon =~ s/.rockbox/$rbdir/;
180 $viewericon =~ /\/(.*icons\
/(.*))/i;
181 `cp $ROOT/icons/$2 $1`;
187 # we assume that we copy the WPS files from the same dir the WPSLIST
193 if($wpslist =~ /(.*)WPSLIST/) {
195 # system("cp $dir/$wps .rockbox/wps/");
196 #print "$req_t_wps $req_g_wps\n";
198 if (-e
"$dir/$req_t_wps" ) {
199 system("cp $dir/$req_t_wps $rbdir/wps/$wps");
201 } elsif (-e
"$dir/$req_g_wps") {
202 system("cp $dir/$req_g_wps $rbdir/wps/$wps");
204 open(WPSFILE
, "$dir/$req_g_wps");
206 $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
210 if ($#filelist >= 0) {
211 if (-e
"$dir/$wps_prefix/$req_g") {
212 foreach $file (@filelist) {
213 system("cp $dir/$wps_prefix/$req_g/$file $rbdir/wps/$wps_prefix/");
216 elsif (-e
"$dir/$wps_prefix") {
217 foreach $file (@filelist) {
218 system("cp $dir/$wps_prefix/$file $rbdir/wps/$wps_prefix/");
222 print STDERR
"beep, no dir to copy WPS from!\n";
227 print STDERR
"Skipping $wps - no matching resolution.\n";
230 print STDERR
"No source directory!\n";
238 $cfg =~ s/\.(r|)wps/.cfg/;
242 \# $cfg generated by wpsbuild.pl
243 \# $wps is made by $author
245 wps: /$rbdir/wps/$wps
249 push @out, "font: /$rbdir/fonts/$font\n";
251 if($fgcolor && $main_depth > 2) {
252 push @out, "foreground color: $fgcolor\n";
254 if($bgcolor && $main_depth > 2) {
255 push @out, "background color: $bgcolor\n";
258 if($rwps && $has_remote ) {
259 push @out, "remote statusbar: $statusbar\n";
261 push @out, "statusbar: $statusbar\n";
263 if(defined($backdrop)) {
264 if ($backdrop eq '') {
265 push @out, "backdrop:\n";
267 # clip resolution from filename
268 $backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
269 push @out, "backdrop: /$rbdir/$backdrop\n";
272 if($lineselectstart && $main_depth > 2) {
273 push @out, "line selector start color: $lineselectstart\n";
275 if($lineselectend && $main_depth > 2) {
276 push @out, "line selector end color: $lineselectend\n";
279 push @out, "selector type: $selecttype\n";
281 if(defined($iconset)) {
282 push @out, "iconset: $iconset\n";
284 if(defined($viewericon)) {
285 push @out, "viewers iconset: $viewericon\n";
287 if($lineselecttextcolor && $main_depth > 2 ) {
288 push @out, "line selector text color: $lineselecttextcolor\n";
290 if($filetylecolor && $main_depth > 2) {
291 push @out, "filetype colours: $filetylecolor\n";
293 if($rwps && $has_remote ) {
294 push @out, "rwps: /$rbdir/wps/$rwps\n";
296 if(-f
"$rbdir/wps/$cfg") {
297 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
300 open(CFG
, ">$rbdir/themes/$cfg");
306 # Get the LCD sizes first
307 ($main_height, $main_width, $main_depth) = getlcdsizes
();
308 ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
310 #print "LCD: ${main_width}x${main_height}x${main_depth}\n";
311 $has_remote = 1 if ($remote_height && $remote_width && $remote_depth);
316 open(WPS
, "<$wpslist");
326 if($l =~ /^ *<(r|)wps>/i) {
329 # undef is a unary operator (!)
343 undef $lineselectstart;
344 undef $lineselectend;
348 undef $lineselecttextcolor;
349 undef $filetylecolor;
354 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
355 # Get the required width and height
356 my ($rheight, $rwidth, $rdepth);
358 ($rheight, $rwidth, $rdepth) =
359 ($remote_height, $remote_width, $remote_depth);
362 ($rheight, $rwidth, $rdepth) =
363 ($main_height, $main_width, $main_depth);
366 if(!$rheight || !$rwidth) {
367 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
368 #$isrwps?"remote ":"";
372 $wpslist =~ /(.*)WPSLIST/;
374 # If this WPS installable on this platform, one of the following
375 # two files will be present
376 foreach my $d (@depthlist) {
377 next if ($d > $rdepth);
379 $req_g = $rwidth . "x" . $rheight . "x" . $d;
381 # check for model specific wps
382 $req_g_wps = $wps_prefix . "." . $req_g . "." . $modelname . ".wps";
383 last if (-e
"$wpsdir/$req_g_wps");
385 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
386 last if (-e
"$wpsdir/$req_g_wps");
389 $req_g = $req_g . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
391 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
392 last if (-e
"$wpsdir/$req_g_wps");
395 $req_t_wps = $wps_prefix . ".txt" . ".wps";
397 #print "LCD: $wps wants $width x $height\n";
398 #print "LCD: is $rwidth x $rheight\n";
400 #print "gwps: $wpsdir/$req_g_wps" . "\n";
401 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
403 # The target model has an LCD that is suitable for this
406 #print "Size requirement is fine!\n";
407 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
408 # Do the copying before building the .cfg - buildcfg()
409 # mangles some filenames
417 copythemeviewericon
();
423 # We only make .cfg files for <wps> sections:
429 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
430 #print "Skip $wps due to size restraints\n";
434 elsif($l =~ /^Name: *(.*)/i) {
435 # Note that in the case this is within <rwps>, $wps will contain the
436 # name of the rwps. Use $isrwps to figure out what type it is.
437 $wps = $wps_prefix = $1;
438 $wps_prefix =~ s/\.(r|)wps//;
439 #print $wps_prefix . "\n";
441 elsif($l =~ /^RWPS: *(.*)/i) {
444 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
447 elsif($l =~ /^Author: *(.*)/i) {
450 elsif($l =~ /^Width: *(.*)/i) {
453 elsif($l =~ /^Width\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
456 elsif($l =~ /^Height: *(.*)/i) {
459 elsif($l =~ /^Height\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
462 elsif($l =~ /^Font: *(.*)/i) {
465 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
468 elsif($l =~ /^Foreground Color: *(.*)/i) {
471 elsif($l =~ /^Background Color: *(.*)/i) {
474 elsif($l =~ /^Statusbar: *(.*)/i) {
477 elsif($l =~ /^Statusbar\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
480 elsif($l =~ /^Backdrop: *(.*)/i) {
483 elsif($l =~ /^Backdrop\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
486 elsif($l =~ /^line selector start color: *(.*)/i) {
487 $lineselectstart = $1;
489 elsif($l =~ /^line selector end color: *(.*)/i) {
492 elsif($l =~ /^selector type: *(.*)/i) {
495 elsif($l =~ /^selector type\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
498 elsif($l =~ /^iconset: *(.*)/i) {
501 elsif($l =~ /^iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
504 elsif($l =~ /^viewers iconset: *(.*)/i) {
507 elsif($l =~ /^viewers iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
510 elsif($l =~ /^line selector text color: *(.*)/i) {
511 $lineselecttextcolor = $1;
513 elsif($l =~ /^filetype colours: *(.*)/i) {
517 #print "Unknown line: $l!\n";