diff options
author | Daniel Stenberg <daniel@haxx.se> | 2005-11-14 15:05:53 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2005-11-14 15:05:53 +0000 |
commit | 8a91802d806376efce1b5605643977c6e7f1bcc4 (patch) | |
tree | bf93260310653355f92db006f1169d3d8529b4e1 /wps | |
parent | b034a830e4d565cd9917f0e112ed6083ee50ceb7 (diff) | |
download | rockbox-8a91802d806376efce1b5605643977c6e7f1bcc4.tar.gz rockbox-8a91802d806376efce1b5605643977c6e7f1bcc4.zip |
figure out the size of the target LCD and more fiddling to work properly
when invoked by the buildzip script
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7863 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'wps')
-rwxr-xr-x | wps/wpsbuild.pl | 141 |
1 files changed, 134 insertions, 7 deletions
diff --git a/wps/wpsbuild.pl b/wps/wpsbuild.pl index 2eb76c6b06..de7f0067c8 100755 --- a/wps/wpsbuild.pl +++ b/wps/wpsbuild.pl @@ -1,27 +1,123 @@ #!/usr/bin/perl +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +$ROOT=".."; + +if($ARGV[0] eq "-r") { + $ROOT=$ARGV[1]; + shift @ARGV; + shift @ARGV; +} + +my $verbose; +if($ARGV[0] eq "-v") { + $verbose =1; + shift @ARGV; +} + +my $firmdir="$ROOT/firmware"; my $wpslist=$ARGV[0]; +my $target = $ARGV[1]; +my $cppdef = $target; + + if(!$wpslist) { - print "Usage: wpsbuilds.pl [WPSLIST]\n"; + print "Usage: wpsbuilds.pl <WPSLIST> <target>\n", + "Run this script in the root of the target build, and it will put all the\n", + "stuff in .rockbox/wps/\n"; exit; } +sub getlcdsizes { + open(GCC, ">gcctemp"); + print GCC <<STOP +\#include "config.h" +Height: LCD_HEIGHT +Width: LCD_WIDTH +STOP +; + close(gcc); + + my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -"; + + #print "CMD $c\n"; + + open(GETSIZE, "$c|"); + + my ($height, $width); + while(<GETSIZE>) { + if($_ =~ /^Height: (\d*)/) { + $height = $1; + } + elsif($_ =~ /^Width: (\d*)/) { + $width = $1; + } + if($height && $width) { + last; + } + } + close(GETSIZE); + unlink("gcctemp"); + + return ($height, $width); +} + +sub mkdirs { + my $wpsdir = $wps; + $wpsdir =~ s/\.wps//; + mkdir ".rockbox/wps", 0777; + mkdir ".rockbox/wps/$wpsdir", 0777; +} + +sub copywps { + # we assume that we copy the WPS files from the same dir the WPSLIST + # file is located in + my $dir; + + if($wpslist =~ /(.*)WPSLIST/) { + $dir = $1; + my $wpsdir = $wps; + $wpsdir =~ s/\.wps//; + system("cp $dir/$wps .rockbox/wps/"); + system("cp $dir/$wpsdir/*.bmp .rockbox/wps/$wpsdir/"); + } + else { + print STDERR "beep, no dir to copy WPS from!\n"; + } +} + sub buildcfg { my $cfg = $wps; + my @out; $cfg =~ s/\.wps/.cfg/; - open(CFG, ">$cfg"); - - print CFG <<MOO + push @out, <<MOO +\# \# $cfg generated by wpsbuild.pl +\# $wps is made by $author \# wps: /.rockbox/wps/$wps -font: /.rockbox/fonts/$font -statusbar: $statusbar MOO ; + if($font) { + push @out, "font: /.rockbox/fonts/$font\n"; + } + if($statusbar) { + push @out, "statusbar: $statusbar\n"; + } + + open(CFG, ">.rockbox/wps/$cfg"); + print CFG @out; close(CFG); } @@ -38,12 +134,42 @@ while(<WPS>) { } if($within) { if($l =~ /^ *<\/wps>/i) { - buildcfg(); + + my ($rheight, $rwidth) = getlcdsizes(); + + if(!$rheight || !$rwidth) { + print STDER "Failed to get LCD sizes!\n"; + exit; + } + + # print "LCD: $wps wants $rheight x $rwidth\n"; + + if(($height >= $rheight) || + ($width >= $width)) { + # + # The target model has an LCD that is suitable for this + # WPS + # + mkdirs(); + buildcfg(); + copywps(); + } $within = 0; + + undef $wps, $width, $height, $font, $statusbar, $author; } elsif($l =~ /^Name: (.*)/i) { $wps = $1; } + elsif($l =~ /^Author: (.*)/i) { + $author = $1; + } + elsif($l =~ /^Width: (.*)/i) { + $width = $1; + } + elsif($l =~ /^Height: (.*)/i) { + $height = $1; + } elsif($l =~ /^Font: (.*)/i) { $font = $1; } @@ -53,3 +179,4 @@ while(<WPS>) { } } +close(WPS) |