diff options
Diffstat (limited to 'wps')
-rwxr-xr-x | wps/wpsbuild.pl | 72 |
1 files changed, 58 insertions, 14 deletions
diff --git a/wps/wpsbuild.pl b/wps/wpsbuild.pl index a8e325fde7..74aad42417 100755 --- a/wps/wpsbuild.pl +++ b/wps/wpsbuild.pl | |||
@@ -38,13 +38,28 @@ if(!$wpslist) { | |||
38 | } | 38 | } |
39 | 39 | ||
40 | sub getlcdsizes { | 40 | sub getlcdsizes { |
41 | my ($remote) = @_; | ||
42 | |||
41 | open(GCC, ">gcctemp"); | 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 | ||
49 | Height: LCD_REMOTE_HEIGHT | ||
50 | Width: LCD_REMOTE_WIDTH | ||
51 | #endif | ||
52 | STOP | ||
53 | ; | ||
54 | } | ||
55 | else { | ||
42 | print GCC <<STOP | 56 | print GCC <<STOP |
43 | \#include "config.h" | 57 | \#include "config.h" |
44 | Height: LCD_HEIGHT | 58 | Height: LCD_HEIGHT |
45 | Width: LCD_WIDTH | 59 | Width: LCD_WIDTH |
46 | STOP | 60 | STOP |
47 | ; | 61 | ; |
62 | } | ||
48 | close(gcc); | 63 | close(gcc); |
49 | 64 | ||
50 | my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -"; | 65 | my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -"; |
@@ -73,9 +88,15 @@ STOP | |||
73 | 88 | ||
74 | sub mkdirs { | 89 | sub mkdirs { |
75 | my $wpsdir = $wps; | 90 | my $wpsdir = $wps; |
76 | $wpsdir =~ s/\.wps//; | 91 | $wpsdir =~ s/\.(r|)wps//; |
77 | mkdir ".rockbox/wps", 0777; | 92 | mkdir ".rockbox/wps", 0777; |
78 | mkdir ".rockbox/wps/$wpsdir", 0777; | 93 | |
94 | if( -d ".rockbox/wps/$wpsdir") { | ||
95 | print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n"; | ||
96 | } | ||
97 | else { | ||
98 | mkdir ".rockbox/wps/$wpsdir", 0777; | ||
99 | } | ||
79 | } | 100 | } |
80 | 101 | ||
81 | sub copywps { | 102 | sub copywps { |
@@ -86,7 +107,7 @@ sub copywps { | |||
86 | if($wpslist =~ /(.*)WPSLIST/) { | 107 | if($wpslist =~ /(.*)WPSLIST/) { |
87 | $dir = $1; | 108 | $dir = $1; |
88 | my $wpsdir = $wps; | 109 | my $wpsdir = $wps; |
89 | $wpsdir =~ s/\.wps//; | 110 | $wpsdir =~ s/\.(r|)wps//; |
90 | system("cp $dir/$wps .rockbox/wps/"); | 111 | system("cp $dir/$wps .rockbox/wps/"); |
91 | if (-e "$dir/$wpsdir") { | 112 | if (-e "$dir/$wpsdir") { |
92 | system("cp $dir/$wpsdir/*.bmp .rockbox/wps/$wpsdir/"); | 113 | system("cp $dir/$wpsdir/*.bmp .rockbox/wps/$wpsdir/"); |
@@ -101,7 +122,7 @@ sub buildcfg { | |||
101 | my $cfg = $wps; | 122 | my $cfg = $wps; |
102 | my @out; | 123 | my @out; |
103 | 124 | ||
104 | $cfg =~ s/\.wps/.cfg/; | 125 | $cfg =~ s/\.(r|)wps/.cfg/; |
105 | 126 | ||
106 | push @out, <<MOO | 127 | push @out, <<MOO |
107 | \# | 128 | \# |
@@ -117,12 +138,24 @@ MOO | |||
117 | if($statusbar) { | 138 | if($statusbar) { |
118 | push @out, "statusbar: $statusbar\n"; | 139 | push @out, "statusbar: $statusbar\n"; |
119 | } | 140 | } |
141 | if($rwps) { | ||
142 | push @out, "rwps: /.rockbox/wps/$rwps\n"; | ||
143 | } | ||
120 | 144 | ||
121 | open(CFG, ">.rockbox/wps/$cfg"); | 145 | if(-f ".rockbox/wps/$cfg") { |
122 | print CFG @out; | 146 | print STDERR "wpsbuild warning: wps/$cfg already exists!\n"; |
123 | close(CFG); | 147 | } |
148 | else { | ||
149 | open(CFG, ">.rockbox/wps/$cfg"); | ||
150 | print CFG @out; | ||
151 | close(CFG); | ||
152 | } | ||
124 | } | 153 | } |
125 | 154 | ||
155 | # Get the LCD sizes first | ||
156 | my ($main_height, $main_width) = getlcdsizes(); | ||
157 | my ($remote_height, $remote_width) = getlcdsizes(1); | ||
158 | |||
126 | open(WPS, "<$wpslist"); | 159 | open(WPS, "<$wpslist"); |
127 | while(<WPS>) { | 160 | while(<WPS>) { |
128 | my $l = $_; | 161 | my $l = $_; |
@@ -130,18 +163,26 @@ while(<WPS>) { | |||
130 | # skip comment | 163 | # skip comment |
131 | next; | 164 | next; |
132 | } | 165 | } |
133 | if($l =~ /^ *<wps>/i) { | 166 | if($l =~ /^ *<(r|)wps>/i) { |
167 | $isrwps = $1; | ||
134 | $within = 1; | 168 | $within = 1; |
135 | next; | 169 | next; |
136 | } | 170 | } |
137 | if($within) { | 171 | if($within) { |
138 | if($l =~ /^ *<\/wps>/i) { | 172 | if($l =~ /^ *<\/${isrwps}wps>/i) { |
139 | 173 | # Get the required width and height | |
140 | my ($rheight, $rwidth) = getlcdsizes(); | 174 | my ($rheight, $rwidth); |
175 | if($isrwps) { | ||
176 | ($rheight, $rwidth) = ($remote_height, $remote_width); | ||
177 | } | ||
178 | else { | ||
179 | ($rheight, $rwidth) = ($main_height, $main_width); | ||
180 | } | ||
141 | 181 | ||
142 | if(!$rheight || !$rwidth) { | 182 | if(!$rheight || !$rwidth) { |
143 | print STDER "Failed to get LCD sizes!\n"; | 183 | printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n", |
144 | exit; | 184 | $isrwps?"remote ":""; |
185 | next; | ||
145 | } | 186 | } |
146 | 187 | ||
147 | #print "LCD: $wps wants $height x $width\n"; | 188 | #print "LCD: $wps wants $height x $width\n"; |
@@ -163,11 +204,14 @@ while(<WPS>) { | |||
163 | } | 204 | } |
164 | $within = 0; | 205 | $within = 0; |
165 | 206 | ||
166 | undef $wps, $width, $height, $font, $statusbar, $author; | 207 | undef $wps, $rwps, $width, $height, $font, $statusbar, $author; |
167 | } | 208 | } |
168 | elsif($l =~ /^Name: (.*)/i) { | 209 | elsif($l =~ /^Name: (.*)/i) { |
169 | $wps = $1; | 210 | $wps = $1; |
170 | } | 211 | } |
212 | elsif($l =~ /^RWPS: (.*)/i) { | ||
213 | $rwps = $1; | ||
214 | } | ||
171 | elsif($l =~ /^Author: (.*)/i) { | 215 | elsif($l =~ /^Author: (.*)/i) { |
172 | $author = $1; | 216 | $author = $1; |
173 | } | 217 | } |