3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
13 use File
::Copy
; # For move() and copy()
14 use File
::Find
; # For find()
15 use File
::Path
qw(mkpath rmtree); # For rmtree()
17 use Getopt
::Long
qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
21 my $ziptool="zip -r9";
22 my $output="rockbox.zip";
29 my $target_id; # passed in, not currently used
30 my $rbdir=".rockbox"; # can be changed for special builds
36 mkpath
($dir, $verbose, 0777);
41 my ($_src, $dest, $opts) = @_;
47 foreach my $src (glob($_src)) {
48 unless ( -d
$src || !(-e
$src)) {
49 system("install $opts \"$src\" \"$dest\"");
50 print "install $opts \"$src\" -> \"$dest\"\n" if $verbose;
57 my ($pattern, $destination) = @_;
58 print "glob_copy: $pattern -> $destination\n" if $verbose;
59 foreach my $path (glob($pattern)) {
60 copy
($path, $destination);
65 my ($pattern, $destination) = @_;
66 print "glob_move: $pattern -> $destination\n" if $verbose;
67 foreach my $path (glob($pattern)) {
68 move
($path, $destination);
74 print "glob_unlink: $pattern\n" if $verbose;
75 foreach my $path (glob($pattern)) {
81 my ($pattern, $destination) = @_;
82 print "find_copyfile: $pattern -> $destination\n" if $verbose;
85 if ($path =~ $pattern && filesize
($path) > 0 && !($path =~ /$rbdir/)) {
86 copy
($path, $destination);
87 print "cp $path $destination\n" if $verbose;
88 chmod(0755, $destination.'/'.$path);
93 sub find_installfile
{
94 my ($pattern, $destination) = @_;
95 print "find_installfile: $pattern -> $destination\n" if $verbose;
98 if ($path =~ $pattern) {
99 print "FIND_INSTALLFILE: $path\n";
100 glob_install
($path, $destination);
107 my ($src, $dest) = @_;
113 my @plugins = ( "games", "apps", "demos", "viewers" );
114 my @userstuff = ( "backdrops", "codepages", "docs", "fonts", "langs", "themes", "wps", "eqs", "icons" );
119 $libdir .= "/lib/rockbox";
120 $userdir .= "/share/rockbox";
122 # for non-app builds we expect the prefix to be the dir above .rockbox
123 $bindir .= "/.rockbox";
124 $libdir = $userdir = $bindir;
126 if ($dest =~ /\/dev\
/null/) {
127 die "ERROR: No PREFIX given\n"
130 if ((!$app) && $src && (abs_path
($dest) eq abs_path
($src))) {
135 unless ($exe eq "") {
136 unless (glob_mkdir
($bindir)) {
139 glob_install
($exe, $bindir, "-m 0775");
143 unless (glob_mkdir
("$libdir/codecs")) {
146 glob_install
("$src/codecs/*", "$libdir/codecs");
149 unless (glob_mkdir
("$libdir/rocks")) {
152 foreach my $t (@plugins) {
153 unless (glob_mkdir
("$libdir/rocks/$t")) {
156 glob_install
("$src/rocks/$t/*", "$libdir/rocks/$t");
160 unless (glob_mkdir
("$libdir/rocks/viewers/lua")) {
163 glob_install
("$src/rocks/viewers/lua/*", "$libdir/rocks/viewers/lua");
165 # all the rest directories
166 foreach my $t (@userstuff) {
167 unless (glob_mkdir
("$userdir/$t")) {
170 glob_install
("$src/$t/*", "$userdir/$t");
173 # wps/ subfolders and bitmaps
174 opendir(DIR
, $src . "/wps");
175 @files = readdir(DIR
);
178 foreach my $_dir (@files) {
179 my $dir = "wps/" . $_dir;
180 if ( -d
"$src/$dir" && $_dir !~ /\
.\
.?
/) {
181 unless (glob_mkdir
("$userdir/$dir")) {
184 glob_install
("$src/$dir/*", "$userdir/$dir");
188 # rest of the files, excluding the binary
190 @files = readdir(DIR
);
193 foreach my $file (grep (/[a-zA-Z]+\.(txt|config|ignnore)/,@files)) {
194 glob_install
("$src/$file", "$userdir/");
200 GetOptions
( 'r|root=s' => \
$ROOT,
201 'z|ziptool=s' => \
$ziptool,
202 'm|modelname=s' => \
$modelname, # The model name as used in ARCHOS in the root makefile
203 'i|id=s' => \
$target_id, # The target id name as used in TARGET_ID in the root makefile
204 'o|output=s' => \
$output,
205 'f|fonts=s' => \
$incfonts, # 0 - no fonts, 1 - fonts only 2 - fonts and package
206 'v|verbose' => \
$verbose,
207 'install=s' => \
$install, # install destination
208 'rbdir=s' => \
$rbdir, # If we want to put in a different directory
211 ($target, $exe) = @ARGV;
213 my $firmdir="$ROOT/firmware";
214 my $appsdir="$ROOT/apps";
215 my $viewer_bmpdir="$ROOT/apps/plugins/bitmaps/viewer_defaults";
217 my $cppdef = $target;
220 open(GCC
, ">gcctemp");
221 # Get the LCD screen depth and graphical status
224 #ifdef HAVE_LCD_BITMAP
228 LCD Height: LCD_HEIGHT
229 Icon Width: CONFIG_DEFAULT_ICON_WIDTH
230 Icon Height: CONFIG_DEFAULT_ICON_HEIGHT
233 #ifdef HAVE_REMOTE_LCD
234 Remote Depth: LCD_REMOTE_DEPTH
235 Remote Icon Width: CONFIG_REMOTE_DEFAULT_ICON_WIDTH
236 Remote Icon Height: CONFIG_REMOTE_DEFAULT_ICON_HEIGHT
240 #ifdef HAVE_RECORDING
247 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
249 # print STDERR "CMD $c\n";
253 my ($bitmap, $width, $height, $depth, $swcodec, $icon_h, $icon_w);
254 my ($remote_depth, $remote_icon_h, $remote_icon_w);
258 # print STDERR "DATA: $_";
259 if($_ =~ /^Bitmap: (.*)/) {
262 elsif($_ =~ /^Depth: (\d*)/) {
265 elsif($_ =~ /^LCD Width: (\d*)/) {
268 elsif($_ =~ /^LCD Height: (\d*)/) {
271 elsif($_ =~ /^Icon Width: (\d*)/) {
274 elsif($_ =~ /^Icon Height: (\d*)/) {
277 elsif($_ =~ /^Codec: (\d*)/) {
278 # SWCODEC is 1, the others are HWCODEC
279 $swcodec = ($1 == 1);
281 elsif($_ =~ /^Remote Depth: (\d*)/) {
284 elsif($_ =~ /^Remote Icon Width: (\d*)/) {
287 elsif($_ =~ /^Remote Icon Height: (\d*)/) {
290 if($_ =~ /^Recording: (.*)/) {
297 return ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
298 $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h);
303 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
304 $atime,$mtime,$ctime,$blksize,$blocks)
310 my ($image, $fonts)=@_;
311 my $libdir = $install;
312 my $temp_dir = ".rockbox";
314 print "buildzip: image=$image fonts=$fonts\n" if $verbose;
316 my ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
317 $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h) =
320 # print "Bitmap: $bitmap\nDepth: $depth\nSwcodec: $swcodec\n";
325 glob_mkdir
($temp_dir);
328 # always disable fonts on non-bitmap targets
332 glob_mkdir
("$temp_dir/fonts");
333 chdir "$temp_dir/fonts";
334 my $cmd = "$ROOT/tools/convbdf -f $ROOT/fonts/*bdf >/dev/null 2>&1";
335 print($cmd."\n") if $verbose;
340 # fonts-only package, return
345 # create the file so the database does not try indexing a folder
346 open(IGNORE
, ">$temp_dir/database.ignore") || die "can't open database.ignore";
349 glob_mkdir
("$temp_dir/langs");
350 glob_mkdir
("$temp_dir/rocks");
351 glob_mkdir
("$temp_dir/rocks/games");
352 glob_mkdir
("$temp_dir/rocks/apps");
353 glob_mkdir
("$temp_dir/rocks/demos");
354 glob_mkdir
("$temp_dir/rocks/viewers");
357 glob_mkdir
("$temp_dir/recpresets");
361 glob_mkdir
("$temp_dir/eqs");
363 glob_copy
("$ROOT/apps/eqs/*.cfg", "$temp_dir/eqs/"); # equalizer presets
366 glob_mkdir
("$temp_dir/wps");
367 glob_mkdir
("$temp_dir/themes");
369 open(THEME
, ">$temp_dir/themes/rockbox_default_icons.cfg");
371 # this config file was auto-generated to make it
372 # easy to reset the icons back to default
374 # taken from apps/gui/icon.c
375 viewers iconset: /$rbdir/icons/viewers.bmp
377 # taken from apps/gui/icon.c
378 remote viewers iconset: /$rbdir/icons/remote_viewers.bmp
385 glob_mkdir
("$temp_dir/codepages");
388 system("$ROOT/tools/codepages");
391 system("$ROOT/tools/codepages -m");
394 glob_move
('*.cp', "$temp_dir/codepages/");
396 if($bitmap && $depth > 1) {
397 glob_mkdir
("$temp_dir/backdrops");
400 glob_mkdir
("$temp_dir/codecs");
402 find
(find_copyfile
(qr/.*\.codec/, abs_path
("$temp_dir/codecs/")), 'apps/codecs');
404 # remove directory again if no codec was copied
405 rmdir("$temp_dir/codecs");
407 find
(find_copyfile
(qr/\.(rock|ovl|lua)/, abs_path
("$temp_dir/rocks/")), 'apps/plugins');
409 open VIEWERS
, "$ROOT/apps/plugins/viewers.config" or
410 die "can't open viewers.config";
411 my @viewers = <VIEWERS
>;
414 open VIEWERS
, ">$temp_dir/viewers.config" or
415 die "can't create $temp_dir/viewers.config";
417 foreach my $line (@viewers) {
418 if ($line =~ /([^,]*),([^,]*),/) {
419 my ($ext, $plugin)=($1, $2);
420 my $r = "${plugin}.rock";
426 # strip off the last slash and file name part
427 $dir =~ s/(.*)\/(.*)/$1/;
428 # store the file name part
431 # get .ovl name (file part only)
433 $oname =~ s/\.rock$/.ovl/;
435 # print STDERR "$ext $plugin $dir $name $r\n";
437 if(-e
"$temp_dir/rocks/$name") {
438 if($dir ne "rocks") {
439 # target is not 'rocks' but the plugins are always in that
441 move
("$temp_dir/rocks/$name", "$temp_dir/rocks/$r");
445 elsif(-e
"$temp_dir/rocks/$r") {
446 # in case the same plugin works for multiple extensions, it
447 # was already moved to the viewers dir
451 if(-e
"$temp_dir/rocks/$oname") {
452 # if there's an "overlay" file for the .rock, move that as
454 move
("$temp_dir/rocks/$oname", "$temp_dir/rocks/$dir");
460 open CATEGORIES
, "$ROOT/apps/plugins/CATEGORIES" or
461 die "can't open CATEGORIES";
462 my @rock_targetdirs = <CATEGORIES
>;
464 foreach my $line (@rock_targetdirs) {
465 if ($line =~ /([^,]*),(.*)/) {
466 my ($plugin, $dir)=($1, $2);
467 move
("$temp_dir/rocks/${plugin}.rock", "$temp_dir/rocks/$dir/${plugin}.rock");
468 if(-e
"$temp_dir/rocks/${plugin}.ovl") {
469 # if there's an "overlay" file for the .rock, move that as
471 move
("$temp_dir/rocks/${plugin}.ovl", "$temp_dir/rocks/$dir");
473 if(-e
"$temp_dir/rocks/${plugin}.lua") {
474 # if this is a lua script, move it to the appropriate dir
475 move
("$temp_dir/rocks/${plugin}.lua", "$temp_dir/rocks/$dir/");
480 glob_unlink
("$temp_dir/rocks/*.lua"); # Clean up unwanted *.lua files (e.g. actions.lua, buttons.lua)
483 glob_mkdir
("$temp_dir/icons");
484 copy
("$viewer_bmpdir/viewers.${icon_w}x${icon_h}x$depth.bmp", "$temp_dir/icons/viewers.bmp");
486 copy
("$viewer_bmpdir/remote_viewers.${remote_icon_w}x${remote_icon_h}x$remote_depth.bmp", "$temp_dir/icons/remote_viewers.bmp");
490 copy
("$ROOT/apps/tagnavi.config", "$temp_dir/");
491 copy
("$ROOT/apps/plugins/disktidy.config", "$temp_dir/rocks/apps/");
494 copy
("$ROOT/apps/plugins/sokoban.levels", "$temp_dir/rocks/games/sokoban.levels"); # sokoban levels
495 copy
("$ROOT/apps/plugins/snake2.levels", "$temp_dir/rocks/games/snake2.levels"); # snake2 levels
496 copy
("$ROOT/apps/plugins/rockbox-fonts.config", "$temp_dir/rocks/viewers/");
499 if(-e
"$temp_dir/rocks/demos/pictureflow.rock") {
500 copy
("$ROOT/apps/plugins/bitmaps/native/pictureflow_emptyslide.100x100x16.bmp",
501 "$temp_dir/rocks/demos/pictureflow_emptyslide.bmp");
504 $pf_logo = "pictureflow_logo.100x18x16.bmp";
506 $pf_logo = "pictureflow_logo.193x34x16.bmp";
508 copy
("$ROOT/apps/plugins/bitmaps/native/$pf_logo",
509 "$temp_dir/rocks/demos/pictureflow_splash.bmp");
514 # image is blank when this is a simulator
515 if( filesize
("rockbox.ucl") > 1000 ) {
516 copy
("rockbox.ucl", "$temp_dir/rockbox.ucl"); # UCL for flashing
518 if( filesize
("rombox.ucl") > 1000) {
519 copy
("rombox.ucl", "$temp_dir/rombox.ucl"); # UCL for flashing
522 # Check for rombox.target
523 if ($image=~/(.*)\.(\w+)$/)
525 my $romfile = "rombox.$2";
526 if (filesize
($romfile) > 1000)
528 copy
($romfile, "$temp_dir/$romfile");
533 glob_mkdir
("$temp_dir/docs");
538 copy
("$ROOT/docs/$_", "$temp_dir/docs/$_.txt");
541 copy
("$ROOT/docs/profontdoc.txt", "$temp_dir/docs/profontdoc.txt");
543 for(("sample.colours",
546 copy
("$ROOT/docs/$_", "$temp_dir/docs/$_");
549 # Now do the WPS dance
551 my $wps_build_cmd="perl $ROOT/wps/wpsbuild.pl ";
552 $wps_build_cmd=$wps_build_cmd."-v " if $verbose;
553 $wps_build_cmd=$wps_build_cmd." --rbdir=$rbdir -r $ROOT -m $modelname $ROOT/wps/WPSLIST $target";
554 print "wpsbuild: $wps_build_cmd\n" if $verbose;
555 system("$wps_build_cmd");
556 print "wps_build_cmd: done\n" if $verbose;
559 print STDERR
"No wps module present, can't do the WPS magic!\n";
562 # until buildwps.pl is fixed, manually copy the classic_statusbar theme across
563 mkdir "$temp_dir/wps/classic_statusbar", 0777;
564 glob_copy
("$ROOT/wps/classic_statusbar/*.bmp", "$temp_dir/wps/classic_statusbar");
567 copy
("$ROOT/wps/classic_statusbar.sbs", "$temp_dir/wps");
568 } elsif ($depth > 1) {
569 copy
("$ROOT/wps/classic_statusbar.grey.sbs", "$temp_dir/wps/classic_statusbar.sbs");
571 copy
("$ROOT/wps/classic_statusbar.mono.sbs", "$temp_dir/wps/classic_statusbar.sbs");
574 copy
("$ROOT/wps/classic_statusbar.112x64x1.sbs", "$temp_dir/wps/classic_statusbar.sbs");
576 system("touch $temp_dir/wps/rockbox_none.sbs");
577 if ($remote_depth != $depth) {
578 copy
("$ROOT/wps/classic_statusbar.mono.sbs", "$temp_dir/wps/classic_statusbar.rsbs");
580 copy
("$temp_dir/wps/classic_statusbar.sbs", "$temp_dir/wps/classic_statusbar.rsbs");
582 copy
("$temp_dir/wps/rockbox_none.sbs", "$temp_dir/wps/rockbox_none.rsbs");
585 copy
("rockbox-info.txt", "$temp_dir/rockbox-info.txt");
587 # copy the already built lng files
588 glob_copy
('apps/lang/*lng', "$temp_dir/langs/");
590 # copy the .lua files
591 glob_mkdir
("$temp_dir/rocks/viewers/lua/");
592 glob_copy
('apps/plugins/lua/*.lua', "$temp_dir/rocks/viewers/lua/");
595 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
601 #$date=sprintf("%04d%02d%02d", $year,$mon, $mday);
602 #$shortdate=sprintf("%02d%02d%02d", $year%100,$mon, $mday);
604 # made once for all targets
606 my ($target, $fonts)=@_;
608 # in the app the the layout is different (no .rockbox, but bin/lib/share)
609 $app = ($modelname eq "application");
611 # build a full install .rockbox ($rbdir) directory
612 buildzip
($target, $fonts);
617 # Don't include image file in fonts-only package
620 if($target && ($target !~ /(mod|ajz|wma)\z/i)) {
621 # On some targets, the image goes into .rockbox.
622 copy
("$target", "$rbdir/$target");
627 make_install
(".rockbox", $install) or die "MKDIRFAILED\n";
630 unless (".rockbox" eq $rbdir) {
631 move
(".rockbox", $rbdir);
632 print "mv .rockbox $rbdir\n" if $verbose;
634 system("$ziptool $output $rbdir $target >/dev/null");
635 print "$ziptool $output $rbdir $target >/dev/null\n" if $verbose;
638 print "rm .rockbox\n" if $verbose;
642 # not specified, guess!
643 if($target =~ /(recorder|ondio)/i) {
646 elsif($target =~ /iriver/i) {
647 $exe = "rockbox.iriver";
653 elsif(($exe =~ /rockboxui/)) {
654 # simulator, exclude the exe file
658 runone
($exe, $incfonts);