2005-11-14 14:24:17 +00:00
|
|
|
#!/usr/bin/perl
|
2005-11-14 15:05:53 +00:00
|
|
|
# __________ __ ___.
|
|
|
|
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
# \/ \/ \/ \/ \/
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
|
2008-11-24 22:16:07 +00:00
|
|
|
use strict;
|
|
|
|
use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
|
2014-01-13 22:05:35 +00:00
|
|
|
use IPC::Open2;
|
2005-11-14 15:05:53 +00:00
|
|
|
|
2008-11-24 22:16:07 +00:00
|
|
|
my $ROOT="..";
|
2012-06-10 18:28:36 +00:00
|
|
|
my $wpsdir;
|
2005-11-14 15:05:53 +00:00
|
|
|
my $verbose;
|
2008-11-24 22:16:07 +00:00
|
|
|
my $rbdir=".rockbox";
|
2010-08-01 16:15:27 +00:00
|
|
|
my $tempdir=".rockbox";
|
2008-11-24 22:16:07 +00:00
|
|
|
my $wpslist;
|
|
|
|
my $target;
|
2009-01-31 12:23:35 +00:00
|
|
|
my $modelname;
|
2005-11-14 14:24:17 +00:00
|
|
|
|
2008-11-24 22:16:07 +00:00
|
|
|
# Get options
|
|
|
|
GetOptions ( 'r|root=s' => \$ROOT,
|
2009-01-31 12:23:35 +00:00
|
|
|
'm|modelname=s' => \$modelname,
|
2008-11-24 22:16:07 +00:00
|
|
|
'v|verbose' => \$verbose,
|
|
|
|
'rbdir=s' => \$rbdir, # If we want to put in a different directory
|
2010-08-01 16:15:27 +00:00
|
|
|
'tempdir=s' => \$tempdir, # override .rockbox temporary dir
|
2008-11-24 22:16:07 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
($wpslist, $target) = @ARGV;
|
2005-11-14 14:24:17 +00:00
|
|
|
|
2008-11-26 09:36:34 +00:00
|
|
|
my $firmdir="$ROOT/firmware";
|
2008-02-23 10:03:51 +00:00
|
|
|
my $cppdef = $target;
|
2005-11-14 15:05:53 +00:00
|
|
|
|
2008-11-24 22:16:07 +00:00
|
|
|
# These parameters are filled in as we parse wpslist
|
2009-10-19 15:28:15 +00:00
|
|
|
my $req_t;
|
2012-06-10 18:28:36 +00:00
|
|
|
my $theme;
|
|
|
|
my $has_wps;
|
2008-11-24 22:16:07 +00:00
|
|
|
my $wps;
|
2012-06-10 18:28:36 +00:00
|
|
|
my $has_rwps;
|
2008-11-24 22:16:07 +00:00
|
|
|
my $rwps;
|
2012-06-10 18:28:36 +00:00
|
|
|
my $has_sbs;
|
2009-10-19 15:28:15 +00:00
|
|
|
my $sbs;
|
2012-06-10 18:28:36 +00:00
|
|
|
my $has_rsbs;
|
2009-10-19 15:28:15 +00:00
|
|
|
my $rsbs;
|
2012-06-10 18:28:36 +00:00
|
|
|
my $has_fms;
|
|
|
|
my $fms;
|
|
|
|
my $has_rfms;
|
|
|
|
my $rfms;
|
2008-11-24 22:16:07 +00:00
|
|
|
my $width;
|
|
|
|
my $height;
|
|
|
|
my $font;
|
2010-06-03 07:30:01 +00:00
|
|
|
my $remotefont;
|
2008-11-24 22:16:07 +00:00
|
|
|
my $fgcolor;
|
|
|
|
my $bgcolor;
|
2013-05-06 05:20:40 +00:00
|
|
|
my $sepcolor;
|
|
|
|
my $sep;
|
2008-11-24 22:16:07 +00:00
|
|
|
my $statusbar;
|
2012-06-10 18:28:36 +00:00
|
|
|
my $remotestatusbar;
|
2008-11-24 22:16:07 +00:00
|
|
|
my $author;
|
|
|
|
my $backdrop;
|
|
|
|
my $lineselectstart;
|
|
|
|
my $lineselectend;
|
|
|
|
my $selecttype;
|
|
|
|
my $iconset;
|
2012-06-10 18:28:36 +00:00
|
|
|
my $remoteiconset;
|
2008-11-24 22:16:07 +00:00
|
|
|
my $viewericon;
|
2012-10-05 16:17:52 +00:00
|
|
|
my $showicons;
|
2012-06-10 18:28:36 +00:00
|
|
|
my $remoteviewericon;
|
2008-11-24 22:16:07 +00:00
|
|
|
my $lineselecttextcolor;
|
|
|
|
my $filetylecolor;
|
2009-08-16 22:20:11 +00:00
|
|
|
my $listviewport;
|
|
|
|
my $remotelistviewport;
|
2008-11-24 22:16:07 +00:00
|
|
|
|
|
|
|
# LCD sizes
|
|
|
|
my ($main_height, $main_width, $main_depth);
|
|
|
|
my ($remote_height, $remote_width, $remote_depth);
|
|
|
|
my $has_remote;
|
|
|
|
|
|
|
|
|
2005-11-14 14:24:17 +00:00
|
|
|
if(!$wpslist) {
|
2005-11-14 15:05:53 +00:00
|
|
|
print "Usage: wpsbuilds.pl <WPSLIST> <target>\n",
|
|
|
|
"Run this script in the root of the target build, and it will put all the\n",
|
2010-08-01 16:15:27 +00:00
|
|
|
"stuff in $tempdir/wps/\n and build the cfg according to $rbdir";
|
2005-11-14 14:24:17 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2008-02-23 10:03:51 +00:00
|
|
|
sub getlcdsizes
|
|
|
|
{
|
2005-11-17 22:39:26 +00:00
|
|
|
my ($remote) = @_;
|
2014-01-13 22:05:35 +00:00
|
|
|
my $str;
|
2005-11-17 22:39:26 +00:00
|
|
|
|
|
|
|
if($remote) {
|
|
|
|
# Get the remote LCD screen size
|
2014-01-13 22:05:35 +00:00
|
|
|
$str = <<STOP
|
2005-11-17 22:39:26 +00:00
|
|
|
\#include "config.h"
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
Height: LCD_REMOTE_HEIGHT
|
|
|
|
Width: LCD_REMOTE_WIDTH
|
2006-05-11 14:27:12 +00:00
|
|
|
Depth: LCD_REMOTE_DEPTH
|
2005-11-17 22:39:26 +00:00
|
|
|
#endif
|
|
|
|
STOP
|
|
|
|
;
|
|
|
|
}
|
|
|
|
else {
|
2014-01-13 22:05:35 +00:00
|
|
|
$str = <<STOP
|
2005-11-14 15:05:53 +00:00
|
|
|
\#include "config.h"
|
|
|
|
Height: LCD_HEIGHT
|
|
|
|
Width: LCD_WIDTH
|
2006-05-11 14:27:12 +00:00
|
|
|
Depth: LCD_DEPTH
|
2005-11-14 15:05:53 +00:00
|
|
|
STOP
|
|
|
|
;
|
2014-01-13 22:05:35 +00:00
|
|
|
}
|
2007-03-12 12:57:31 +00:00
|
|
|
close(GCC);
|
2005-11-14 15:05:53 +00:00
|
|
|
|
2014-01-13 22:05:35 +00:00
|
|
|
my $cmd = "gcc $cppdef -I. -I$firmdir/export -E -P -";
|
|
|
|
my $pid = open2(*COUT, *CIN, $cmd) or die "Could not spawn child: $!\n";
|
2005-11-14 15:05:53 +00:00
|
|
|
|
2014-01-13 22:05:35 +00:00
|
|
|
print CIN $str;
|
|
|
|
close(CIN);
|
|
|
|
waitpid($pid, 0);
|
2005-11-14 15:05:53 +00:00
|
|
|
|
2014-01-13 22:05:35 +00:00
|
|
|
my ($height, $width, $depth, $touch);
|
|
|
|
while(<COUT>) {
|
2005-11-14 15:05:53 +00:00
|
|
|
if($_ =~ /^Height: (\d*)/) {
|
|
|
|
$height = $1;
|
|
|
|
}
|
|
|
|
elsif($_ =~ /^Width: (\d*)/) {
|
|
|
|
$width = $1;
|
|
|
|
}
|
2006-05-11 14:27:12 +00:00
|
|
|
elsif($_ =~ /^Depth: (\d*)/) {
|
|
|
|
$depth = $1;
|
|
|
|
}
|
2014-01-13 22:05:35 +00:00
|
|
|
if($_ =~ /^Touchscreen/) {
|
|
|
|
$touch = 1;
|
2005-11-14 15:05:53 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-13 22:05:35 +00:00
|
|
|
close(COUT);
|
2005-11-14 15:05:53 +00:00
|
|
|
|
2006-05-11 14:27:12 +00:00
|
|
|
return ($height, $width, $depth);
|
2005-11-14 15:05:53 +00:00
|
|
|
}
|
|
|
|
|
2008-02-23 10:03:51 +00:00
|
|
|
sub mkdirs
|
|
|
|
{
|
2010-08-01 16:15:27 +00:00
|
|
|
mkdir "$tempdir/wps", 0777;
|
|
|
|
mkdir "$tempdir/themes", 0777;
|
2012-06-10 18:28:36 +00:00
|
|
|
mkdir "$tempdir/icons", 0777;
|
2005-11-17 22:39:26 +00:00
|
|
|
|
2012-06-10 18:28:36 +00:00
|
|
|
if( -d "$tempdir/wps/$theme") {
|
|
|
|
#print STDERR "wpsbuild warning: directory wps/$theme already exists!\n";
|
2005-11-17 22:39:26 +00:00
|
|
|
}
|
2006-05-11 14:27:12 +00:00
|
|
|
else
|
|
|
|
{
|
2012-06-10 18:28:36 +00:00
|
|
|
mkdir "$tempdir/wps/$theme", 0777;
|
2005-11-17 22:39:26 +00:00
|
|
|
}
|
2005-11-14 15:05:53 +00:00
|
|
|
}
|
|
|
|
|
2012-06-10 18:28:36 +00:00
|
|
|
sub normalize
|
|
|
|
{
|
|
|
|
my $in = $_[0];
|
|
|
|
# strip resolution
|
|
|
|
$in =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//;
|
|
|
|
return $in;
|
|
|
|
}
|
|
|
|
|
2008-02-23 10:03:51 +00:00
|
|
|
sub copybackdrop
|
|
|
|
{
|
|
|
|
#copy the backdrop file into the build dir
|
2008-02-23 10:22:06 +00:00
|
|
|
if ($backdrop ne '') {
|
2012-06-10 18:28:36 +00:00
|
|
|
my $dst = normalize($backdrop);
|
|
|
|
system("cp $ROOT/$backdrop $tempdir/$dst");
|
2008-02-23 10:22:06 +00:00
|
|
|
}
|
2008-01-18 04:00:12 +00:00
|
|
|
}
|
|
|
|
|
2008-02-23 10:03:51 +00:00
|
|
|
sub copythemefont
|
|
|
|
{
|
|
|
|
#copy the font specified by the theme
|
2010-06-03 07:30:01 +00:00
|
|
|
my $o = $_[0];
|
2008-01-21 00:21:40 +00:00
|
|
|
|
2008-02-23 10:03:51 +00:00
|
|
|
$o =~ s/\.fnt/\.bdf/;
|
2010-08-01 16:15:27 +00:00
|
|
|
mkdir "$tempdir/fonts";
|
2012-06-10 18:28:36 +00:00
|
|
|
system("$ROOT/tools/convbdf -f -o \"$tempdir/fonts/$_[0]\" \"$ROOT/fonts/$o\" ");
|
2008-01-21 01:48:38 +00:00
|
|
|
}
|
|
|
|
|
2008-02-23 10:03:51 +00:00
|
|
|
sub copythemeicon
|
|
|
|
{
|
2012-06-10 18:28:36 +00:00
|
|
|
my $i = $_[0];
|
2008-02-23 10:03:51 +00:00
|
|
|
#copy the icon specified by the theme
|
2012-06-10 18:28:36 +00:00
|
|
|
if ($i ne "-") {
|
|
|
|
my $tempicon = $tempdir . "/" . $i;
|
2010-08-01 16:15:27 +00:00
|
|
|
$tempicon =~ /\/.*icons\/(.*)/i;
|
2012-06-10 18:28:36 +00:00
|
|
|
system("cp $ROOT/icons/$1 $tempicon");
|
2008-02-23 10:22:06 +00:00
|
|
|
}
|
2008-01-21 01:48:38 +00:00
|
|
|
}
|
|
|
|
|
2012-06-10 18:28:36 +00:00
|
|
|
sub uniq {
|
|
|
|
my %seen = ();
|
|
|
|
my @r = ();
|
|
|
|
foreach my $a (@_) {
|
|
|
|
unless ($seen{$a}) {
|
|
|
|
push @r, $a;
|
|
|
|
$seen{$a} = 1;
|
|
|
|
}
|
2008-02-23 22:54:33 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
return @r;
|
2008-02-23 10:03:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub copywps
|
|
|
|
{
|
2005-11-14 15:05:53 +00:00
|
|
|
# we assume that we copy the WPS files from the same dir the WPSLIST
|
|
|
|
# file is located in
|
|
|
|
my $dir;
|
2012-06-10 18:28:36 +00:00
|
|
|
my %skinfiles = ("wps", $wps,
|
|
|
|
"sbs", $sbs,
|
|
|
|
"fms", $fms,
|
|
|
|
"rwps", $rwps,
|
|
|
|
"rsbs", $rsbs,
|
|
|
|
"rfms", $rfms);
|
2006-05-11 14:27:12 +00:00
|
|
|
my @filelist;
|
|
|
|
my $file;
|
2005-11-14 15:05:53 +00:00
|
|
|
|
2012-06-10 18:28:36 +00:00
|
|
|
if($wpslist =~ /(.*)\/WPSLIST/) {
|
2005-11-14 15:05:53 +00:00
|
|
|
$dir = $1;
|
2012-06-10 18:28:36 +00:00
|
|
|
|
|
|
|
# copy fully-fledged wps, sbs, etc. including graphics
|
|
|
|
foreach my $ext (keys %skinfiles) {
|
|
|
|
next unless ($skinfiles{$ext});
|
|
|
|
$file = $skinfiles{$ext};
|
|
|
|
system("cp $dir/$file $tempdir/wps/$theme.$ext");
|
|
|
|
open(SKIN, "$dir/$file");
|
|
|
|
while (<SKIN>) {
|
|
|
|
$filelist[$#filelist + 1] = $1 if (/[\(,]([^,]*?.bmp)[\),]/);
|
|
|
|
}
|
|
|
|
close(SKIN);
|
2009-10-19 15:28:15 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
|
|
|
|
if ($#filelist >= 0) {
|
|
|
|
if (-e "$dir/$theme") {
|
|
|
|
foreach $file (uniq(@filelist)) {
|
|
|
|
system("cp $dir/$theme/$file $tempdir/wps/$theme/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print STDERR "beep, no dir to copy WPS from!\n";
|
|
|
|
}
|
2009-10-19 15:28:15 +00:00
|
|
|
}
|
2006-05-11 14:27:12 +00:00
|
|
|
} else {
|
|
|
|
print STDERR "No source directory!\n";
|
2005-11-14 15:05:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-14 14:24:17 +00:00
|
|
|
sub buildcfg {
|
2012-06-10 18:28:36 +00:00
|
|
|
my $cfg = $theme . ".cfg";
|
|
|
|
my @out;
|
2005-11-14 14:24:17 +00:00
|
|
|
|
2005-11-14 15:05:53 +00:00
|
|
|
push @out, <<MOO
|
|
|
|
\#
|
2005-11-14 14:24:17 +00:00
|
|
|
\# $cfg generated by wpsbuild.pl
|
2005-11-14 15:05:53 +00:00
|
|
|
\# $wps is made by $author
|
2005-11-14 14:24:17 +00:00
|
|
|
\#
|
|
|
|
MOO
|
|
|
|
;
|
2012-06-10 18:28:36 +00:00
|
|
|
|
|
|
|
my %skinfiles = ("wps" => $wps,
|
|
|
|
"sbs" => $sbs,
|
|
|
|
"fms" => $fms,
|
|
|
|
"rwps" => $rwps,
|
|
|
|
"rsbs" => $rsbs,
|
|
|
|
"rfms" => $rfms);
|
|
|
|
for my $skin (keys %skinfiles) {
|
|
|
|
my $val = $skinfiles{$skin};
|
|
|
|
if (!defined($val)) {
|
|
|
|
# dont put value if not defined (e.g. rwps when there's no remote)
|
|
|
|
next;
|
|
|
|
} elsif ($val eq '') {
|
|
|
|
# empty resets to built-in
|
|
|
|
push @out, "$skin: -\n";
|
2010-02-21 19:10:57 +00:00
|
|
|
} else {
|
2012-06-10 18:28:36 +00:00
|
|
|
# file name is always <theme>.{wps,rwps,...} (see copywps())
|
|
|
|
push @out, "$skin: $rbdir/wps/$theme.$skin\n";
|
2010-02-21 19:10:57 +00:00
|
|
|
}
|
2005-11-17 22:39:26 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
|
|
|
|
push @out, "selector type: $selecttype\n" if (defined($selecttype));
|
|
|
|
push @out, "backdrop: $backdrop\n" if (defined($backdrop));
|
|
|
|
push @out, "filetype colours: $filetylecolor\n" if (defined($filetylecolor));
|
|
|
|
|
|
|
|
if ($main_depth > 2) {
|
|
|
|
push @out, "foreground color: $fgcolor\n" if($fgcolor);
|
|
|
|
push @out, "background color: $bgcolor\n" if($bgcolor);
|
|
|
|
push @out, "line selector start color: $lineselectstart\n" if($lineselectstart);
|
|
|
|
push @out, "line selector end color: $lineselectend\n" if($lineselectend);;
|
|
|
|
push @out, "line selector text color: $lineselecttextcolor\n" if($lineselecttextcolor);
|
2013-05-06 05:20:40 +00:00
|
|
|
# list separator actually depends on HAVE_TOUCSCREEN
|
|
|
|
push @out, "list separator height: $sep\n" if($sep);
|
|
|
|
push @out, "list separator color: $sepcolor\n" if($sepcolor);
|
2009-08-16 22:20:11 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
|
|
|
|
push @out, "font: $font\n" if (defined($font));
|
|
|
|
push @out, "statusbar: $statusbar\n" if (defined($statusbar));
|
|
|
|
push @out, "iconset: $iconset\n" if (defined($iconset));
|
|
|
|
push @out, "viewers iconset: $viewericon\n" if (defined($viewericon));
|
2012-10-05 16:17:52 +00:00
|
|
|
push @out, "show icons: $showicons\n" if (defined($viewericon) && defined($showicons));
|
2012-06-10 18:28:36 +00:00
|
|
|
push @out, "ui viewport: $listviewport\n" if (defined($listviewport));
|
|
|
|
|
|
|
|
if ($has_remote) {
|
|
|
|
push @out, "remote font: $remotefont\n" if (defined($remotefont));
|
|
|
|
push @out, "remote statusbar: $remotestatusbar\n" if (defined($remotestatusbar));
|
|
|
|
push @out, "remote iconset: $remoteiconset\n" if (defined($remoteiconset));
|
|
|
|
push @out, "remote viewers iconset: $remoteviewericon\n" if (defined($remoteviewericon));
|
|
|
|
push @out, "remote ui viewport: $remotelistviewport\n" if (defined($remotelistviewport));
|
2009-08-16 22:20:11 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
|
2010-08-01 16:15:27 +00:00
|
|
|
if(-f "$tempdir/wps/$cfg") {
|
2005-11-17 22:39:26 +00:00
|
|
|
print STDERR "wpsbuild warning: wps/$cfg already exists!\n";
|
|
|
|
}
|
|
|
|
else {
|
2010-08-01 16:15:27 +00:00
|
|
|
open(CFG, ">$tempdir/themes/$cfg");
|
2005-11-17 22:39:26 +00:00
|
|
|
print CFG @out;
|
|
|
|
close(CFG);
|
|
|
|
}
|
2005-11-14 14:24:17 +00:00
|
|
|
}
|
|
|
|
|
2005-11-17 22:39:26 +00:00
|
|
|
# Get the LCD sizes first
|
2008-02-23 09:18:09 +00:00
|
|
|
($main_height, $main_width, $main_depth) = getlcdsizes();
|
|
|
|
($remote_height, $remote_width, $remote_depth) = getlcdsizes(1);
|
2005-11-17 22:39:26 +00:00
|
|
|
|
2009-01-23 20:46:49 +00:00
|
|
|
#print "LCD: ${main_width}x${main_height}x${main_depth}\n";
|
2008-11-24 22:16:07 +00:00
|
|
|
$has_remote = 1 if ($remote_height && $remote_width && $remote_depth);
|
|
|
|
|
2012-06-10 18:28:36 +00:00
|
|
|
|
|
|
|
# check if line matches the setting string or if it contains a regex
|
|
|
|
# that contains the targets resolution
|
2014-01-13 22:06:28 +00:00
|
|
|
#
|
|
|
|
# the line can be of the from
|
|
|
|
# 1) setting: value (handled above)
|
|
|
|
# 2) setting.128x96x2: value
|
|
|
|
# 3) setting.128x96x2&touchscreen: value
|
|
|
|
# The resolution pattern can be a perl-comatible regex
|
|
|
|
sub check_res_feature {
|
2012-06-10 18:28:36 +00:00
|
|
|
my ($line, $string, $remote) = @_;
|
2014-01-13 22:06:28 +00:00
|
|
|
if ($line =~ /^$string: *(.*)/i) {
|
2012-06-10 18:28:36 +00:00
|
|
|
return $1;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($line =~ /^$string\.(.*): *(.*)/i) {
|
|
|
|
# $1 is a resolution/feature regex, $2 the filename incl. resolution
|
|
|
|
my $substr = $1;
|
2012-06-10 18:28:36 +00:00
|
|
|
my $fn = $2;
|
2014-01-13 22:06:28 +00:00
|
|
|
my $feature;
|
2012-06-10 18:28:36 +00:00
|
|
|
my $size_str = "${main_width}x${main_height}x${main_depth}";
|
|
|
|
if ($remote) {
|
|
|
|
$size_str = "${remote_width}x${remote_height}x${remote_depth}";
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
|
|
|
|
# extract feature constraint, if any
|
|
|
|
if ($substr =~ /&([a-z0-9_]+)/) {
|
|
|
|
$feature = $1;
|
|
|
|
$substr =~ s/&$feature//;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($size_str =~ /$substr$/) {
|
|
|
|
if ($feature) {
|
|
|
|
# check feature constrait
|
|
|
|
open(FEAT, "<apps/features");
|
|
|
|
chomp(my @lines = <FEAT>);
|
|
|
|
close(FEAT);
|
|
|
|
my $matches = (grep { /$feature/ } @lines);
|
|
|
|
return $fn if $matches > 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# no feature constraint
|
|
|
|
return $fn;
|
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
# check if <theme>.<model>.<ext> exists. If not, check if <theme>.<ext> exists
|
|
|
|
sub check_skinfile {
|
|
|
|
my $ext = $_[0];
|
|
|
|
my $req_skin = $theme . "." . $modelname . ".$ext";
|
|
|
|
if (-e "$wpsdir/$req_skin") {
|
|
|
|
return $req_skin;
|
|
|
|
} else {
|
|
|
|
$req_skin = $theme . ".$ext";
|
|
|
|
if (-e "$wpsdir/$req_skin") {
|
|
|
|
return $req_skin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Infer WPS (etc.) filename from the the if it wasnt given
|
|
|
|
$wpslist =~ /(.*)WPSLIST/;
|
|
|
|
$wpsdir = $1;
|
2005-11-18 15:33:05 +00:00
|
|
|
|
2005-11-14 14:24:17 +00:00
|
|
|
open(WPS, "<$wpslist");
|
|
|
|
while(<WPS>) {
|
|
|
|
my $l = $_;
|
2008-11-24 22:16:07 +00:00
|
|
|
|
2008-03-10 17:47:58 +00:00
|
|
|
# remove CR
|
|
|
|
$l =~ s/\r//g;
|
2005-11-14 14:24:17 +00:00
|
|
|
if($l =~ /^ *\#/) {
|
|
|
|
# skip comment
|
|
|
|
next;
|
|
|
|
}
|
2010-08-01 16:15:27 +00:00
|
|
|
|
|
|
|
# prefix $rbdir with / if needed (needed for the theme.cfg)
|
2010-08-05 14:31:07 +00:00
|
|
|
unless ($rbdir =~ m/^\/.*/) {
|
2010-08-01 16:15:27 +00:00
|
|
|
$rbdir = "/" . $rbdir;
|
|
|
|
}
|
|
|
|
|
2012-06-10 18:28:36 +00:00
|
|
|
if($l =~ /^ *<theme>/i) {
|
2005-11-18 15:33:05 +00:00
|
|
|
# undef is a unary operator (!)
|
2012-06-10 18:28:36 +00:00
|
|
|
undef $theme;
|
|
|
|
undef $has_wps;
|
|
|
|
undef $has_rwps;
|
|
|
|
undef $has_sbs;
|
|
|
|
undef $has_rsbs;
|
|
|
|
undef $has_fms;
|
|
|
|
undef $has_rfms;
|
2005-11-18 15:33:05 +00:00
|
|
|
undef $wps;
|
|
|
|
undef $rwps;
|
2009-10-19 15:28:15 +00:00
|
|
|
undef $sbs;
|
|
|
|
undef $rsbs;
|
2012-06-10 18:28:36 +00:00
|
|
|
undef $fms;
|
|
|
|
undef $rfms;
|
2008-02-23 10:03:51 +00:00
|
|
|
undef $width;
|
2005-11-18 15:33:05 +00:00
|
|
|
undef $height;
|
|
|
|
undef $font;
|
2010-06-03 07:30:01 +00:00
|
|
|
undef $remotefont;
|
2007-02-11 20:49:48 +00:00
|
|
|
undef $fgcolor;
|
|
|
|
undef $bgcolor;
|
2013-05-06 05:20:40 +00:00
|
|
|
undef $sepcolor;
|
|
|
|
undef $sep;
|
2005-11-18 15:33:05 +00:00
|
|
|
undef $statusbar;
|
2012-06-10 18:28:36 +00:00
|
|
|
undef $remotestatusbar;
|
2005-11-18 15:33:05 +00:00
|
|
|
undef $author;
|
2008-01-18 04:00:12 +00:00
|
|
|
undef $backdrop;
|
|
|
|
undef $lineselectstart;
|
|
|
|
undef $lineselectend;
|
|
|
|
undef $selecttype;
|
|
|
|
undef $iconset;
|
2012-06-10 18:28:36 +00:00
|
|
|
undef $remoteiconset;
|
2008-01-18 04:00:12 +00:00
|
|
|
undef $viewericon;
|
2012-10-05 16:17:52 +00:00
|
|
|
undef $showicons;
|
2012-06-10 18:28:36 +00:00
|
|
|
undef $remoteviewericon;
|
2008-01-18 04:00:12 +00:00
|
|
|
undef $lineselecttextcolor;
|
|
|
|
undef $filetylecolor;
|
2009-08-16 22:20:11 +00:00
|
|
|
undef $listviewport;
|
|
|
|
undef $remotelistviewport;
|
2005-11-14 14:24:17 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
elsif($l =~ /^Name: *(.*)/i) {
|
|
|
|
$theme = $1;
|
|
|
|
}
|
|
|
|
elsif($l =~ /^Authors: *(.*)/i) {
|
|
|
|
$author = $1;
|
|
|
|
}
|
|
|
|
elsif ($l =~ /^WPS: *(yes|no)/i) {
|
|
|
|
$has_wps = $1;
|
|
|
|
}
|
|
|
|
elsif ($l =~ /^RWPS: *(yes|no)/i) {
|
|
|
|
$has_rwps = $1;
|
|
|
|
}
|
|
|
|
elsif ($l =~ /^SBS: *(yes|no)/i) {
|
|
|
|
$has_sbs = $1;
|
|
|
|
}
|
|
|
|
elsif ($l =~ /^RSBS: *(yes|no)/i) {
|
|
|
|
$has_rsbs = $1;
|
|
|
|
}
|
|
|
|
elsif ($l =~ /^FMS: *(yes|no)/i) {
|
|
|
|
$has_fms = $1;
|
|
|
|
}
|
|
|
|
elsif ($l =~ /^RFMS: *(yes|no)/i) {
|
|
|
|
$has_rfms = $1;
|
|
|
|
}
|
|
|
|
elsif($l =~ /^ *<main>/i) {
|
|
|
|
# parse main unit settings
|
|
|
|
while(<WPS>) {
|
|
|
|
my $l = $_;
|
|
|
|
if ($l =~ /^ *<\/main>/i) {
|
|
|
|
last;
|
2005-11-17 22:39:26 +00:00
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "wps")) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$wps = $_;
|
2005-11-17 22:39:26 +00:00
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "sbs")) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$sbs = $_;
|
2005-11-14 15:05:53 +00:00
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "fms")) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$fms = $_;
|
2008-02-23 10:03:51 +00:00
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "Font")) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$font = $_;
|
2005-11-14 15:05:53 +00:00
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "Statusbar")) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$statusbar = $_;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "Backdrop")) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$backdrop = $_;
|
|
|
|
}
|
|
|
|
elsif($l =~ /^Foreground Color: *(.*)/i) {
|
|
|
|
$fgcolor = $1;
|
|
|
|
}
|
|
|
|
elsif($l =~ /^Background Color: *(.*)/i) {
|
|
|
|
$bgcolor = $1;
|
|
|
|
}
|
2013-05-06 05:20:40 +00:00
|
|
|
elsif($_ = check_res_feature($l, "list separator color")) {
|
|
|
|
$sepcolor = $_;
|
|
|
|
}
|
|
|
|
elsif($_ = check_res_feature($l, "list separator height")) {
|
|
|
|
$sep = $_;
|
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
elsif($l =~ /^line selector start color: *(.*)/i) {
|
|
|
|
$lineselectstart = $1;
|
|
|
|
}
|
|
|
|
elsif($l =~ /^line selector end color: *(.*)/i) {
|
|
|
|
$lineselectend = $1;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "selector type")) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$selecttype = $_;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "iconset")) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$iconset = $_;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "viewers iconset")) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$viewericon = $_;
|
|
|
|
}
|
2012-10-05 16:17:52 +00:00
|
|
|
elsif($l =~ /^show icons: *(.*)/i) {
|
|
|
|
$showicons = $1;
|
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
elsif($l =~ /^line selector text color: *(.*)/i) {
|
|
|
|
$lineselecttextcolor = $1;
|
|
|
|
}
|
|
|
|
elsif($l =~ /^filetype colours: *(.*)/i) {
|
|
|
|
$filetylecolor = $1;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "ui viewport")) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$listviewport = $_;
|
2005-11-14 15:10:40 +00:00
|
|
|
}
|
2008-02-23 10:03:51 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
}
|
|
|
|
elsif($l =~ /^ *<remote>/i) {
|
|
|
|
while(<WPS>) {
|
|
|
|
# parse remote settings
|
|
|
|
my $l = $_;
|
|
|
|
if ($l =~ /^ *<\/remote>/i) {
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
elsif(!$has_remote) {
|
|
|
|
next; # dont parse <remote> section
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "rwps", 1)) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$rwps = $_;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "rsbs", 1)) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$rsbs = $_;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "rfms", 1)) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$rfms = $_;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "Font", 1)) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$remotefont = $_;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "iconset", 1)) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$remoteiconset = $_;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "viewers iconset", 1)) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$remoteviewericon = $_;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "statusbar", 1)) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$remotestatusbar = $_;
|
|
|
|
}
|
2014-01-13 22:06:28 +00:00
|
|
|
elsif($_ = check_res_feature($l, "ui viewport", 1)) {
|
2012-06-10 18:28:36 +00:00
|
|
|
$remotelistviewport = $_;
|
|
|
|
}
|
2008-02-23 10:03:51 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
}
|
|
|
|
elsif($l =~ /^ *<\/theme>/i) {
|
|
|
|
# for each wps,sbs,fms (+ remote variants) check if <theme>[.<model>].wps
|
|
|
|
# exists if no filename was specified in WPSLIST
|
|
|
|
my $req_skin;
|
|
|
|
|
|
|
|
if ($has_wps eq "yes" && !$wps) {
|
|
|
|
$wps = check_skinfile("wps");
|
|
|
|
} elsif ($has_wps eq "no") {
|
|
|
|
$wps = '';
|
2008-02-23 10:03:51 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
|
|
|
|
if ($has_sbs eq "yes" && !$sbs) {
|
|
|
|
$sbs = check_skinfile("sbs");
|
|
|
|
} elsif ($has_sbs eq "no") {
|
|
|
|
$sbs = '';
|
2008-02-23 10:03:51 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
|
|
|
|
if ($has_fms eq "yes" && !$fms) {
|
|
|
|
$fms = check_skinfile("fms");
|
|
|
|
} elsif ($has_fms eq "no") {
|
|
|
|
$fms = '';
|
2009-08-16 22:20:11 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
|
|
|
|
# now check for remote skin files (use main screen's extension)
|
|
|
|
if ($has_remote) {
|
|
|
|
if ($has_rwps eq "yes" && !$rwps) {
|
|
|
|
$rwps = check_skinfile("wps");
|
|
|
|
} elsif ($has_rwps eq "no") {
|
|
|
|
$rwps = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($has_rsbs eq "yes" && !$rsbs) {
|
|
|
|
$rsbs = check_skinfile("sbs");
|
|
|
|
} elsif ($has_rsbs eq "no") {
|
|
|
|
$rsbs = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($has_rfms eq "yes" && !$rfms) {
|
|
|
|
$rfms = check_skinfile("fms");
|
|
|
|
} elsif ($has_rfms eq "no") {
|
|
|
|
$rfms = '';
|
|
|
|
}
|
2009-10-19 15:28:15 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
#print "LCD: $wps wants $width x $height\n";
|
|
|
|
|
|
|
|
#
|
|
|
|
# The target model has an LCD that is suitable for this
|
|
|
|
# WPS
|
|
|
|
#
|
|
|
|
#print "Size requirement is fine!\n";
|
|
|
|
mkdirs() if (-e "$wpsdir/$theme");
|
|
|
|
# Do the copying before building the .cfg - buildcfg()
|
|
|
|
# mangles some filenames
|
|
|
|
if (defined($backdrop) && $backdrop ne "-") {
|
|
|
|
copybackdrop();
|
2012-06-25 06:54:21 +00:00
|
|
|
$backdrop = "$rbdir/" . normalize($backdrop);
|
2012-06-10 18:28:36 +00:00
|
|
|
}
|
|
|
|
foreach my $i ($iconset, $viewericon, $remoteiconset, $remoteviewericon) {
|
|
|
|
if (defined($i) && $i ne "-") {
|
|
|
|
copythemeicon($i);
|
2012-06-25 06:54:21 +00:00
|
|
|
$i = "$rbdir/$i";
|
2012-06-10 18:28:36 +00:00
|
|
|
}
|
2009-08-16 22:20:11 +00:00
|
|
|
}
|
2012-06-25 06:54:21 +00:00
|
|
|
foreach my $i ($font, $remotefont) {
|
|
|
|
if (defined($i) && $i ne "-") {
|
2012-10-11 18:04:29 +00:00
|
|
|
copythemefont($i);
|
|
|
|
$i = "$rbdir/fonts/$i";
|
2012-06-25 06:54:21 +00:00
|
|
|
}
|
2008-02-23 10:03:51 +00:00
|
|
|
}
|
2012-06-10 18:28:36 +00:00
|
|
|
buildcfg();
|
|
|
|
copywps();
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
#print "Unknown line: $l!\n";
|
2005-11-14 14:24:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-11 14:27:12 +00:00
|
|
|
close(WPS);
|