2005-11-14 14:24:17 +00:00
|
|
|
#!/usr/bin/perl
|
2005-11-14 15:05:53 +00:00
|
|
|
# __________ __ ___.
|
|
|
|
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
# \/ \/ \/ \/ \/
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
|
|
|
|
$ROOT="..";
|
|
|
|
|
|
|
|
if($ARGV[0] eq "-r") {
|
|
|
|
$ROOT=$ARGV[1];
|
|
|
|
shift @ARGV;
|
|
|
|
shift @ARGV;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $verbose;
|
|
|
|
if($ARGV[0] eq "-v") {
|
|
|
|
$verbose =1;
|
|
|
|
shift @ARGV;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $firmdir="$ROOT/firmware";
|
2005-11-14 14:24:17 +00:00
|
|
|
|
|
|
|
my $wpslist=$ARGV[0];
|
|
|
|
|
2005-11-14 15:05:53 +00:00
|
|
|
my $target = $ARGV[1];
|
|
|
|
my $cppdef = $target;
|
2006-05-11 14:27:12 +00:00
|
|
|
my @depthlist = ( 16, 8, 4, 2, 1 );
|
2005-11-14 15:05:53 +00:00
|
|
|
|
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",
|
|
|
|
"stuff in .rockbox/wps/\n";
|
2005-11-14 14:24:17 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2005-11-14 15:05:53 +00:00
|
|
|
sub getlcdsizes {
|
2005-11-17 22:39:26 +00:00
|
|
|
my ($remote) = @_;
|
|
|
|
|
2005-11-14 15:05:53 +00:00
|
|
|
open(GCC, ">gcctemp");
|
2005-11-17 22:39:26 +00:00
|
|
|
if($remote) {
|
|
|
|
# Get the remote LCD screen size
|
|
|
|
print GCC <<STOP
|
|
|
|
\#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 {
|
2005-11-14 15:05:53 +00:00
|
|
|
print GCC <<STOP
|
|
|
|
\#include "config.h"
|
2006-03-18 21:17:05 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-11-14 15:05:53 +00:00
|
|
|
Height: LCD_HEIGHT
|
|
|
|
Width: LCD_WIDTH
|
2006-05-11 14:27:12 +00:00
|
|
|
Depth: LCD_DEPTH
|
2006-03-18 21:17:05 +00:00
|
|
|
#endif
|
2005-11-14 15:05:53 +00:00
|
|
|
STOP
|
|
|
|
;
|
2005-11-17 22:39:26 +00:00
|
|
|
}
|
2005-11-14 15:05:53 +00:00
|
|
|
close(gcc);
|
|
|
|
|
|
|
|
my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
|
|
|
|
|
|
|
|
#print "CMD $c\n";
|
|
|
|
|
|
|
|
open(GETSIZE, "$c|");
|
|
|
|
|
|
|
|
my ($height, $width);
|
|
|
|
while(<GETSIZE>) {
|
|
|
|
if($_ =~ /^Height: (\d*)/) {
|
|
|
|
$height = $1;
|
|
|
|
}
|
|
|
|
elsif($_ =~ /^Width: (\d*)/) {
|
|
|
|
$width = $1;
|
|
|
|
}
|
2006-05-11 14:27:12 +00:00
|
|
|
elsif($_ =~ /^Depth: (\d*)/) {
|
|
|
|
$depth = $1;
|
|
|
|
}
|
|
|
|
if($height && $width && $depth) {
|
2005-11-14 15:05:53 +00:00
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(GETSIZE);
|
|
|
|
unlink("gcctemp");
|
|
|
|
|
2006-05-11 14:27:12 +00:00
|
|
|
return ($height, $width, $depth);
|
2005-11-14 15:05:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub mkdirs {
|
|
|
|
my $wpsdir = $wps;
|
2005-11-17 22:39:26 +00:00
|
|
|
$wpsdir =~ s/\.(r|)wps//;
|
2005-11-14 15:05:53 +00:00
|
|
|
mkdir ".rockbox/wps", 0777;
|
2005-11-18 15:33:05 +00:00
|
|
|
mkdir ".rockbox/themes", 0777;
|
2005-11-17 22:39:26 +00:00
|
|
|
|
|
|
|
if( -d ".rockbox/wps/$wpsdir") {
|
2005-11-17 23:47:23 +00:00
|
|
|
#print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n";
|
2005-11-17 22:39:26 +00:00
|
|
|
}
|
2006-05-11 14:27:12 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
mkdir ".rockbox/wps/$wpsdir", 0777;
|
2005-11-17 22:39:26 +00:00
|
|
|
}
|
2005-11-14 15:05:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub copywps {
|
|
|
|
# we assume that we copy the WPS files from the same dir the WPSLIST
|
|
|
|
# file is located in
|
|
|
|
my $dir;
|
2006-05-11 14:27:12 +00:00
|
|
|
my @filelist;
|
|
|
|
my $file;
|
2005-11-14 15:05:53 +00:00
|
|
|
|
|
|
|
if($wpslist =~ /(.*)WPSLIST/) {
|
|
|
|
$dir = $1;
|
2006-05-11 14:27:12 +00:00
|
|
|
# system("cp $dir/$wps .rockbox/wps/");
|
|
|
|
# print "$req_t_wps $req_g_wps\n";
|
2005-11-17 23:47:23 +00:00
|
|
|
|
2006-05-11 14:27:12 +00:00
|
|
|
if (-e "$dir/$req_t_wps" ) {
|
2006-06-14 22:06:11 +00:00
|
|
|
system("cp $dir/$req_t_wps .rockbox/wps/$wps");
|
2006-05-11 14:27:12 +00:00
|
|
|
|
2006-06-14 22:06:11 +00:00
|
|
|
} elsif (-e "$dir/$req_g_wps") {
|
|
|
|
system("cp $dir/$req_g_wps .rockbox/wps/$wps");
|
2006-05-11 14:27:12 +00:00
|
|
|
|
|
|
|
open(WPSFILE, "$dir/$req_g_wps");
|
|
|
|
while (<WPSFILE>) {
|
|
|
|
$filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
|
|
|
|
}
|
|
|
|
close(WPSFILE);
|
|
|
|
|
2006-05-15 07:47:29 +00:00
|
|
|
if (-e "$dir/$wps_prefix/$req_g") {
|
|
|
|
foreach $file (@filelist) {
|
|
|
|
system("cp $dir/$wps_prefix/$req_g/$file .rockbox/wps/$wps_prefix/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif (-e "$dir/$wps_prefix") {
|
2006-05-11 14:27:12 +00:00
|
|
|
foreach $file (@filelist) {
|
|
|
|
system("cp $dir/$wps_prefix/$file .rockbox/wps/$wps_prefix/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print STDERR "beep, no dir to copy WPS from!\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
print STDERR "Skipping $wps - no matching resolution.\n";
|
|
|
|
}
|
|
|
|
} 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 {
|
|
|
|
my $cfg = $wps;
|
2005-11-14 15:05:53 +00:00
|
|
|
my @out;
|
2005-11-14 14:24:17 +00:00
|
|
|
|
2005-11-17 22:39:26 +00:00
|
|
|
$cfg =~ s/\.(r|)wps/.cfg/;
|
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
|
|
|
\#
|
|
|
|
wps: /.rockbox/wps/$wps
|
|
|
|
MOO
|
|
|
|
;
|
2005-11-14 15:05:53 +00:00
|
|
|
if($font) {
|
|
|
|
push @out, "font: /.rockbox/fonts/$font\n";
|
|
|
|
}
|
2007-02-11 20:49:48 +00:00
|
|
|
if($fgcolor) {
|
|
|
|
push @out, "foreground color: $fgcolor\n";
|
|
|
|
}
|
|
|
|
if($bgcolor) {
|
|
|
|
push @out, "background color: $bgcolor\n";
|
|
|
|
}
|
2005-11-14 15:05:53 +00:00
|
|
|
if($statusbar) {
|
|
|
|
push @out, "statusbar: $statusbar\n";
|
|
|
|
}
|
2005-11-18 15:33:05 +00:00
|
|
|
if($rwps && $has_remote ) {
|
2005-11-17 22:39:26 +00:00
|
|
|
push @out, "rwps: /.rockbox/wps/$rwps\n";
|
|
|
|
}
|
2005-11-14 15:05:53 +00:00
|
|
|
|
2005-11-17 22:39:26 +00:00
|
|
|
if(-f ".rockbox/wps/$cfg") {
|
|
|
|
print STDERR "wpsbuild warning: wps/$cfg already exists!\n";
|
|
|
|
}
|
|
|
|
else {
|
2005-11-18 15:33:05 +00:00
|
|
|
open(CFG, ">.rockbox/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
|
2006-05-11 14:27:12 +00:00
|
|
|
my ($main_height, $main_width, $main_depth) = getlcdsizes();
|
|
|
|
my ($remote_height, $remote_width, $remote_depth) = getlcdsizes(1);
|
2005-11-17 22:39:26 +00:00
|
|
|
|
2006-05-11 14:27:12 +00:00
|
|
|
#print "LCD: ${main_height}x${main_width}x${main_depth}\n";
|
|
|
|
$has_remote = true if ($remote_height && $remote_width && remote_depth);
|
2005-11-18 15:33:05 +00:00
|
|
|
|
2005-11-14 14:24:17 +00:00
|
|
|
open(WPS, "<$wpslist");
|
|
|
|
while(<WPS>) {
|
|
|
|
my $l = $_;
|
|
|
|
if($l =~ /^ *\#/) {
|
|
|
|
# skip comment
|
|
|
|
next;
|
|
|
|
}
|
2005-11-17 22:39:26 +00:00
|
|
|
if($l =~ /^ *<(r|)wps>/i) {
|
|
|
|
$isrwps = $1;
|
2005-11-14 14:24:17 +00:00
|
|
|
$within = 1;
|
2005-11-18 15:33:05 +00:00
|
|
|
# undef is a unary operator (!)
|
|
|
|
undef $wps;
|
2006-05-11 14:27:12 +00:00
|
|
|
undef $wps_prefix;
|
2005-11-18 15:33:05 +00:00
|
|
|
undef $rwps;
|
|
|
|
undef $width;
|
|
|
|
undef $height;
|
|
|
|
undef $font;
|
2007-02-11 20:49:48 +00:00
|
|
|
undef $fgcolor;
|
|
|
|
undef $bgcolor;
|
2005-11-18 15:33:05 +00:00
|
|
|
undef $statusbar;
|
|
|
|
undef $author;
|
2006-05-11 14:27:12 +00:00
|
|
|
undef $req_g_wps;
|
2006-06-14 22:06:11 +00:00
|
|
|
undef $req_t_wps;
|
2005-11-14 14:24:17 +00:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
if($within) {
|
2005-11-17 22:39:26 +00:00
|
|
|
if($l =~ /^ *<\/${isrwps}wps>/i) {
|
|
|
|
# Get the required width and height
|
2006-05-11 14:27:12 +00:00
|
|
|
my ($rheight, $rwidth, $rdepth);
|
2005-11-17 22:39:26 +00:00
|
|
|
if($isrwps) {
|
2006-05-11 14:27:12 +00:00
|
|
|
($rheight, $rwidth, $rdepth) =
|
|
|
|
($remote_height, $remote_width, $remote_depth);
|
2005-11-17 22:39:26 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-05-11 14:27:12 +00:00
|
|
|
($rheight, $rwidth, $rdepth) =
|
|
|
|
($main_height, $main_width, $main_depth);
|
2005-11-17 22:39:26 +00:00
|
|
|
}
|
2005-11-14 15:05:53 +00:00
|
|
|
|
|
|
|
if(!$rheight || !$rwidth) {
|
2006-03-18 21:17:05 +00:00
|
|
|
#printf STDERR "wpsbuild notice: No %sLCD size, skipping $wps\n",
|
2005-11-17 22:39:26 +00:00
|
|
|
$isrwps?"remote ":"";
|
2005-11-18 15:33:05 +00:00
|
|
|
$within = 0;
|
2005-11-17 22:39:26 +00:00
|
|
|
next;
|
2005-11-14 15:05:53 +00:00
|
|
|
}
|
2006-05-11 14:27:12 +00:00
|
|
|
$wpslist =~ /(.*)WPSLIST/;
|
|
|
|
my $wpsdir = $1;
|
2006-06-14 22:06:11 +00:00
|
|
|
# If this WPS installable on this platform, one of the following
|
|
|
|
# two files will be present
|
|
|
|
foreach $d (@depthlist) {
|
2006-05-11 14:27:12 +00:00
|
|
|
next if ($d > $rdepth);
|
|
|
|
|
2006-06-14 22:06:11 +00:00
|
|
|
$req_g = $rwidth . "x" . $rheight . "x" . $d;
|
2006-05-15 07:47:29 +00:00
|
|
|
|
2006-06-14 22:06:11 +00:00
|
|
|
$req_g_wps = $wps_prefix . "." . $req_g . ".wps";
|
|
|
|
last if (-e "$wpsdir/$req_g_wps");
|
2006-06-15 20:17:47 +00:00
|
|
|
|
|
|
|
if ($isrwps) {
|
|
|
|
$req_g = $req_g . "." . $main_width . "x" . $main_height . "x" . "$main_depth";
|
|
|
|
|
|
|
|
$req_g_wps = $wps_prefix . "." . $req_g . ".wps";
|
|
|
|
last if (-e "$wpsdir/$req_g_wps");
|
|
|
|
}
|
2006-05-11 14:27:12 +00:00
|
|
|
}
|
|
|
|
$req_t_wps = $wps_prefix . ".txt" . ".wps";
|
2005-11-14 15:05:53 +00:00
|
|
|
|
2005-11-14 15:10:40 +00:00
|
|
|
#print "LCD: $wps wants $height x $width\n";
|
|
|
|
#print "LCD: is $rheight x $rwidth\n";
|
2005-11-14 15:05:53 +00:00
|
|
|
|
2006-05-11 14:27:12 +00:00
|
|
|
#print "gwps: $wpsdir/$req_g_wps" . "\n";
|
|
|
|
if (-e "$wpsdir/$req_g_wps" || -e "$wpsdir/$req_t_wps" ) {
|
2005-11-14 15:05:53 +00:00
|
|
|
#
|
|
|
|
# The target model has an LCD that is suitable for this
|
|
|
|
# WPS
|
|
|
|
#
|
2005-11-14 15:10:40 +00:00
|
|
|
#print "Size requirement is fine!\n";
|
2006-05-11 14:27:12 +00:00
|
|
|
mkdirs() if (-e "$wpsdir/$req_g_wps");
|
2005-11-17 23:47:23 +00:00
|
|
|
if(!$isrwps) {
|
|
|
|
# We only make .cfg files for <wps> sections:
|
|
|
|
buildcfg();
|
|
|
|
}
|
2005-11-14 15:05:53 +00:00
|
|
|
copywps();
|
|
|
|
}
|
2005-11-14 15:10:40 +00:00
|
|
|
else {
|
2006-05-11 14:27:12 +00:00
|
|
|
#print "(${wps_prefix}-${rwidth}x${rheight}x$rdepth) ";
|
2006-10-26 14:20:31 +00:00
|
|
|
#print "Skip $wps due to size restraints\n";
|
2005-11-14 15:10:40 +00:00
|
|
|
}
|
2005-11-14 14:24:17 +00:00
|
|
|
$within = 0;
|
|
|
|
}
|
|
|
|
elsif($l =~ /^Name: (.*)/i) {
|
2005-11-17 23:47:23 +00:00
|
|
|
# Note that in the case this is within <rwps>, $wps will contain the
|
|
|
|
# name of the rwps. Use $isrwps to figure out what type it is.
|
2006-05-11 14:27:12 +00:00
|
|
|
$wps = $wps_prefix = $1;
|
|
|
|
$wps_prefix =~ s/\.(r|)wps//;
|
|
|
|
# print $wps_prefix . "\n";
|
2005-11-14 14:24:17 +00:00
|
|
|
}
|
2005-11-17 22:39:26 +00:00
|
|
|
elsif($l =~ /^RWPS: (.*)/i) {
|
|
|
|
$rwps = $1;
|
|
|
|
}
|
2006-06-15 20:17:47 +00:00
|
|
|
elsif($l =~ /^RWPS\.${main_width}x${main_height}x$main_depth: (.*)/i) {
|
|
|
|
$rwps = $1;
|
|
|
|
}
|
2005-11-14 15:05:53 +00:00
|
|
|
elsif($l =~ /^Author: (.*)/i) {
|
|
|
|
$author = $1;
|
|
|
|
}
|
|
|
|
elsif($l =~ /^Width: (.*)/i) {
|
|
|
|
$width = $1;
|
|
|
|
}
|
|
|
|
elsif($l =~ /^Height: (.*)/i) {
|
|
|
|
$height = $1;
|
|
|
|
}
|
2005-11-14 14:24:17 +00:00
|
|
|
elsif($l =~ /^Font: (.*)/i) {
|
|
|
|
$font = $1;
|
|
|
|
}
|
2007-02-11 20:49:48 +00:00
|
|
|
elsif($l =~ /^Foreground Color: (.*)/i) {
|
|
|
|
$fgcolor = $1;
|
|
|
|
}
|
|
|
|
elsif($l =~ /^Background Color: (.*)/i) {
|
|
|
|
$bgcolor = $1;
|
|
|
|
}
|
2006-06-14 22:06:11 +00:00
|
|
|
elsif($l =~ /^Font\.${main_width}x${main_height}x$main_depth: (.*)/i) {
|
|
|
|
$font = $1;
|
|
|
|
}
|
2005-11-14 14:24:17 +00:00
|
|
|
elsif($l =~ /^Statusbar: (.*)/i) {
|
|
|
|
$statusbar = $1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-11 14:27:12 +00:00
|
|
|
close(WPS);
|