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
59 #ifdef HAVE_LCD_BITMAP
69 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
77 if($_ =~ /^Height: (\d*)/) {
80 elsif($_ =~ /^Width: (\d*)/) {
83 elsif($_ =~ /^Depth: (\d*)/) {
86 if($height && $width && $depth) {
93 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;
112 # we assume that we copy the WPS files from the same dir the WPSLIST
118 if($wpslist =~ /(.*)WPSLIST/) {
120 # system("cp $dir/$wps .rockbox/wps/");
121 # print "$req_t_wps $req_g_wps\n";
123 if (-e
"$dir/$req_t_wps" ) {
124 system("cp $dir/$req_t_wps .rockbox/wps/$wps");
126 } elsif (-e
"$dir/$req_g_wps") {
127 system("cp $dir/$req_g_wps .rockbox/wps/$wps");
129 open(WPSFILE
, "$dir/$req_g_wps");
131 $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
135 if (-e
"$dir/$wps_prefix/$req_g") {
136 foreach $file (@filelist) {
137 system("cp $dir/$wps_prefix/$req_g/$file .rockbox/wps/$wps_prefix/");
140 elsif (-e
"$dir/$wps_prefix") {
141 foreach $file (@filelist) {
142 system("cp $dir/$wps_prefix/$file .rockbox/wps/$wps_prefix/");
146 print STDERR
"beep, no dir to copy WPS from!\n";
150 print STDERR
"Skipping $wps - no matching resolution.\n";
153 print STDERR
"No source directory!\n";
161 $cfg =~ s/\.(r|)wps/.cfg/;
165 \# $cfg generated by wpsbuild.pl
166 \# $wps is made by $author
168 wps: /.rockbox/wps/$wps
172 push @out, "font: /.rockbox/fonts/$font\n";
175 push @out, "statusbar: $statusbar\n";
177 if($rwps && $has_remote ) {
178 push @out, "rwps: /.rockbox/wps/$rwps\n";
181 if(-f
".rockbox/wps/$cfg") {
182 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
185 open(CFG
, ">.rockbox/themes/$cfg");
191 # Get the LCD sizes first
192 my ($main_height, $main_width, $main_depth) = getlcdsizes
();
193 my ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
195 #print "LCD: ${main_height}x${main_width}x${main_depth}\n";
196 $has_remote = true
if ($remote_height && $remote_width && remote_depth
);
198 open(WPS
, "<$wpslist");
205 if($l =~ /^ *<(r|)wps>/i) {
208 # undef is a unary operator (!)
222 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
223 # Get the required width and height
224 my ($rheight, $rwidth, $rdepth);
226 ($rheight, $rwidth, $rdepth) =
227 ($remote_height, $remote_width, $remote_depth);
230 ($rheight, $rwidth, $rdepth) =
231 ($main_height, $main_width, $main_depth);
234 if(!$rheight || !$rwidth) {
235 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
236 $isrwps?
"remote ":"";
240 $wpslist =~ /(.*)WPSLIST/;
242 # If this WPS installable on this platform, one of the following
243 # two files will be present
244 foreach $d (@depthlist) {
245 next if ($d > $rdepth);
247 $req_g = $rwidth . "x" . $rheight . "x" . $d;
249 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
250 last if (-e
"$wpsdir/$req_g_wps");
253 $req_g = $req_g . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
255 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
256 last if (-e
"$wpsdir/$req_g_wps");
259 $req_t_wps = $wps_prefix . ".txt" . ".wps";
261 #print "LCD: $wps wants $height x $width\n";
262 #print "LCD: is $rheight x $rwidth\n";
264 #print "gwps: $wpsdir/$req_g_wps" . "\n";
265 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
267 # The target model has an LCD that is suitable for this
270 #print "Size requirement is fine!\n";
271 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
273 # We only make .cfg files for <wps> sections:
279 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
280 print "Skip $wps due to size restraints\n";
284 elsif($l =~ /^Name: (.*)/i) {
285 # Note that in the case this is within <rwps>, $wps will contain the
286 # name of the rwps. Use $isrwps to figure out what type it is.
287 $wps = $wps_prefix = $1;
288 $wps_prefix =~ s/\.(r|)wps//;
289 # print $wps_prefix . "\n";
291 elsif($l =~ /^RWPS: (.*)/i) {
294 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: (.*)/i) {
297 elsif($l =~ /^Author: (.*)/i) {
300 elsif($l =~ /^Width: (.*)/i) {
303 elsif($l =~ /^Height: (.*)/i) {
306 elsif($l =~ /^Font: (.*)/i) {
309 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: (.*)/i) {
312 elsif($l =~ /^Statusbar: (.*)/i) {