summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-11-14 15:05:53 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-11-14 15:05:53 +0000
commit8a91802d806376efce1b5605643977c6e7f1bcc4 (patch)
treebf93260310653355f92db006f1169d3d8529b4e1
parentb034a830e4d565cd9917f0e112ed6083ee50ceb7 (diff)
downloadrockbox-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
-rwxr-xr-xwps/wpsbuild.pl141
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 @@
1#!/usr/bin/perl 1#!/usr/bin/perl
2# __________ __ ___.
3# Open \______ \ ____ ____ | | _\_ |__ _______ ___
4# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7# \/ \/ \/ \/ \/
8# $Id$
9#
10
11$ROOT="..";
12
13if($ARGV[0] eq "-r") {
14 $ROOT=$ARGV[1];
15 shift @ARGV;
16 shift @ARGV;
17}
18
19my $verbose;
20if($ARGV[0] eq "-v") {
21 $verbose =1;
22 shift @ARGV;
23}
24
25my $firmdir="$ROOT/firmware";
2 26
3my $wpslist=$ARGV[0]; 27my $wpslist=$ARGV[0];
4 28
29my $target = $ARGV[1];
30my $cppdef = $target;
31
32
5if(!$wpslist) { 33if(!$wpslist) {
6 print "Usage: wpsbuilds.pl [WPSLIST]\n"; 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";
7 exit; 37 exit;
8} 38}
9 39
40sub getlcdsizes {
41 open(GCC, ">gcctemp");
42 print GCC <<STOP
43\#include "config.h"
44Height: LCD_HEIGHT
45Width: LCD_WIDTH
46STOP
47;
48 close(gcc);
49
50 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
51
52 #print "CMD $c\n";
53
54 open(GETSIZE, "$c|");
55
56 my ($height, $width);
57 while(<GETSIZE>) {
58 if($_ =~ /^Height: (\d*)/) {
59 $height = $1;
60 }
61 elsif($_ =~ /^Width: (\d*)/) {
62 $width = $1;
63 }
64 if($height && $width) {
65 last;
66 }
67 }
68 close(GETSIZE);
69 unlink("gcctemp");
70
71 return ($height, $width);
72}
73
74sub mkdirs {
75 my $wpsdir = $wps;
76 $wpsdir =~ s/\.wps//;
77 mkdir ".rockbox/wps", 0777;
78 mkdir ".rockbox/wps/$wpsdir", 0777;
79}
80
81sub copywps {
82 # we assume that we copy the WPS files from the same dir the WPSLIST
83 # file is located in
84 my $dir;
85
86 if($wpslist =~ /(.*)WPSLIST/) {
87 $dir = $1;
88 my $wpsdir = $wps;
89 $wpsdir =~ s/\.wps//;
90 system("cp $dir/$wps .rockbox/wps/");
91 system("cp $dir/$wpsdir/*.bmp .rockbox/wps/$wpsdir/");
92 }
93 else {
94 print STDERR "beep, no dir to copy WPS from!\n";
95 }
96}
97
10sub buildcfg { 98sub buildcfg {
11 my $cfg = $wps; 99 my $cfg = $wps;
100 my @out;
12 101
13 $cfg =~ s/\.wps/.cfg/; 102 $cfg =~ s/\.wps/.cfg/;
14 103
15 open(CFG, ">$cfg"); 104 push @out, <<MOO
16 105\#
17 print CFG <<MOO
18\# $cfg generated by wpsbuild.pl 106\# $cfg generated by wpsbuild.pl
107\# $wps is made by $author
19\# 108\#
20wps: /.rockbox/wps/$wps 109wps: /.rockbox/wps/$wps
21font: /.rockbox/fonts/$font
22statusbar: $statusbar
23MOO 110MOO
24; 111;
112 if($font) {
113 push @out, "font: /.rockbox/fonts/$font\n";
114 }
115 if($statusbar) {
116 push @out, "statusbar: $statusbar\n";
117 }
118
119 open(CFG, ">.rockbox/wps/$cfg");
120 print CFG @out;
25 close(CFG); 121 close(CFG);
26} 122}
27 123
@@ -38,12 +134,42 @@ while(<WPS>) {
38 } 134 }
39 if($within) { 135 if($within) {
40 if($l =~ /^ *<\/wps>/i) { 136 if($l =~ /^ *<\/wps>/i) {
41 buildcfg(); 137
138 my ($rheight, $rwidth) = getlcdsizes();
139
140 if(!$rheight || !$rwidth) {
141 print STDER "Failed to get LCD sizes!\n";
142 exit;
143 }
144
145 # print "LCD: $wps wants $rheight x $rwidth\n";
146
147 if(($height >= $rheight) ||
148 ($width >= $width)) {
149 #
150 # The target model has an LCD that is suitable for this
151 # WPS
152 #
153 mkdirs();
154 buildcfg();
155 copywps();
156 }
42 $within = 0; 157 $within = 0;
158
159 undef $wps, $width, $height, $font, $statusbar, $author;
43 } 160 }
44 elsif($l =~ /^Name: (.*)/i) { 161 elsif($l =~ /^Name: (.*)/i) {
45 $wps = $1; 162 $wps = $1;
46 } 163 }
164 elsif($l =~ /^Author: (.*)/i) {
165 $author = $1;
166 }
167 elsif($l =~ /^Width: (.*)/i) {
168 $width = $1;
169 }
170 elsif($l =~ /^Height: (.*)/i) {
171 $height = $1;
172 }
47 elsif($l =~ /^Font: (.*)/i) { 173 elsif($l =~ /^Font: (.*)/i) {
48 $font = $1; 174 $font = $1;
49 } 175 }
@@ -53,3 +179,4 @@ while(<WPS>) {
53 } 179 }
54} 180}
55 181
182close(WPS)