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 push @out, "statusbar: $statusbar\n";
260 if(defined($backdrop)) {
261 if ($backdrop eq '') {
262 push @out, "backdrop:\n";
264 # clip resolution from filename
265 $backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
266 push @out, "backdrop: /$rbdir/$backdrop\n";
269 if($lineselectstart && $main_depth > 2) {
270 push @out, "line selector start color: $lineselectstart\n";
272 if($lineselectend && $main_depth > 2) {
273 push @out, "line selector end color: $lineselectend\n";
276 push @out, "selector type: $selecttype\n";
278 if(defined($iconset)) {
279 push @out, "iconset: $iconset\n";
281 if(defined($viewericon)) {
282 push @out, "viewers iconset: $viewericon\n";
284 if($lineselecttextcolor && $main_depth > 2 ) {
285 push @out, "line selector text color: $lineselecttextcolor\n";
287 if($filetylecolor && $main_depth > 2) {
288 push @out, "filetype colours: $filetylecolor\n";
290 if($rwps && $has_remote ) {
291 push @out, "rwps: /$rbdir/wps/$rwps\n";
293 if(-f
"$rbdir/wps/$cfg") {
294 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
297 open(CFG
, ">$rbdir/themes/$cfg");
303 # Get the LCD sizes first
304 ($main_height, $main_width, $main_depth) = getlcdsizes
();
305 ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
307 #print "LCD: ${main_width}x${main_height}x${main_depth}\n";
308 $has_remote = 1 if ($remote_height && $remote_width && $remote_depth);
313 open(WPS
, "<$wpslist");
323 if($l =~ /^ *<(r|)wps>/i) {
326 # undef is a unary operator (!)
340 undef $lineselectstart;
341 undef $lineselectend;
345 undef $lineselecttextcolor;
346 undef $filetylecolor;
351 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
352 # Get the required width and height
353 my ($rheight, $rwidth, $rdepth);
355 ($rheight, $rwidth, $rdepth) =
356 ($remote_height, $remote_width, $remote_depth);
359 ($rheight, $rwidth, $rdepth) =
360 ($main_height, $main_width, $main_depth);
363 if(!$rheight || !$rwidth) {
364 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
365 #$isrwps?"remote ":"";
369 $wpslist =~ /(.*)WPSLIST/;
371 # If this WPS installable on this platform, one of the following
372 # two files will be present
373 foreach my $d (@depthlist) {
374 next if ($d > $rdepth);
376 $req_g = $rwidth . "x" . $rheight . "x" . $d;
378 # check for model specific wps
379 $req_g_wps = $wps_prefix . "." . $req_g . "." . $modelname . ".wps";
380 last if (-e
"$wpsdir/$req_g_wps");
382 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
383 last if (-e
"$wpsdir/$req_g_wps");
386 $req_g = $req_g . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
388 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
389 last if (-e
"$wpsdir/$req_g_wps");
392 $req_t_wps = $wps_prefix . ".txt" . ".wps";
394 #print "LCD: $wps wants $width x $height\n";
395 #print "LCD: is $rwidth x $rheight\n";
397 #print "gwps: $wpsdir/$req_g_wps" . "\n";
398 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
400 # The target model has an LCD that is suitable for this
403 #print "Size requirement is fine!\n";
404 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
405 # Do the copying before building the .cfg - buildcfg()
406 # mangles some filenames
414 copythemeviewericon
();
420 # We only make .cfg files for <wps> sections:
426 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
427 #print "Skip $wps due to size restraints\n";
431 elsif($l =~ /^Name: *(.*)/i) {
432 # Note that in the case this is within <rwps>, $wps will contain the
433 # name of the rwps. Use $isrwps to figure out what type it is.
434 $wps = $wps_prefix = $1;
435 $wps_prefix =~ s/\.(r|)wps//;
436 #print $wps_prefix . "\n";
438 elsif($l =~ /^RWPS: *(.*)/i) {
441 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
444 elsif($l =~ /^Author: *(.*)/i) {
447 elsif($l =~ /^Width: *(.*)/i) {
450 elsif($l =~ /^Width\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
453 elsif($l =~ /^Height: *(.*)/i) {
456 elsif($l =~ /^Height\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
459 elsif($l =~ /^Font: *(.*)/i) {
462 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
465 elsif($l =~ /^Foreground Color: *(.*)/i) {
468 elsif($l =~ /^Background Color: *(.*)/i) {
471 elsif($l =~ /^Statusbar: *(.*)/i) {
474 elsif($l =~ /^Statusbar\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
477 elsif($l =~ /^Backdrop: *(.*)/i) {
480 elsif($l =~ /^Backdrop\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
483 elsif($l =~ /^line selector start color: *(.*)/i) {
484 $lineselectstart = $1;
486 elsif($l =~ /^line selector end color: *(.*)/i) {
489 elsif($l =~ /^selector type: *(.*)/i) {
492 elsif($l =~ /^selector type\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
495 elsif($l =~ /^iconset: *(.*)/i) {
498 elsif($l =~ /^iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
501 elsif($l =~ /^viewers iconset: *(.*)/i) {
504 elsif($l =~ /^viewers iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
507 elsif($l =~ /^line selector text color: *(.*)/i) {
508 $lineselecttextcolor = $1;
510 elsif($l =~ /^filetype colours: *(.*)/i) {
514 #print "Unknown line: $l!\n";