2004-05-21 19:05:27 +00:00
|
|
|
#!/usr/bin/perl
|
2005-11-14 15:06:51 +00:00
|
|
|
# __________ __ ___.
|
|
|
|
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
# \/ \/ \/ \/ \/
|
|
|
|
# $Id$
|
|
|
|
#
|
2004-05-21 19:05:27 +00:00
|
|
|
|
2004-08-24 15:13:08 +00:00
|
|
|
$ROOT="..";
|
|
|
|
|
|
|
|
if($ARGV[0] eq "-r") {
|
|
|
|
$ROOT=$ARGV[1];
|
|
|
|
shift @ARGV;
|
|
|
|
shift @ARGV;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $verbose;
|
|
|
|
if($ARGV[0] eq "-v") {
|
|
|
|
$verbose =1;
|
|
|
|
shift @ARGV;
|
|
|
|
}
|
|
|
|
|
2005-08-04 18:11:46 +00:00
|
|
|
my $firmdir="$ROOT/firmware";
|
|
|
|
|
2005-08-03 21:31:51 +00:00
|
|
|
my $target = $ARGV[0];
|
|
|
|
my $cppdef = $target;
|
|
|
|
|
|
|
|
my $exe = $ARGV[1];
|
2004-08-24 15:13:08 +00:00
|
|
|
|
2004-08-24 09:38:26 +00:00
|
|
|
sub filesize {
|
|
|
|
my ($filename)=@_;
|
|
|
|
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
|
|
|
|
$atime,$mtime,$ctime,$blksize,$blocks)
|
|
|
|
= stat($filename);
|
|
|
|
return $size;
|
|
|
|
}
|
|
|
|
|
2004-05-21 19:05:27 +00:00
|
|
|
sub buildlangs {
|
|
|
|
my ($outputlang)=@_;
|
2004-08-24 15:13:08 +00:00
|
|
|
my $dir = "$ROOT/apps/lang";
|
2004-05-21 19:05:27 +00:00
|
|
|
opendir(DIR, $dir);
|
|
|
|
my @files = grep { /\.lang$/ } readdir(DIR);
|
|
|
|
closedir(DIR);
|
|
|
|
|
|
|
|
for(@files) {
|
|
|
|
my $output = $_;
|
|
|
|
$output =~ s/(.*)\.lang/$1.lng/;
|
|
|
|
print "lang $_\n" if($verbose);
|
2004-08-24 15:13:08 +00:00
|
|
|
system ("$ROOT/tools/binlang $dir/english.lang $dir/$_ $outputlang/$output >/dev/null 2>&1");
|
2004-05-21 19:05:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub buildzip {
|
|
|
|
my ($zip, $image, $notplayer)=@_;
|
|
|
|
|
|
|
|
# remove old traces
|
|
|
|
`rm -rf .rockbox`;
|
|
|
|
|
|
|
|
mkdir ".rockbox", 0777;
|
|
|
|
mkdir ".rockbox/langs", 0777;
|
|
|
|
mkdir ".rockbox/rocks", 0777;
|
2005-06-05 23:05:10 +00:00
|
|
|
mkdir ".rockbox/codecs", 0777;
|
2005-11-12 21:54:40 +00:00
|
|
|
mkdir ".rockbox/wps", 0777;
|
2005-11-18 15:33:05 +00:00
|
|
|
mkdir ".rockbox/themes", 0777;
|
2005-07-12 11:11:50 +00:00
|
|
|
|
|
|
|
my $c = 'find apps -name "*.codec" ! -empty -exec cp {} .rockbox/codecs/ \;';
|
|
|
|
print `$c`;
|
2005-08-11 20:48:34 +00:00
|
|
|
|
2005-09-06 20:42:45 +00:00
|
|
|
my @call = `find .rockbox/codecs -type f`;
|
2005-08-11 20:48:34 +00:00
|
|
|
if(!$call[0]) {
|
|
|
|
# no codec was copied, remove directory again
|
2005-09-06 20:42:45 +00:00
|
|
|
rmdir(".rockbox/codecs");
|
2005-08-11 20:48:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-12 11:11:50 +00:00
|
|
|
$c= 'find apps "(" -name "*.rock" -o -name "*.ovl" ")" ! -empty -exec cp {} .rockbox/rocks/ \;';
|
|
|
|
print `$c`;
|
2004-05-21 19:05:27 +00:00
|
|
|
|
2004-08-24 15:13:08 +00:00
|
|
|
open VIEWERS, "$ROOT/apps/plugins/viewers.config" or
|
2004-07-13 09:45:39 +00:00
|
|
|
die "can't open viewers.config";
|
|
|
|
@viewers = <VIEWERS>;
|
|
|
|
close VIEWERS;
|
|
|
|
|
|
|
|
open VIEWERS, ">.rockbox/viewers.config" or
|
|
|
|
die "can't create .rockbox/viewers.config";
|
2004-12-01 09:56:36 +00:00
|
|
|
mkdir ".rockbox/viewers", 0777;
|
2005-10-05 08:02:10 +00:00
|
|
|
foreach my $line (@viewers) {
|
|
|
|
if ($line =~ /([^,]*),([^,]*),/) {
|
|
|
|
my ($ext, $plugin)=($1, $2);
|
|
|
|
my $r = "${plugin}.rock";
|
2005-11-02 07:32:16 +00:00
|
|
|
my $oname;
|
2005-10-05 08:02:10 +00:00
|
|
|
|
|
|
|
my $dir = $r;
|
|
|
|
my $name;
|
|
|
|
|
|
|
|
# strip off the last slash and file name part
|
|
|
|
$dir =~ s/(.*)\/(.*)/$1/;
|
|
|
|
# store the file name part
|
|
|
|
$name = $2;
|
|
|
|
|
2005-11-02 07:32:16 +00:00
|
|
|
# get .ovl name (file part only)
|
|
|
|
$oname = $name;
|
|
|
|
$oname =~ s/\.rock$/.ovl/;
|
|
|
|
|
2005-10-05 08:02:10 +00:00
|
|
|
# print STDERR "$ext $plugin $dir $name $r\n";
|
|
|
|
|
|
|
|
if(-e ".rockbox/rocks/$name") {
|
|
|
|
if($dir ne "rocks") {
|
|
|
|
# target is not 'rocks' but the plugins are always in that
|
|
|
|
# dir at first!
|
|
|
|
`mv .rockbox/rocks/$name .rockbox/$r`;
|
|
|
|
}
|
|
|
|
print VIEWERS $line;
|
2004-05-21 21:01:20 +00:00
|
|
|
}
|
2005-10-05 08:02:10 +00:00
|
|
|
elsif(-e ".rockbox/$r") {
|
2005-03-03 22:09:41 +00:00
|
|
|
# in case the same plugin works for multiple extensions, it
|
|
|
|
# was already moved to the viewers dir
|
2005-10-05 08:02:10 +00:00
|
|
|
print VIEWERS $line;
|
2005-03-03 22:09:41 +00:00
|
|
|
}
|
2005-11-02 07:32:16 +00:00
|
|
|
|
|
|
|
if(-e ".rockbox/rocks/$oname") {
|
2005-03-04 08:19:56 +00:00
|
|
|
# if there's an "overlay" file for the .rock, move that as
|
|
|
|
# well
|
2005-11-02 07:32:16 +00:00
|
|
|
`mv .rockbox/rocks/$oname .rockbox/$dir`;
|
2005-03-04 08:19:56 +00:00
|
|
|
}
|
2004-05-21 21:01:20 +00:00
|
|
|
}
|
2004-07-13 09:45:39 +00:00
|
|
|
}
|
|
|
|
close VIEWERS;
|
|
|
|
|
|
|
|
if($notplayer) {
|
2005-06-09 06:50:02 +00:00
|
|
|
`cp $ROOT/apps/plugins/sokoban.levels .rockbox/rocks/`; # sokoban levels
|
2005-06-09 06:14:04 +00:00
|
|
|
`cp $ROOT/apps/plugins/snake2.levels .rockbox/rocks/`; # snake2 levels
|
2004-05-21 21:01:20 +00:00
|
|
|
|
2004-05-21 19:05:27 +00:00
|
|
|
mkdir ".rockbox/fonts", 0777;
|
|
|
|
|
2004-08-24 15:13:08 +00:00
|
|
|
opendir(DIR, "$ROOT/fonts") || die "can't open dir fonts";
|
|
|
|
my @fonts = grep { /\.bdf$/ && -f "$ROOT/fonts/$_" } readdir(DIR);
|
2004-05-21 19:05:27 +00:00
|
|
|
closedir DIR;
|
|
|
|
|
2004-08-24 09:38:26 +00:00
|
|
|
my $maxfont;
|
2005-08-03 21:31:51 +00:00
|
|
|
|
|
|
|
open(SIZE, ">ziptemp");
|
|
|
|
print SIZE <<STOP
|
|
|
|
\#include "font.h"
|
|
|
|
Font Size We Want: MAX_FONT_SIZE
|
|
|
|
STOP
|
|
|
|
;
|
|
|
|
close(SIZE);
|
2005-08-04 18:11:46 +00:00
|
|
|
my $c="cat ziptemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
|
2005-08-03 21:31:51 +00:00
|
|
|
# print STDERR "C: $c\n";
|
|
|
|
open(GETSIZE, "$c|");
|
|
|
|
|
|
|
|
while(<GETSIZE>) {
|
|
|
|
if($_ =~ /^Font Size We Want: (\d*)/) {
|
2004-08-24 09:38:26 +00:00
|
|
|
$maxfont = $1;
|
2005-08-03 21:31:51 +00:00
|
|
|
last;
|
2004-08-24 09:38:26 +00:00
|
|
|
}
|
|
|
|
}
|
2005-08-03 21:31:51 +00:00
|
|
|
close(GETSIZE);
|
|
|
|
unlink("ziptemp");
|
2004-08-24 09:38:26 +00:00
|
|
|
die "no decent max font size" if ($maxfont < 2000);
|
|
|
|
|
2004-05-21 19:05:27 +00:00
|
|
|
for(@fonts) {
|
|
|
|
my $f = $_;
|
|
|
|
|
|
|
|
print "FONT: $f\n" if($verbose);
|
|
|
|
my $o = $f;
|
|
|
|
$o =~ s/\.bdf/\.fnt/;
|
2004-08-24 15:13:08 +00:00
|
|
|
my $cmd ="$ROOT/tools/convbdf -s 32 -l 255 -f -o \".rockbox/fonts/$o\" \"$ROOT/fonts/$f\" >/dev/null 2>&1";
|
2004-05-21 19:05:27 +00:00
|
|
|
print "CMD: $cmd\n" if($verbose);
|
|
|
|
`$cmd`;
|
2004-08-24 09:38:26 +00:00
|
|
|
|
|
|
|
# no need to add fonts we cannot load anyway
|
|
|
|
my $fontsize = filesize(".rockbox/fonts/$o");
|
|
|
|
if($fontsize > $maxfont) {
|
|
|
|
unlink(".rockbox/fonts/$o");
|
|
|
|
}
|
2004-05-21 19:05:27 +00:00
|
|
|
}
|
|
|
|
|
2004-11-20 10:45:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if($image) {
|
|
|
|
# image is blank when this is a simulator
|
|
|
|
if( filesize("rockbox.ucl") > 1000 ) {
|
|
|
|
`cp rockbox.ucl .rockbox/`; # UCL for flashing
|
|
|
|
}
|
|
|
|
if( filesize("rombox.ucl") > 1000) {
|
|
|
|
`cp rombox.ucl .rockbox/`; # UCL for flashing
|
2004-06-14 15:04:46 +00:00
|
|
|
}
|
2004-05-21 19:05:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mkdir ".rockbox/docs", 0777;
|
|
|
|
for(("BATTERY-FAQ",
|
|
|
|
"CUSTOM_CFG_FORMAT",
|
|
|
|
"CUSTOM_WPS_FORMAT",
|
|
|
|
"FAQ",
|
|
|
|
"NODO",
|
|
|
|
"TECH")) {
|
2004-08-24 15:13:08 +00:00
|
|
|
`cp $ROOT/docs/$_ .rockbox/docs/$_.txt`;
|
2004-05-21 19:05:27 +00:00
|
|
|
}
|
|
|
|
|
2005-11-14 15:06:51 +00:00
|
|
|
# Now do the WPS dance
|
|
|
|
if(-d "$ROOT/wps") {
|
2005-11-14 18:52:17 +00:00
|
|
|
system("perl $ROOT/wps/wpsbuild.pl -r $ROOT $ROOT/wps/WPSLIST $target");
|
2005-11-14 15:06:51 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
print STDERR "No wps module present, can't do the WPS magic!\n";
|
|
|
|
}
|
|
|
|
|
2004-05-21 19:05:27 +00:00
|
|
|
# now copy the file made for reading on the unit:
|
|
|
|
#if($notplayer) {
|
|
|
|
# `cp $webroot/docs/Help-JBR.txt .rockbox/docs/`;
|
|
|
|
#}
|
|
|
|
#else {
|
|
|
|
# `cp $webroot/docs/Help-Stu.txt .rockbox/docs/`;
|
|
|
|
#}
|
|
|
|
|
|
|
|
buildlangs(".rockbox/langs");
|
|
|
|
|
2005-06-09 06:50:52 +00:00
|
|
|
`rm -f $zip`;
|
2004-05-21 19:05:27 +00:00
|
|
|
`find .rockbox | zip $zip -@ >/dev/null`;
|
|
|
|
|
2004-06-14 15:04:46 +00:00
|
|
|
if($image) {
|
|
|
|
`zip $zip $image`;
|
|
|
|
}
|
2004-05-21 19:05:27 +00:00
|
|
|
|
|
|
|
# remove the .rockbox afterwards
|
|
|
|
`rm -rf .rockbox`;
|
|
|
|
}
|
|
|
|
|
|
|
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
|
|
|
|
localtime(time);
|
|
|
|
|
|
|
|
$mon+=1;
|
|
|
|
$year+=1900;
|
|
|
|
|
|
|
|
$date=sprintf("%04d%02d%02d", $year,$mon, $mday);
|
|
|
|
$shortdate=sprintf("%02d%02d%02d", $year%100,$mon, $mday);
|
|
|
|
|
|
|
|
# made once for all targets
|
|
|
|
sub runone {
|
|
|
|
my ($type, $target)=@_;
|
|
|
|
|
|
|
|
# build a full install zip file
|
|
|
|
buildzip("rockbox.zip", $target,
|
|
|
|
($type eq "player")?0:1);
|
|
|
|
};
|
|
|
|
|
2005-02-18 13:47:17 +00:00
|
|
|
if(!$exe) {
|
|
|
|
# not specified, guess!
|
2004-09-15 13:20:49 +00:00
|
|
|
if($target =~ /(recorder|ondio)/i) {
|
2004-06-14 15:04:46 +00:00
|
|
|
$exe = "ajbrec.ajz";
|
|
|
|
}
|
2005-01-31 19:33:39 +00:00
|
|
|
elsif($target =~ /iriver/i) {
|
|
|
|
$exe = "rockbox.iriver";
|
|
|
|
}
|
2005-02-11 11:48:27 +00:00
|
|
|
elsif($target =~ /gmini/i) {
|
|
|
|
$exe = "rockbox.gmini";
|
|
|
|
}
|
2004-06-14 15:04:46 +00:00
|
|
|
else {
|
|
|
|
$exe = "archos.mod";
|
|
|
|
}
|
|
|
|
}
|
2005-03-03 22:31:30 +00:00
|
|
|
elsif($exe =~ /rockboxui/) {
|
|
|
|
# simulator, exclude the exe file
|
|
|
|
$exe = "";
|
|
|
|
}
|
2004-06-14 15:04:46 +00:00
|
|
|
|
2004-09-16 21:18:35 +00:00
|
|
|
if($target =~ /player/i) {
|
|
|
|
runone("player", $exe);
|
2004-05-21 19:05:27 +00:00
|
|
|
}
|
|
|
|
else {
|
2004-09-16 21:18:35 +00:00
|
|
|
runone("recorder", $exe);
|
2004-05-21 19:05:27 +00:00
|
|
|
}
|
|
|
|
|