summaryrefslogtreecommitdiff
path: root/wps/.#wpsbuild.pl.1.9
diff options
context:
space:
mode:
Diffstat (limited to 'wps/.#wpsbuild.pl.1.9')
-rwxr-xr-xwps/.#wpsbuild.pl.1.9242
1 files changed, 242 insertions, 0 deletions
diff --git a/wps/.#wpsbuild.pl.1.9 b/wps/.#wpsbuild.pl.1.9
new file mode 100755
index 0000000000..3ea3ff6c93
--- /dev/null
+++ b/wps/.#wpsbuild.pl.1.9
@@ -0,0 +1,242 @@
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";
26
27my $wpslist=$ARGV[0];
28
29my $target = $ARGV[1];
30my $cppdef = $target;
31
32
33if(!$wpslist) {
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";
37 exit;
38}
39
40sub getlcdsizes {
41 my ($remote) = @_;
42
43 open(GCC, ">gcctemp");
44 if($remote) {
45 # Get the remote LCD screen size
46 print GCC <<STOP
47\#include "config.h"
48#ifdef HAVE_REMOTE_LCD
49Height: LCD_REMOTE_HEIGHT
50Width: LCD_REMOTE_WIDTH
51#endif
52STOP
53;
54 }
55 else {
56 print GCC <<STOP
57\#include "config.h"
58Height: LCD_HEIGHT
59Width: LCD_WIDTH
60STOP
61;
62}
63 close(gcc);
64
65 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
66
67 #print "CMD $c\n";
68
69 open(GETSIZE, "$c|");
70
71 my ($height, $width);
72 while(<GETSIZE>) {
73 if($_ =~ /^Height: (\d*)/) {
74 $height = $1;
75 }
76 elsif($_ =~ /^Width: (\d*)/) {
77 $width = $1;
78 }
79 if($height && $width) {
80 last;
81 }
82 }
83 close(GETSIZE);
84 unlink("gcctemp");
85
86 return ($height, $width);
87}
88
89sub mkdirs {
90 my $wpsdir = $wps;
91 $wpsdir =~ s/\.(r|)wps//;
92 mkdir ".rockbox/wps", 0777;
93 mkdir ".rockbox/themes", 0777;
94
95 if( -d ".rockbox/wps/$wpsdir") {
96 #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
97 }
98 else {
99 mkdir ".rockbox/wps/$wpsdir", 0777;
100 }
101}
102
103sub copywps {
104 # we assume that we copy the WPS files from the same dir the WPSLIST
105 # file is located in
106 my $dir;
107
108 if($wpslist =~ /(.*)WPSLIST/) {
109 $dir = $1;
110 my $wpsdir = $wps;
111 $wpsdir =~ s/\.(r|)wps//;
112 system("cp $dir/$wps .rockbox/wps/");
113
114 if (-e "$dir/$wpsdir") {
115 system("cp $dir/$wpsdir/*.bmp .rockbox/wps/$wpsdir/");
116 }
117 }
118 else {
119 print STDERR "beep, no dir to copy WPS from!\n";
120 }
121}
122
123sub buildcfg {
124 my $cfg = $wps;
125 my @out;
126
127 $cfg =~ s/\.(r|)wps/.cfg/;
128
129 push @out, <<MOO
130\#
131\# $cfg generated by wpsbuild.pl
132\# $wps is made by $author
133\#
134wps: /.rockbox/wps/$wps
135MOO
136;
137 if($font) {
138 push @out, "font: /.rockbox/fonts/$font\n";
139 }
140 if($statusbar) {
141 push @out, "statusbar: $statusbar\n";
142 }
143 if($rwps && $has_remote ) {
144 push @out, "rwps: /.rockbox/wps/$rwps\n";
145 }
146
147 if(-f ".rockbox/wps/$cfg") {
148 print STDERR "wpsbuild warning: wps/$cfg already exists!\n";
149 }
150 else {
151 open(CFG, ">.rockbox/themes/$cfg");
152 print CFG @out;
153 close(CFG);
154 }
155}
156
157# Get the LCD sizes first
158my ($main_height, $main_width) = getlcdsizes();
159my ($remote_height, $remote_width) = getlcdsizes(1);
160
161$has_remote = true if ($remote_height && $remote_width);
162
163open(WPS, "<$wpslist");
164while(<WPS>) {
165 my $l = $_;
166 if($l =~ /^ *\#/) {
167 # skip comment
168 next;
169 }
170 if($l =~ /^ *<(r|)wps>/i) {
171 $isrwps = $1;
172 $within = 1;
173 next;
174 }
175 if($within) {
176 if($l =~ /^ *<\/${isrwps}wps>/i) {
177 # Get the required width and height
178 my ($rheight, $rwidth);
179 if($isrwps) {
180 ($rheight, $rwidth) = ($remote_height, $remote_width);
181 }
182 else {
183 ($rheight, $rwidth) = ($main_height, $main_width);
184 }
185
186 if(!$rheight || !$rwidth) {
187 printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
188 $isrwps?"remote ":"";
189 next;
190 }
191
192 #print "LCD: $wps wants $height x $width\n";
193 #print "LCD: is $rheight x $rwidth\n";
194
195 if(($height <= $rheight) && ($width <= $rwidth)) {
196 #
197 # The target model has an LCD that is suitable for this
198 # WPS
199 #
200 #print "Size requirement is fine!\n";
201
202 mkdirs();
203 if(!$isrwps) {
204 # We only make .cfg files for <wps> sections:
205 buildcfg();
206 }
207 copywps();
208 }
209 else {
210 #print "Skip $wps due to size restraints\n";
211 }
212 $within = 0;
213
214 undef $wps, $rwps, $width, $height, $font, $statusbar, $author;
215 }
216 elsif($l =~ /^Name: (.*)/i) {
217 # Note that in the case this is within <rwps>, $wps will contain the
218 # name of the rwps. Use $isrwps to figure out what type it is.
219 $wps = $1;
220 }
221 elsif($l =~ /^RWPS: (.*)/i) {
222 $rwps = $1;
223 }
224 elsif($l =~ /^Author: (.*)/i) {
225 $author = $1;
226 }
227 elsif($l =~ /^Width: (.*)/i) {
228 $width = $1;
229 }
230 elsif($l =~ /^Height: (.*)/i) {
231 $height = $1;
232 }
233 elsif($l =~ /^Font: (.*)/i) {
234 $font = $1;
235 }
236 elsif($l =~ /^Statusbar: (.*)/i) {
237 $statusbar = $1;
238 }
239 }
240}
241
242close(WPS)