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, "foreground color: $fgcolor\n";
178 push @out, "background color: $bgcolor\n";
181 push @out, "statusbar: $statusbar\n";
183 if($rwps && $has_remote ) {
184 push @out, "rwps: /.rockbox/wps/$rwps\n";
187 if(-f
".rockbox/wps/$cfg") {
188 print STDERR
"wpsbuild warning: wps/$cfg already exists!\n";
191 open(CFG
, ">.rockbox/themes/$cfg");
197 # Get the LCD sizes first
198 my ($main_height, $main_width, $main_depth) = getlcdsizes
();
199 my ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
201 #print "LCD: ${main_height}x${main_width}x${main_depth}\n";
202 $has_remote = true
if ($remote_height && $remote_width && remote_depth
);
204 open(WPS
, "<$wpslist");
211 if($l =~ /^ *<(r|)wps>/i) {
214 # undef is a unary operator (!)
230 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
231 # Get the required width and height
232 my ($rheight, $rwidth, $rdepth);
234 ($rheight, $rwidth, $rdepth) =
235 ($remote_height, $remote_width, $remote_depth);
238 ($rheight, $rwidth, $rdepth) =
239 ($main_height, $main_width, $main_depth);
242 if(!$rheight || !$rwidth) {
243 #printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
244 $isrwps?
"remote ":"";
248 $wpslist =~ /(.*)WPSLIST/;
250 # If this WPS installable on this platform, one of the following
251 # two files will be present
252 foreach $d (@depthlist) {
253 next if ($d > $rdepth);
255 $req_g = $rwidth . "x" . $rheight . "x" . $d;
257 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
258 last if (-e
"$wpsdir/$req_g_wps");
261 $req_g = $req_g . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
263 $req_g_wps = $wps_prefix . "." . $req_g . ".wps";
264 last if (-e
"$wpsdir/$req_g_wps");
267 $req_t_wps = $wps_prefix . ".txt" . ".wps";
269 #print "LCD: $wps wants $height x $width\n";
270 #print "LCD: is $rheight x $rwidth\n";
272 #print "gwps: $wpsdir/$req_g_wps" . "\n";
273 if (-e
"$wpsdir/$req_g_wps" || -e
"$wpsdir/$req_t_wps" ) {
275 # The target model has an LCD that is suitable for this
278 #print "Size requirement is fine!\n";
279 mkdirs
() if (-e
"$wpsdir/$req_g_wps");
281 # We only make .cfg files for <wps> sections:
287 #print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
288 #print "Skip $wps due to size restraints\n";
292 elsif($l =~ /^Name: (.*)/i) {
293 # Note that in the case this is within <rwps>, $wps will contain the
294 # name of the rwps. Use $isrwps to figure out what type it is.
295 $wps = $wps_prefix = $1;
296 $wps_prefix =~ s/\.(r|)wps//;
297 # print $wps_prefix . "\n";
299 elsif($l =~ /^RWPS: (.*)/i) {
302 elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: (.*)/i) {
305 elsif($l =~ /^Author: (.*)/i) {
308 elsif($l =~ /^Width: (.*)/i) {
311 elsif($l =~ /^Height: (.*)/i) {
314 elsif($l =~ /^Font: (.*)/i) {
317 elsif($l =~ /^Foreground Color: (.*)/i) {
320 elsif($l =~ /^Background Color: (.*)/i) {
323 elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: (.*)/i) {
326 elsif($l =~ /^Statusbar: (.*)/i) {