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
114 if ($backdrop ne '') {
116 $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
117 $cmd = "cp $ROOT/$backdrop .rockbox/$dst";
124 #copy the font specified by the theme
127 $o =~ s/\.fnt/\.bdf/;
128 `mkdir .rockbox/fonts/ >/dev/null 2>&1`;
129 $cmd ="$ROOT/tools/convbdf -f -o \".rockbox/fonts/$font\" \"$ROOT/fonts/$o\" ";
135 #copy the icon specified by the theme
137 if ($iconset ne '') {
138 $iconset =~ /\/(.*icons\
/(.*))/i;
139 `cp $ROOT/icons/$2 $1`;
143 sub copythemeviewericon
145 #copy the viewer icon specified by the theme
147 if ($viewericon ne '') {
148 $viewericon =~ /\/(.*icons\
/(.*))/i;
149 `cp $ROOT/icons/$2 $1`;
155 # we assume that we copy the WPS files from the same dir the WPSLIST
161 if($wpslist =~ /(.*)WPSLIST/) {
163 # system("cp $dir/$wps .rockbox/wps/");
164 # print "$req_t_wps $req_g_wps\n";
166 if (-e
"$dir/$req_t_wps" ) {
167 system("cp $dir/$req_t_wps .rockbox/wps/$wps");
169 } elsif (-e
"$dir/$req_g_wps") {
170 system("cp $dir/$req_g_wps .rockbox/wps/$wps");
172 open(WPSFILE
, "$dir/$req_g_wps");
174 $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
178 if ($#filelist >= 0) {
179 if (-e
"$dir/$wps_prefix/$req_g") {
180 foreach $file (@filelist) {
181 system("cp $dir/$wps_prefix/$req_g/$file .rockbox/wps/$wps_prefix/");
184 elsif (-e
"$dir/$wps_prefix") {
185 foreach $file (@filelist) {
186 system("cp $dir/$wps_prefix/$file .rockbox/wps/$wps_prefix/");
190 print STDERR
"beep, no dir to copy WPS from!\n";
195 print STDERR
"Skipping $wps - no matching resolution.\n";
198 print STDERR
"No source directory!\n";
206 $cfg =~ s/\.(r|)wps/.cfg/;
210 \# $cfg generated by wpsbuild.pl
211 \# $wps is made by $author
213 wps: /.rockbox/wps/$wps
217 push @out, "font: /.rockbox/fonts/$font\n";
219 if($fgcolor && $main_depth > 2) {
220 push @out, "foreground color: $fgcolor\n";
222 if($bgcolor && $main_depth > 2) {
223 push @out, "background color: $bgcolor\n";
226 push @out, "statusbar: $statusbar\n";
228 if(defined($backdrop)) {
229 if ($backdrop eq '') {
230 push @out, "backdrop:\n";
232 # clip resolution from filename
233 $backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
234 push @out, "backdrop: /.rockbox/$backdrop\n";
237 if($lineselectstart && $main_depth > 2) {
238 push @out, "line selector start color: $lineselectstart\n";
240 if($lineselectend && $main_depth > 2) {
241 push @out, "line selector end color: $lineselectend\n";
244 push @out, "selector type: $selecttype\n";
246 if(defined($iconset)) {
247 push @out, "iconset: $iconset\n";
249 if(defined($viewericon)) {
250 push @out, "viewers iconset: $viewericon\n";
252 if($lineselecttextcolor && $main_depth > 2 ) {
253 push @out, "line selector text color: $lineselecttextcolor\n";
255 if($filetylecolor && $main_depth > 2) {
256 push @out, "filetype colours: $filetylecolor\n";
258 if($rwps && $has_remote ) {
259 push @out, "rwps: /.rockbox/wps/$rwps\n";
261 if(-f
".rockbox/wps/$cfg") {
262 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
265 open(CFG
, ">.rockbox/themes/$cfg");
271 # Get the LCD sizes first
272 ($main_height, $main_width, $main_depth) = getlcdsizes
();
273 ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
275 #print "LCD: ${main_height}x${main_width}x${main_depth}\n";
276 $has_remote = 1 if ($remote_height && $remote_width && remote_depth
);
278 open(WPS
, "<$wpslist");
285 if($l =~ /^ *<(r|)wps>/i) {
288 # undef is a unary operator (!)
302 undef $lineselectstart;
303 undef $lineselectend;
307 undef $lineselecttextcolor;
308 undef $filetylecolor;
313 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
314 # Get the required width and height
315 my ($rheight, $rwidth, $rdepth);
317 ($rheight, $rwidth, $rdepth) =
318 ($remote_height, $remote_width, $remote_depth);
321 ($rheight, $rwidth, $rdepth) =
322 ($main_height, $main_width, $main_depth);
325 if(!$rheight || !$rwidth) {
326 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
327 #$isrwps?"remote ":"";
331 $wpslist =~ /(.*)WPSLIST/;
333 # If this WPS installable on this platform, one of the following
334 # two files will be present
335 foreach $d (@depthlist) {
336 next if ($d > $rdepth);
338 $req_g = $rwidth . "x" . $rheight . "x" . $d;
340 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
341 last if (-e
"$wpsdir/$req_g_wps");
344 $req_g = $req_g . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
346 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
347 last if (-e
"$wpsdir/$req_g_wps");
350 $req_t_wps = $wps_prefix . ".txt" . ".wps";
352 #print "LCD: $wps wants $height x $width\n";
353 #print "LCD: is $rheight x $rwidth\n";
355 #print "gwps: $wpsdir/$req_g_wps" . "\n";
356 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
358 # The target model has an LCD that is suitable for this
361 #print "Size requirement is fine!\n";
362 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
364 # We only make .cfg files for <wps> sections:
370 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
371 #print "Skip $wps due to size restraints\n";
375 elsif($l =~ /^Name: *(.*)/i) {
376 # Note that in the case this is within <rwps>, $wps will contain the
377 # name of the rwps. Use $isrwps to figure out what type it is.
378 $wps = $wps_prefix = $1;
379 $wps_prefix =~ s/\.(r|)wps//;
380 # print $wps_prefix . "\n";
382 elsif($l =~ /^RWPS: *(.*)/i) {
385 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
388 elsif($l =~ /^Author: *(.*)/i) {
391 elsif($l =~ /^Width: *(.*)/i) {
394 elsif($l =~ /^Width\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
397 elsif($l =~ /^Height: *(.*)/i) {
400 elsif($l =~ /^Height\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
403 elsif($l =~ /^Font: *(.*)/i) {
406 elsif($l =~ /^Foreground Color: *(.*)/i) {
409 elsif($l =~ /^Background Color: *(.*)/i) {
412 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
416 elsif($l =~ /^Statusbar: *(.*)/i) {
419 elsif($l =~ /^Statusbar\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
422 elsif($l =~ /^Backdrop: *(.*)/i) {
426 elsif($l =~ /^Backdrop\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
430 elsif($l =~ /^line selector start color: *(.*)/i) {
431 $lineselectstart = $1;
433 elsif($l =~ /^line selector end color: *(.*)/i) {
436 elsif($l =~ /^selector type: *(.*)/i) {
439 elsif($l =~ /^selector type\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
442 elsif($l =~ /^iconset: *(.*)/i) {
446 elsif($l =~ /^iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
450 elsif($l =~ /^viewers iconset: *(.*)/i) {
452 copythemeviewericon
();
454 elsif($l =~ /^viewers iconset\.${main_width}x${main_height}x$main_depth: *(.*)/i) {
456 copythemeviewericon
();
458 elsif($l =~ /^line selector text color: *(.*)/i) {
459 $lineselecttextcolor = $1;
461 elsif($l =~ /^filetype colours: *(.*)/i) {
465 #print "Unknown line: $l!\n";