diff options
Diffstat (limited to 'wps/wpsbuild.pl')
-rwxr-xr-x | wps/wpsbuild.pl | 99 |
1 files changed, 74 insertions, 25 deletions
diff --git a/wps/wpsbuild.pl b/wps/wpsbuild.pl index 548b46974f..9d2f122227 100755 --- a/wps/wpsbuild.pl +++ b/wps/wpsbuild.pl @@ -28,7 +28,7 @@ my $wpslist=$ARGV[0]; my $target = $ARGV[1]; my $cppdef = $target; - +my @depthlist = ( 16, 8, 4, 2, 1 ); if(!$wpslist) { print "Usage: wpsbuilds.pl <WPSLIST> <target>\n", @@ -48,6 +48,7 @@ sub getlcdsizes { #ifdef HAVE_REMOTE_LCD Height: LCD_REMOTE_HEIGHT Width: LCD_REMOTE_WIDTH +Depth: LCD_REMOTE_DEPTH #endif STOP ; @@ -58,6 +59,7 @@ STOP #ifdef HAVE_LCD_BITMAP Height: LCD_HEIGHT Width: LCD_WIDTH +Depth: LCD_DEPTH #endif STOP ; @@ -78,14 +80,17 @@ STOP elsif($_ =~ /^Width: (\d*)/) { $width = $1; } - if($height && $width) { + elsif($_ =~ /^Depth: (\d*)/) { + $depth = $1; + } + if($height && $width && $depth) { last; } } close(GETSIZE); unlink("gcctemp"); - return ($height, $width); + return ($height, $width, $depth); } sub mkdirs { @@ -97,8 +102,9 @@ sub mkdirs { if( -d ".rockbox/wps/$wpsdir") { #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n"; } - else { - mkdir ".rockbox/wps/$wpsdir", 0777; + else + { + mkdir ".rockbox/wps/$wpsdir", 0777; } } @@ -106,19 +112,40 @@ sub copywps { # we assume that we copy the WPS files from the same dir the WPSLIST # file is located in my $dir; + my @filelist; + my $file; if($wpslist =~ /(.*)WPSLIST/) { $dir = $1; - my $wpsdir = $wps; - $wpsdir =~ s/\.(r|)wps//; - system("cp $dir/$wps .rockbox/wps/"); +# system("cp $dir/$wps .rockbox/wps/"); + # print "$req_t_wps $req_g_wps\n"; - if (-e "$dir/$wpsdir") { - system("cp $dir/$wpsdir/*.bmp .rockbox/wps/$wpsdir/"); - } - } - else { - print STDERR "beep, no dir to copy WPS from!\n"; + if (-e "$dir/$req_t_wps" ) { + system("cp $dir/$req_t_wps .rockbox/wps/$wps"); + + } elsif (-e "$dir/$req_g_wps") { + system("cp $dir/$req_g_wps .rockbox/wps/$wps"); + + open(WPSFILE, "$dir/$req_g_wps"); + while (<WPSFILE>) { + $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/); + } + close(WPSFILE); + + if (-e "$dir/$wpsdir") { + foreach $file (@filelist) { + system("cp $dir/$wps_prefix/$file .rockbox/wps/$wps_prefix/"); + } + } + else { + print STDERR "beep, no dir to copy WPS from!\n"; + } + + } else { + print STDERR "Skipping $wps - no matching resolution.\n"; + } + } else { + print STDERR "No source directory!\n"; } } @@ -157,10 +184,11 @@ MOO } # Get the LCD sizes first -my ($main_height, $main_width) = getlcdsizes(); -my ($remote_height, $remote_width) = getlcdsizes(1); +my ($main_height, $main_width, $main_depth) = getlcdsizes(); +my ($remote_height, $remote_width, $remote_depth) = getlcdsizes(1); -$has_remote = true if ($remote_height && $remote_width); +#print "LCD: ${main_height}x${main_width}x${main_depth}\n"; +$has_remote = true if ($remote_height && $remote_width && remote_depth); open(WPS, "<$wpslist"); while(<WPS>) { @@ -174,23 +202,28 @@ while(<WPS>) { $within = 1; # undef is a unary operator (!) undef $wps; + undef $wps_prefix; undef $rwps; undef $width; undef $height; undef $font; undef $statusbar; undef $author; + undef $req_g_wps; + undef $req_t_wps; next; } if($within) { if($l =~ /^ *<\/${isrwps}wps>/i) { # Get the required width and height - my ($rheight, $rwidth); + my ($rheight, $rwidth, $rdepth); if($isrwps) { - ($rheight, $rwidth) = ($remote_height, $remote_width); + ($rheight, $rwidth, $rdepth) = + ($remote_height, $remote_width, $remote_depth); } else { - ($rheight, $rwidth) = ($main_height, $main_width); + ($rheight, $rwidth, $rdepth) = + ($main_height, $main_width, $main_depth); } if(!$rheight || !$rwidth) { @@ -199,17 +232,30 @@ while(<WPS>) { $within = 0; next; } + $wpslist =~ /(.*)WPSLIST/; + my $wpsdir = $1; + # If this WPS installable on this platform, one of the following + # two files will be present + foreach $d (@depthlist) { + next if ($d > $rdepth); + + $req_g_wps = $wps_prefix . "." . $rwidth . "x" . $rheight + . "x" . $d . ".wps"; + last if (-e "$wpsdir/$req_g_wps"); + } + $req_t_wps = $wps_prefix . ".txt" . ".wps"; #print "LCD: $wps wants $height x $width\n"; #print "LCD: is $rheight x $rwidth\n"; - if(($height <= $rheight) && ($width <= $rwidth)) { + #print "gwps: $wpsdir/$req_g_wps" . "\n"; + if (-e "$wpsdir/$req_g_wps" || -e "$wpsdir/$req_t_wps" ) { # # The target model has an LCD that is suitable for this # WPS # #print "Size requirement is fine!\n"; - mkdirs(); + mkdirs() if (-e "$wpsdir/$req_g_wps"); if(!$isrwps) { # We only make .cfg files for <wps> sections: buildcfg(); @@ -217,14 +263,17 @@ while(<WPS>) { copywps(); } else { - #print "Skip $wps due to size restraints\n"; + #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) "; + print "Skip $wps due to size restraints\n"; } $within = 0; } elsif($l =~ /^Name: (.*)/i) { # Note that in the case this is within <rwps>, $wps will contain the # name of the rwps. Use $isrwps to figure out what type it is. - $wps = $1; + $wps = $wps_prefix = $1; + $wps_prefix =~ s/\.(r|)wps//; + # print $wps_prefix . "\n"; } elsif($l =~ /^RWPS: (.*)/i) { $rwps = $1; @@ -247,4 +296,4 @@ while(<WPS>) { } } -close(WPS) +close(WPS); |