3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
13 if($ARGV[0] eq "-r") {
20 if($ARGV[0] eq "-v") {
25 my $firmdir="$ROOT/firmware";
29 my $target = $ARGV[1];
31 my @depthlist = ( 16, 8, 4, 2, 1 );
34 print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
35 "Run this script in the root of the target build, and it will put all the\n",
36 "stuff in .rockbox/wps/\n";
44 open(GCC
, ">gcctemp");
46 # Get the remote LCD screen size
49 #ifdef HAVE_REMOTE_LCD
50 Height: LCD_REMOTE_HEIGHT
51 Width: LCD_REMOTE_WIDTH
52 Depth: LCD_REMOTE_DEPTH
68 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
76 if($_ =~ /^Height: (\d*)/) {
79 elsif($_ =~ /^Width: (\d*)/) {
82 elsif($_ =~ /^Depth: (\d*)/) {
85 if($height && $width && $depth) {
92 return ($height, $width, $depth);
98 $wpsdir =~ s/\.(r|)wps//;
99 mkdir ".rockbox/wps", 0777;
100 mkdir ".rockbox/themes", 0777;
102 if( -d
".rockbox/wps/$wpsdir") {
103 #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
107 mkdir ".rockbox/wps/$wpsdir", 0777;
113 #copy the backdrop file into the build dir
115 $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
116 $cmd = "cp $ROOT/$backdrop .rockbox/$dst";
122 #copy the font specified by the theme
125 $o =~ s/\.fnt/\.bdf/;
126 `mkdir .rockbox/fonts/ >/dev/null 2>&1`;
127 $cmd ="$ROOT/tools/convbdf -f -o \".rockbox/fonts/$font\" \"$ROOT/fonts/$o\" ";
133 #copy the icon specified by the theme
135 $iconset =~ /\/(.*icons\
/(.*))/i;
136 `cp $ROOT/icons/$2 $1`;
139 sub copythemeviewericon
141 #copy the viewer icon specified by the theme
143 $viewericon =~ /\/(.*icons\
/(.*))/i;
144 `cp $ROOT/icons/$2 $1`;
149 # we assume that we copy the WPS files from the same dir the WPSLIST
155 if($wpslist =~ /(.*)WPSLIST/) {
157 # system("cp $dir/$wps .rockbox/wps/");
158 # print "$req_t_wps $req_g_wps\n";
160 if (-e
"$dir/$req_t_wps" ) {
161 system("cp $dir/$req_t_wps .rockbox/wps/$wps");
163 } elsif (-e
"$dir/$req_g_wps") {
164 system("cp $dir/$req_g_wps .rockbox/wps/$wps");
166 open(WPSFILE
, "$dir/$req_g_wps");
168 $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
172 if ($#filelist >= 0) {
173 if (-e
"$dir/$wps_prefix/$req_g") {
174 foreach $file (@filelist) {
175 system("cp $dir/$wps_prefix/$req_g/$file .rockbox/wps/$wps_prefix/");
178 elsif (-e
"$dir/$wps_prefix") {
179 foreach $file (@filelist) {
180 system("cp $dir/$wps_prefix/$file .rockbox/wps/$wps_prefix/");
184 print STDERR
"beep, no dir to copy WPS from!\n";
189 print STDERR
"Skipping $wps - no matching resolution.\n";
192 print STDERR
"No source directory!\n";
200 $cfg =~ s/\.(r|)wps/.cfg/;
204 \# $cfg generated by wpsbuild.pl
205 \# $wps is made by $author
207 wps: /.rockbox/wps/$wps
211 push @out, "font: /.rockbox/fonts/$font\n";
213 if($fgcolor && $main_depth > 2) {
214 push @out, "foreground color: $fgcolor\n";
216 if($bgcolor && $main_depth > 2) {
217 push @out, "background color: $bgcolor\n";
220 push @out, "statusbar: $statusbar\n";
223 # clip resolution from filename
224 $backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
225 push @out, "backdrop: /.rockbox/$backdrop\n";
227 if($lineselectstart && $main_depth > 2) {
228 push @out, "line selector start color: $lineselectstart\n";
230 if($lineselectend && $main_depth > 2) {
231 push @out, "line selector end color: $lineselectend\n";
234 push @out, "selector type: $selecttype\n";
237 push @out, "iconset: $iconset\n";
240 push @out, "viewers iconset: $viewericon\n";
242 if($lineselecttextcolor && $main_depth > 2 ) {
243 push @out, "line selector text color: $lineselecttextcolor\n";
245 if($filetylecolor && $main_depth > 2) {
246 push @out, "filetype colours: $filetylecolor\n";
248 if($rwps && $has_remote ) {
249 push @out, "rwps: /.rockbox/wps/$rwps\n";
251 if(-f
".rockbox/wps/$cfg") {
252 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
255 open(CFG
, ">.rockbox/themes/$cfg");
261 # Get the LCD sizes first
262 ($main_height, $main_width, $main_depth) = getlcdsizes
();
263 ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
265 #print "LCD: ${main_height}x${main_width}x${main_depth}\n";
266 $has_remote = 1 if ($remote_height && $remote_width && remote_depth
);
268 open(WPS
, "<$wpslist");
275 if($l =~ /^ *<(r|)wps>/i) {
278 # undef is a unary operator (!)
292 undef $lineselectstart;
293 undef $lineselectend;
297 undef $lineselecttextcolor;
298 undef $filetylecolor;
303 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
304 # Get the required width and height
305 my ($rheight, $rwidth, $rdepth);
307 ($rheight, $rwidth, $rdepth) =
308 ($remote_height, $remote_width, $remote_depth);
311 ($rheight, $rwidth, $rdepth) =
312 ($main_height, $main_width, $main_depth);
315 if(!$rheight || !$rwidth) {
316 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
317 #$isrwps?"remote ":"";
321 $wpslist =~ /(.*)WPSLIST/;
323 # If this WPS installable on this platform, one of the following
324 # two files will be present
325 foreach $d (@depthlist) {
326 next if ($d > $rdepth);
328 $req_g = $rwidth . "x" . $rheight . "x" . $d;
330 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
331 last if (-e
"$wpsdir/$req_g_wps");
334 $req_g = $req_g . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
336 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
337 last if (-e
"$wpsdir/$req_g_wps");
340 $req_t_wps = $wps_prefix . ".txt" . ".wps";
342 #print "LCD: $wps wants $height x $width\n";
343 #print "LCD: is $rheight x $rwidth\n";
345 #print "gwps: $wpsdir/$req_g_wps" . "\n";
346 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
348 # The target model has an LCD that is suitable for this
351 #print "Size requirement is fine!\n";
352 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
354 # We only make .cfg files for <wps> sections:
360 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
361 #print "Skip $wps due to size restraints\n";
365 elsif($l =~ /^Name: (.*)/i) {
366 # Note that in the case this is within <rwps>, $wps will contain the
367 # name of the rwps. Use $isrwps to figure out what type it is.
368 $wps = $wps_prefix = $1;
369 $wps_prefix =~ s/\.(r|)wps//;
370 # print $wps_prefix . "\n";
372 elsif($l =~ /^RWPS: (.*)/i) {
375 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: (.*)/i) {
378 elsif($l =~ /^Author: (.*)/i) {
381 elsif($l =~ /^Width: (.*)/i) {
384 elsif($l =~ /^Width\.${main_width}x${main_height}x$main_depth: (.*)/i) {
387 elsif($l =~ /^Height: (.*)/i) {
390 elsif($l =~ /^Height\.${main_width}x${main_height}x$main_depth: (.*)/i) {
393 elsif($l =~ /^Font: (.*)/i) {
396 elsif($l =~ /^Foreground Color: (.*)/i) {
399 elsif($l =~ /^Background Color: (.*)/i) {
402 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: (.*)/i) {
406 elsif($l =~ /^Statusbar: (.*)/i) {
409 elsif($l =~ /^Statusbar\.${main_width}x${main_height}x$main_depth: (.*)/i) {
412 elsif($l =~ /^Backdrop: (.*)/i) {
416 elsif($l =~ /^Backdrop\.${main_width}x${main_height}x$main_depth: (.*)/i) {
420 elsif($l =~ /^line selector start color: (.*)/i) {
421 $lineselectstart = $1;
423 elsif($l =~ /^line selector end color: (.*)/i) {
426 elsif($l =~ /^selector type: (.*)/i) {
429 elsif($l =~ /^selector type\.${main_width}x${main_height}x$main_depth: (.*)/i) {
432 elsif($l =~ /^iconset: (.*)/i) {
436 elsif($l =~ /^iconset\.${main_width}x${main_height}x$main_depth: (.*)/i) {
440 elsif($l =~ /^viewers iconset: (.*)/i) {
442 copythemeviewericon
();
444 elsif($l =~ /^viewers iconset\.${main_width}x${main_height}x$main_depth: (.*)/i) {
446 copythemeviewericon
();
448 elsif($l =~ /^line selector text color: (.*)/i) {
449 $lineselecttextcolor = $1;
451 elsif($l =~ /^filetype colours: (.*)/i) {
455 #print "Unknown line: $l!\n";