3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 # $Id: wpsbuild.pl 24813 2010-02-21 19:10:57Z kugel $
12 use Getopt
::Long
qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
22 GetOptions
( 'r|root=s' => \
$ROOT,
23 'm|modelname=s' => \
$modelname,
24 'v|verbose' => \
$verbose,
25 'rbdir=s' => \
$rbdir, # If we want to put in a different directory
28 ($wpslist, $target) = @ARGV;
30 my $firmdir="$ROOT/firmware";
32 my @depthlist = ( 16, 8, 4, 2, 1 );
36 my ($main_height, $main_width, $main_depth);
37 my ($remote_height, $remote_width, $remote_depth);
42 print "Usage: buildtheme.pl <WPSLIST> <target>\n",
43 "Run this script in the root of the target build, and it will put all the\n",
44 "stuff in $rbdir/wps/\n";
52 open(GCC
, ">gcctemp");
54 # Get the remote LCD screen size
57 #ifdef HAVE_REMOTE_LCD
58 Height: LCD_REMOTE_HEIGHT
59 Width: LCD_REMOTE_WIDTH
60 Depth: LCD_REMOTE_DEPTH
76 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
82 my ($height, $width, $depth);
84 if($_ =~ /^Height: (\d*)/) {
87 elsif($_ =~ /^Width: (\d*)/) {
90 elsif($_ =~ /^Depth: (\d*)/) {
93 if($height && $width && $depth) {
100 return ($height, $width, $depth);
103 # Get the LCD sizes first
104 ($main_height, $main_width, $main_depth) = getlcdsizes
();
105 ($remote_height, $remote_width, $remote_depth) = getlcdsizes
(1);
107 #print "LCD: ${main_width}x${main_height}x${main_depth}\n";
108 $has_remote = 1 if ($remote_height && $remote_width && $remote_depth);
117 my ($string, $pattern)=@_;
119 $pattern =~ s/\*/.*/g;
120 $pattern =~ s/\?/./g;
122 return ($string =~ /^$pattern\z/);
125 sub matchdisplaystring
{
127 return ($string =~ /${main_width}x${main_height}x${main_depth}/i) ||
128 ($string =~ /r${remote_width}x${remote_height}x${remote_depth}/i);
133 my ($themename) = @_;
134 mkdir "$rbdir", 0777;
135 mkdir "$rbdir/wps", 0777;
136 mkdir "$rbdir/themes", 0777;
137 mkdir "$rbdir/icons", 0777;
138 mkdir "$rbdir/backdrops", 0777;
140 if( -d
"$rbdir/wps/$themename") {
141 # print STDERR "wpsbuild warning: directory wps/$themename already exists!\n";
145 mkdir "$rbdir/wps/$themename", 0777;
150 my ($themename) = @_;
155 \# generated by buildtheme.pl
156 \# $themename is made by $theme{"Author"}
161 "Name" => "# Theme Name",
162 "WPS" => "wps", "RWPS" => "rwps",
163 "FMS" => "fms", "RFMS" => "rfms",
164 "SBS" => "sbs", "RSBS" => "rsbs",
165 "Font" => "font", "Remote Font" => "remote font",
166 "Statusbar" => "statusbar", "Remote Statusbar" => "remote statusbar",
167 "selector type" => "selector type", "Remote Selector Type" => "remote selector type",
168 "backdrop" => "backdrop", "iconset" => "iconset", "viewers iconset" => "viewers iconset",
169 "remote iconset" => "remote iconset", "remote viewers iconset" => "remote viewers iconset",
170 "Foreground Color" => "foreground color", "Background Color" => "background color",
171 "backdrop" => "backdrop"
174 while( my ($k, $v) = each %configs )
180 elsif ($k =~ /WPS|RWPS|FMS|RFMS|SBS|RSBS/ && exists($theme{$k}))
182 push (@out, "$v: $themename.$v\n");
184 elsif ($k =~ /backdrop/ )
186 if (exists($theme{$k}))
188 my $dst = $theme{$k};
189 $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
190 push (@out, "$v: $theme{$k}\n");
194 push (@out, "$v: -\n");
197 elsif (exists($theme{$k}))
199 push (@out, "$v: $theme{$k}\n");
203 push (@out, "$v: -\n");
207 # if(-f "$rbdir/themes/$themename.cfg") {
208 # print STDERR "wpsbuild warning: $themename.cfg already exists!\n";
211 open(CFG
, ">$rbdir/themes/$themename.cfg");
221 #copy the font specified by the theme
224 $o =~ s/\.fnt/\.bdf/;
225 mkdir "$rbdir/fonts";
226 my $cmd ="$ROOT/tools/convbdf -f -o \"$rbdir/fonts/$font\" \"$ROOT/fonts/$o\" ";
234 #copy the icon specified by the theme
236 if ($iconset ne '') {
237 $iconset =~ s/.rockbox/$rbdir/;
238 $iconset =~ /\/(.*icons\
/(.*))/i;
239 `cp $ROOT/icons/$2 $1`;
246 #copy the backdrop file into the build dir
250 $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
251 my $cmd = "cp $ROOT/$backdrop $rbdir/$dst";
260 my ($themename, $skin, $ext) = @_;
261 # we assume that we copy the WPS files from the same dir the WPSLIST
269 if($wpslist =~ /(.*)WPSFILE/) {
272 # first try the actual filename given to us
273 # then $skin.widthxheightxdepths.ext
275 $src = "${dir}$skin.$ext";
278 if ($skin =~ /\w\.(\d*x\d*x\d*).*/)
282 my $cmd = "cp $src $rbdir/wps/$themename.$ext";
287 my $is_remote = ($ext =~ /^r.../i);
288 my $width = $is_remote ?
$remote_width : $main_width;
289 my $height = $is_remote ?
$remote_height : $main_height;
290 my $depth = $is_remote ?
$remote_depth : $main_depth;
292 foreach my $d (@depthlist)
294 next if ($d > $depth);
295 $sizestring = "${width}x${height}x${d}";
296 $src = "${dir}$skin.${sizestring}.$ext";
301 my $cmd = "cp $src $rbdir/wps/$themename.$ext";
304 elsif (-e
"${dir}$skin.$ext")
306 my $cmd = "cp ${dir}$skin.$ext $rbdir/wps/$themename.$ext";
311 #print STDERR "buildtheme warning: No suitable skin file for $ext\n";
316 open(WPSFILE
, "$rbdir/wps/$themename.$ext");
318 $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
324 if ($sizestring && -e
"$dir/$themename/$sizestring")
326 foreach $file (@filelist)
328 system("cp $dir/$themename/$sizestring/$file $rbdir/wps/$themename/");
331 elsif (-e
"$dir/$themename")
333 foreach $file (@filelist)
335 system("cp $dir/$themename/$file $rbdir/wps/$themename/");
340 print STDERR
"beep, no dir to copy WPS from!\n";
346 open(WPS
, "<$wpslist");
356 if($l =~ /^ *<(r|)wps>/i) {
363 if($l =~ /^ *<\/${isrwps
}wps
>/i
) {
364 #get the skin directory
365 $wpslist =~ /(.*)WPSLIST/;
369 next if (!exists($theme{Name
}));
370 mkdirs
($theme{Name
});
371 buildcfg
($theme{Name
});
373 copyskin
($theme{"Name"}, $theme{"WPS"}, "wps") if exists($theme{"WPS"});
374 copyskin
($theme{"Name"}, $theme{"RWPS"}, "rwps") if exists($theme{"RWPS"});
375 copyskin
($theme{"Name"}, $theme{"FMS"}, "fms") if exists($theme{"FMS"});
376 copyskin
($theme{"Name"}, $theme{"RFMS"}, "rfms") if exists($theme{"RFMS"});
377 copyskin
($theme{"Name"}, $theme{"SBS"}, "sbs") if exists($theme{"SBS"});
378 copyskin
($theme{"Name"}, $theme{"RSBS"}, "rsbs") if exists($theme{"RSBS"});
380 copyiconset
($theme{"iconset"}) if exists($theme{"iconset"});
381 copyiconset
($theme{"remote iconset"}) if exists($theme{"remote iconset"});
382 copyiconset
($theme{"viewers iconset"}) if exists($theme{"viewers iconset"});
383 copyiconset
($theme{"remote viewers iconset"}) if exists($theme{"remote viewers iconset"});
385 copythemefont
($theme{"Font"}) if exists($theme{"Font"});
386 copythemefont
($theme{"Remote Font"}) if exists($theme{"Remote Font"});
388 copybackdrop
($theme{"backdrop"}) if exists($theme{"backdrop"});
393 elsif($l =~ /^([\w ]*)\.?(.*):\s*(.*)/) {
397 if (!exists($theme{$var}))
400 ($extra && (match
($target, $extra) || matchdisplaystring
($extra))))
402 $theme{$var} = $value;
403 #print "\'$var\': $value\n";
408 #print "Unknown line: $l!\n";