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";
43 open(GCC
, ">gcctemp");
45 # Get the remote LCD screen size
48 #ifdef HAVE_REMOTE_LCD
49 Height: LCD_REMOTE_HEIGHT
50 Width: LCD_REMOTE_WIDTH
51 Depth: LCD_REMOTE_DEPTH
67 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
75 if($_ =~ /^Height: (\d*)/) {
78 elsif($_ =~ /^Width: (\d*)/) {
81 elsif($_ =~ /^Depth: (\d*)/) {
84 if($height && $width && $depth) {
91 return ($height, $width, $depth);
96 $wpsdir =~ s/\.(r|)wps//;
97 mkdir ".rockbox/wps", 0777;
98 mkdir ".rockbox/themes", 0777;
100 if( -d
".rockbox/wps/$wpsdir") {
101 #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
105 mkdir ".rockbox/wps/$wpsdir", 0777;
110 #copy the backdrop file into the build dir
112 $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
113 $cmd = "cp $ROOT/$backdrop .rockbox/$dst";
118 #copy the font specified by the theme
121 $o =~ s/\.fnt/\.bdf/;
122 `mkdir .rockbox/fonts/ >/dev/null 2>&1`;
123 $cmd ="$ROOT/tools/convbdf -f -o \".rockbox/fonts/$font\" \"$ROOT/fonts/$o\" ";
128 #copy the icon specified by the theme
130 $iconset =~ /\/(.*icons\
/(.*))/i;
131 `cp $ROOT/icons/$2 $1`;
134 sub copythemeviewericon
{
135 #copy the viewer icon specified by the theme
137 $viewericon =~ /\/(.*icons\
/(.*))/i;
138 `cp $ROOT/icons/$2 $1`;
143 # we assume that we copy the WPS files from the same dir the WPSLIST
149 if($wpslist =~ /(.*)WPSLIST/) {
151 # system("cp $dir/$wps .rockbox/wps/");
152 # print "$req_t_wps $req_g_wps\n";
154 if (-e
"$dir/$req_t_wps" ) {
155 system("cp $dir/$req_t_wps .rockbox/wps/$wps");
157 } elsif (-e
"$dir/$req_g_wps") {
158 system("cp $dir/$req_g_wps .rockbox/wps/$wps");
160 open(WPSFILE
, "$dir/$req_g_wps");
162 $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
166 if ($#filelist >= 0) {
167 if (-e
"$dir/$wps_prefix/$req_g") {
168 foreach $file (@filelist) {
169 system("cp $dir/$wps_prefix/$req_g/$file .rockbox/wps/$wps_prefix/");
172 elsif (-e
"$dir/$wps_prefix") {
173 foreach $file (@filelist) {
174 system("cp $dir/$wps_prefix/$file .rockbox/wps/$wps_prefix/");
178 print STDERR
"beep, no dir to copy WPS from!\n";
183 print STDERR
"Skipping $wps - no matching resolution.\n";
186 print STDERR
"No source directory!\n";
194 $cfg =~ s/\.(r|)wps/.cfg/;
198 \# $cfg generated by wpsbuild.pl
199 \# $wps is made by $author
201 wps: /.rockbox/wps/$wps
205 push @out, "font: /.rockbox/fonts/$font\n";
207 if($fgcolor && $main_depth > 2) {
208 push @out, "foreground color: $fgcolor\n";
210 if($bgcolor && $main_depth > 2) {
211 push @out, "background color: $bgcolor\n";
214 push @out, "statusbar: $statusbar\n";
217 #clip resolution from filename
218 $backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
219 push @out, "backdrop: /.rockbox/$backdrop\n";
221 if($lineselectstart && $main_depth > 2) {
222 push @out, "line selector start color: $lineselectstart\n";
224 if($lineselectend && $main_depth > 2) {
225 push @out, "line selector end color: $lineselectend\n";
228 push @out, "selector type: $selecttype\n";
231 push @out, "iconset: $iconset\n";
234 push @out, "viewers iconset: $viewericon\n";
236 if($lineselecttextcolor && $main_depth > 2 ) {
237 push @out, "line selector text color: $lineselecttextcolor\n";
239 if($filetylecolor && $main_depth > 2) {
240 push @out, "filetype colours: $filetylecolor\n";
242 if($rwps && $has_remote ) {
243 push @out, "rwps: /.rockbox/wps/$rwps\n";
245 if(-f
".rockbox/wps/$cfg") {
246 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
249 open(CFG
, ">.rockbox/themes/$cfg");
255 # Get the LCD sizes first
256 ($main_height, $main_width, $main_depth) = getlcdsizes
();
257 ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
259 #print "LCD: ${main_height}x${main_width}x${main_depth}\n";
260 $has_remote = 1 if ($remote_height && $remote_width && remote_depth
);
262 open(WPS
, "<$wpslist");
269 if($l =~ /^ *<(r|)wps>/i) {
272 # undef is a unary operator (!)
286 undef $lineselectstart;
287 undef $lineselectend;
291 undef $lineselecttextcolor;
292 undef $filetylecolor;
297 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
298 # Get the required width and height
299 my ($rheight, $rwidth, $rdepth);
301 ($rheight, $rwidth, $rdepth) =
302 ($remote_height, $remote_width, $remote_depth);
305 ($rheight, $rwidth, $rdepth) =
306 ($main_height, $main_width, $main_depth);
309 if(!$rheight || !$rwidth) {
310 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
311 #$isrwps?"remote ":"";
315 $wpslist =~ /(.*)WPSLIST/;
317 # If this WPS installable on this platform, one of the following
318 # two files will be present
319 foreach $d (@depthlist) {
320 next if ($d > $rdepth);
322 $req_g = $rwidth . "x" . $rheight . "x" . $d;
324 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
325 last if (-e
"$wpsdir/$req_g_wps");
328 $req_g = $req_g . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
330 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
331 last if (-e
"$wpsdir/$req_g_wps");
334 $req_t_wps = $wps_prefix . ".txt" . ".wps";
336 #print "LCD: $wps wants $height x $width\n";
337 #print "LCD: is $rheight x $rwidth\n";
339 #print "gwps: $wpsdir/$req_g_wps" . "\n";
340 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
342 # The target model has an LCD that is suitable for this
345 #print "Size requirement is fine!\n";
346 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
348 # We only make .cfg files for <wps> sections:
354 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
355 #print "Skip $wps due to size restraints\n";
359 elsif($l =~ /^Name: (.*)/i) {
360 # Note that in the case this is within <rwps>, $wps will contain the
361 # name of the rwps. Use $isrwps to figure out what type it is.
362 $wps = $wps_prefix = $1;
363 $wps_prefix =~ s/\.(r|)wps//;
364 # print $wps_prefix . "\n";
366 elsif($l =~ /^RWPS: (.*)/i) {
369 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: (.*)/i) {
372 elsif($l =~ /^Author: (.*)/i) {
375 elsif($l =~ /^Width: (.*)/i) {
378 elsif($l =~ /^Width\.${main_width}x${main_height}x$main_depth: (.*)/i) {
381 elsif($l =~ /^Height: (.*)/i) {
384 elsif($l =~ /^Height\.${main_width}x${main_height}x$main_depth: (.*)/i) {
387 elsif($l =~ /^Font: (.*)/i) {
390 elsif($l =~ /^Foreground Color: (.*)/i) {
393 elsif($l =~ /^Background Color: (.*)/i) {
396 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: (.*)/i) {
400 elsif($l =~ /^Statusbar: (.*)/i) {
403 elsif($l =~ /^Statusbar\.${main_width}x${main_height}x$main_depth: (.*)/i) {
406 elsif($l =~ /^Backdrop: (.*)/i) {
410 elsif($l =~ /^Backdrop\.${main_width}x${main_height}x$main_depth: (.*)/i) {
414 elsif($l =~ /^line selector start color: (.*)/i) {
415 $lineselectstart = $1;
417 elsif($l =~ /^line selector end color: (.*)/i) {
420 elsif($l =~ /^selector type: (.*)/i) {
423 elsif($l =~ /^selector type\.${main_width}x${main_height}x$main_depth: (.*)/i) {
426 elsif($l =~ /^iconset: (.*)/i) {
430 elsif($l =~ /^iconset\.${main_width}x${main_height}x$main_depth: (.*)/i) {
434 elsif($l =~ /^viewers iconset: (.*)/i) {
436 copythemeviewericon
();
438 elsif($l =~ /^viewers iconset\.${main_width}x${main_height}x$main_depth: (.*)/i) {
440 copythemeviewericon
();
442 elsif($l =~ /^line selector text color: (.*)/i) {
443 $lineselecttextcolor = $1;
445 elsif($l =~ /^filetype colours: (.*)/i) {
449 #print "Unknown line: $l!\n";