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()
18 use Getopt
::Long
qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF
30 my $target_id; # passed in, not currently used
31 my $rbdir; # can be non-.rockbox for special builds
37 mkpath
($dir, $verbose, 0777);
42 my ($_src, $dest, $opts) = @_;
48 foreach my $src (glob($_src)) {
49 unless ( -d
$src || !(-e
$src)) {
50 system("install $opts \"$src\" \"$dest\"");
51 print "install $opts \"$src\" -> \"$dest\"\n" if $verbose;
58 my ($pattern, $destination) = @_;
59 print "glob_copy: $pattern -> $destination\n" if $verbose;
60 foreach my $path (glob($pattern)) {
61 copy
($path, $destination);
66 my ($pattern, $destination) = @_;
67 print "glob_move: $pattern -> $destination\n" if $verbose;
68 foreach my $path (glob($pattern)) {
69 move
($path, $destination);
75 print "glob_unlink: $pattern\n" if $verbose;
76 foreach my $path (glob($pattern)) {
82 my ($pattern, $destination) = @_;
83 print "find_copyfile: $pattern -> $destination\n" if $verbose;
86 my $source = getcwd
();
87 if ($path =~ $pattern && filesize
($path) > 0 && !($path =~ /$rbdir/)) {
89 print "link $path $destination\n" if $verbose;
90 symlink($source.'/'.$path, $destination.'/'.$path);
92 print "cp $path $destination\n" if $verbose;
93 copy
($path, $destination);
94 chmod(0755, $destination.'/'.$path);
100 sub find_installfile
{
101 my ($pattern, $destination) = @_;
102 print "find_installfile: $pattern -> $destination\n" if $verbose;
105 if ($path =~ $pattern) {
106 print "FIND_INSTALLFILE: $path\n";
107 glob_install
($path, $destination);
114 my ($src, $dest) = @_;
120 my @plugins = ( "games", "apps", "demos", "viewers" );
121 my @userstuff = ( "backdrops", "codepages", "docs", "fonts", "langs", "themes", "wps", "eqs", "icons" );
126 $libdir .= "/lib/rockbox";
127 $userdir .= "/share/rockbox";
129 # for non-app builds we expect the prefix to be the dir above .rockbox
130 $bindir .= "/$rbdir";
131 $libdir = $userdir = $bindir;
133 if ($dest =~ /\/dev\
/null/) {
134 die "ERROR: No PREFIX given\n"
137 if ((!$app) && -e
$bindir && -e
$src && (abs_path
($bindir) eq abs_path
($src))) {
142 unless ($exe eq "") {
143 unless (glob_mkdir
($bindir)) {
146 glob_install
($exe, $bindir, "-m 0775");
150 unless (glob_mkdir
("$libdir/codecs")) {
153 # Android has codecs installed as native libraries so they are not needed
155 if ($modelname !~ /android/) {
156 glob_install
("$src/codecs/*", "$libdir/codecs", "-m 0755");
160 unless (glob_mkdir
("$libdir/rocks")) {
163 foreach my $t (@plugins) {
164 unless (glob_mkdir
("$libdir/rocks/$t")) {
167 glob_install
("$src/rocks/$t/*", "$libdir/rocks/$t", "-m 0755");
171 unless (glob_mkdir
("$libdir/rocks/viewers/lua")) {
174 glob_install
("$src/rocks/viewers/lua/*", "$libdir/rocks/viewers/lua");
176 # all the rest directories
177 foreach my $t (@userstuff) {
178 unless (glob_mkdir
("$userdir/$t")) {
181 glob_install
("$src/$t/*", "$userdir/$t");
184 # wps/ subfolders and bitmaps
185 opendir(DIR
, $src . "/wps");
186 @files = readdir(DIR
);
189 foreach my $_dir (@files) {
190 my $dir = "wps/" . $_dir;
191 if ( -d
"$src/$dir" && $_dir !~ /\
.\
.?
/) {
192 unless (glob_mkdir
("$userdir/$dir")) {
195 glob_install
("$src/$dir/*", "$userdir/$dir");
199 # rest of the files, excluding the binary
201 @files = readdir(DIR
);
204 foreach my $file (grep (/[a-zA-Z]+\.(txt|config|ignnore)/,@files)) {
205 glob_install
("$src/$file", "$userdir/");
211 GetOptions
( 'r|root=s' => \
$ROOT,
212 'z|ziptool:s' => \
$ziptool,
213 'm|modelname=s' => \
$modelname, # The model name as used in ARCHOS in the root makefile
214 'i|id=s' => \
$target_id, # The target id name as used in TARGET_ID in the root makefile
215 'o|output:s' => \
$output,
216 'f|fonts=s' => \
$incfonts, # 0 - no fonts, 1 - fonts only 2 - fonts and package
217 'v|verbose' => \
$verbose,
218 'install=s' => \
$install, # install destination
219 'rbdir:s' => \
$rbdir, # If we want to put in a different directory
220 'l|link' => \
$mklinks, # If we want to create links instead of copying files
221 'a|app:s' => \
$app, # Is this an Application build?
224 # GetOptions() doesn't remove the params from @ARGV if their value was ""
225 # Thus we use the ":" for those for which we use a default value in case of ""
226 # and assign the default value afterwards
227 if ($ziptool eq '') {
228 $ziptool = "zip -r9";
231 $output = "rockbox.zip"
237 # Now @ARGV shuold be free of any left-overs GetOptions left
238 ($target, $exe) = @ARGV;
240 my $firmdir="$ROOT/firmware";
241 my $appsdir="$ROOT/apps";
242 my $viewer_bmpdir="$ROOT/apps/plugins/bitmaps/viewer_defaults";
244 my $cppdef = $target;
247 open(GCC
, ">gcctemp");
248 # Get the LCD screen depth and graphical status
251 #ifdef HAVE_LCD_BITMAP
255 LCD Height: LCD_HEIGHT
256 Icon Width: CONFIG_DEFAULT_ICON_WIDTH
257 Icon Height: CONFIG_DEFAULT_ICON_HEIGHT
260 #ifdef HAVE_REMOTE_LCD
261 Remote Depth: LCD_REMOTE_DEPTH
262 Remote Icon Width: CONFIG_REMOTE_DEFAULT_ICON_WIDTH
263 Remote Icon Height: CONFIG_REMOTE_DEFAULT_ICON_HEIGHT
267 #ifdef HAVE_RECORDING
274 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
276 # print STDERR "CMD $c\n";
280 my ($bitmap, $width, $height, $depth, $swcodec, $icon_h, $icon_w);
281 my ($remote_depth, $remote_icon_h, $remote_icon_w);
285 # print STDERR "DATA: $_";
286 if($_ =~ /^Bitmap: (.*)/) {
289 elsif($_ =~ /^Depth: (\d*)/) {
292 elsif($_ =~ /^LCD Width: (\d*)/) {
295 elsif($_ =~ /^LCD Height: (\d*)/) {
298 elsif($_ =~ /^Icon Width: (\d*)/) {
301 elsif($_ =~ /^Icon Height: (\d*)/) {
304 elsif($_ =~ /^Codec: (\d*)/) {
305 # SWCODEC is 1, the others are HWCODEC
306 $swcodec = ($1 == 1);
308 elsif($_ =~ /^Remote Depth: (\d*)/) {
311 elsif($_ =~ /^Remote Icon Width: (\d*)/) {
314 elsif($_ =~ /^Remote Icon Height: (\d*)/) {
317 if($_ =~ /^Recording: (.*)/) {
324 return ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
325 $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h);
330 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
331 $atime,$mtime,$ctime,$blksize,$blocks)
336 sub create_failsafefiles
{
337 my ($dir, $remote_depth) = @_;
338 my $text = "# Dummy file to allow Rockbox to reset to the default skin config.
339 # Do not edit this file. It's never actually loaded by Rockbox.";
340 open (FOO
, ">$dir/wps/rockbox_failsafe.wps");
343 open (FOO
, ">$dir/wps/rockbox_failsafe.sbs");
346 open (FOO
, ">$dir/wps/rockbox_failsafe.fms");
350 open (FOO
, ">$dir/wps/rockbox_failsafe.rwps");
353 open (FOO
, ">$dir/wps/rockbox_failsafe.rsbs");
356 open (FOO
, ">$dir/wps/rockbox_failsafe.rfms");
360 open (FOO
, ">$dir/themes/rockbox_failsafe.cfg");
362 # This config has been autogenerated to reload the failsafe setup
363 wps: $dir/wps/rockbox_failsafe.wps
364 sbs: $dir/wps/rockbox_failsafe.sbs
365 fms: $dir/wps/rockbox_failsafe.fms
370 rwps: $dir/wps/rockbox_failsafe.rwps
371 rsbs: $dir/wps/rockbox_failsafe.rsbs
372 rfms: $dir/wps/rockbox_failsafe.rfms
378 font: 08-Schumacher-Clean.fnt
379 foreground color: 000000
380 background color: B6C6E5
381 selector type: bar (inverse)
388 my ($image, $fonts)=@_;
389 my $libdir = $install;
390 my $temp_dir = ".rockbox";
392 print "buildzip: image=$image fonts=$fonts\n" if $verbose;
394 my ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
395 $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h) =
398 # print "Bitmap: $bitmap\nDepth: $depth\nSwcodec: $swcodec\n";
403 glob_mkdir
($temp_dir);
406 # always disable fonts on non-bitmap targets
410 glob_mkdir
("$temp_dir/fonts");
411 chdir "$temp_dir/fonts";
412 my $cmd = "$ROOT/tools/convbdf -f $ROOT/fonts/*bdf >/dev/null 2>&1";
413 print($cmd."\n") if $verbose;
418 # fonts-only package, return
423 # create the file so the database does not try indexing a folder
424 open(IGNORE
, ">$temp_dir/database.ignore") || die "can't open database.ignore";
427 glob_mkdir
("$temp_dir/langs");
428 glob_mkdir
("$temp_dir/rocks");
429 glob_mkdir
("$temp_dir/rocks/games");
430 glob_mkdir
("$temp_dir/rocks/apps");
431 glob_mkdir
("$temp_dir/rocks/demos");
432 glob_mkdir
("$temp_dir/rocks/viewers");
435 glob_mkdir
("$temp_dir/recpresets");
439 glob_mkdir
("$temp_dir/eqs");
441 glob_copy
("$ROOT/apps/eqs/*.cfg", "$temp_dir/eqs/"); # equalizer presets
444 glob_mkdir
("$temp_dir/wps");
445 glob_mkdir
("$temp_dir/themes");
447 open(THEME
, ">$temp_dir/themes/rockbox_default_icons.cfg");
449 # this config file was auto-generated to make it
450 # easy to reset the icons back to default
452 # taken from apps/gui/icon.c
453 viewers iconset: /$rbdir/icons/viewers.bmp
455 # taken from apps/gui/icon.c
456 remote viewers iconset: /$rbdir/icons/remote_viewers.bmp
463 glob_mkdir
("$temp_dir/codepages");
466 system("$ROOT/tools/codepages");
469 system("$ROOT/tools/codepages -m");
472 glob_move
('*.cp', "$temp_dir/codepages/");
474 if($bitmap && $depth > 1) {
475 glob_mkdir
("$temp_dir/backdrops");
478 glob_mkdir
("$temp_dir/codecs");
480 # Android has codecs installed as native libraries so they are not needed
482 if ($modelname !~ /android/) {
483 find
(find_copyfile
(qr/.*\.codec/, abs_path
("$temp_dir/codecs/")), 'apps/codecs');
486 # remove directory again if no codec was copied
487 rmdir("$temp_dir/codecs");
489 find
(find_copyfile
(qr/\.(rock|ovl|lua)/, abs_path
("$temp_dir/rocks/")), 'apps/plugins');
491 # exclude entries for the image file types not supported by the imageviewer for the target.
492 my $viewers = "$ROOT/apps/plugins/viewers.config";
493 my $c="cat $viewers | gcc $cppdef -I. -I$firmdir/export -E -P -include config.h -";
495 open VIEWERS
, "$c|" or die "can't open viewers.config";
496 my @viewers = <VIEWERS
>;
499 open VIEWERS
, ">$temp_dir/viewers.config" or
500 die "can't create $temp_dir/viewers.config";
502 foreach my $line (@viewers) {
503 if ($line =~ /([^,]*),([^,]*),/) {
504 my ($ext, $plugin)=($1, $2);
505 my $r = "${plugin}.rock";
511 # strip off the last slash and file name part
512 $dir =~ s/(.*)\/(.*)/$1/;
513 # store the file name part
516 # get .ovl name (file part only)
518 $oname =~ s/\.rock$/.ovl/;
520 # print STDERR "$ext $plugin $dir $name $r\n";
522 if(-e
"$temp_dir/rocks/$name") {
523 if($dir ne "rocks") {
524 # target is not 'rocks' but the plugins are always in that
526 move
("$temp_dir/rocks/$name", "$temp_dir/rocks/$r");
530 elsif(-e
"$temp_dir/rocks/$r") {
531 # in case the same plugin works for multiple extensions, it
532 # was already moved to the viewers dir
536 if(-e
"$temp_dir/rocks/$oname") {
537 # if there's an "overlay" file for the .rock, move that as
539 move
("$temp_dir/rocks/$oname", "$temp_dir/rocks/$dir");
545 open CATEGORIES
, "$ROOT/apps/plugins/CATEGORIES" or
546 die "can't open CATEGORIES";
547 my @rock_targetdirs = <CATEGORIES
>;
549 foreach my $line (@rock_targetdirs) {
550 if ($line =~ /([^,]*),(.*)/) {
551 my ($plugin, $dir)=($1, $2);
552 move
("$temp_dir/rocks/${plugin}.rock", "$temp_dir/rocks/$dir/${plugin}.rock");
553 if(-e
"$temp_dir/rocks/${plugin}.ovl") {
554 # if there's an "overlay" file for the .rock, move that as
556 move
("$temp_dir/rocks/${plugin}.ovl", "$temp_dir/rocks/$dir");
558 if(-e
"$temp_dir/rocks/${plugin}.lua") {
559 # if this is a lua script, move it to the appropriate dir
560 move
("$temp_dir/rocks/${plugin}.lua", "$temp_dir/rocks/$dir/");
565 glob_unlink
("$temp_dir/rocks/*.lua"); # Clean up unwanted *.lua files (e.g. actions.lua, buttons.lua)
568 glob_mkdir
("$temp_dir/icons");
569 copy
("$viewer_bmpdir/viewers.${icon_w}x${icon_h}x$depth.bmp", "$temp_dir/icons/viewers.bmp");
571 copy
("$viewer_bmpdir/remote_viewers.${remote_icon_w}x${remote_icon_h}x$remote_depth.bmp", "$temp_dir/icons/remote_viewers.bmp");
575 copy
("$ROOT/apps/tagnavi.config", "$temp_dir/");
576 copy
("$ROOT/apps/plugins/disktidy.config", "$temp_dir/rocks/apps/");
579 copy
("$ROOT/apps/plugins/sokoban.levels", "$temp_dir/rocks/games/sokoban.levels"); # sokoban levels
580 copy
("$ROOT/apps/plugins/snake2.levels", "$temp_dir/rocks/games/snake2.levels"); # snake2 levels
581 copy
("$ROOT/apps/plugins/rockbox-fonts.config", "$temp_dir/rocks/viewers/");
584 if(-e
"$temp_dir/rocks/demos/pictureflow.rock") {
585 copy
("$ROOT/apps/plugins/bitmaps/native/pictureflow_emptyslide.100x100x16.bmp",
586 "$temp_dir/rocks/demos/pictureflow_emptyslide.bmp");
589 $pf_logo = "pictureflow_logo.100x18x16.bmp";
591 $pf_logo = "pictureflow_logo.193x34x16.bmp";
593 copy
("$ROOT/apps/plugins/bitmaps/native/$pf_logo",
594 "$temp_dir/rocks/demos/pictureflow_splash.bmp");
597 create_failsafefiles
($temp_dir, $remote_depth);
600 # image is blank when this is a simulator
601 if( filesize
("rockbox.ucl") > 1000 ) {
602 copy
("rockbox.ucl", "$temp_dir/rockbox.ucl"); # UCL for flashing
604 if( filesize
("rombox.ucl") > 1000) {
605 copy
("rombox.ucl", "$temp_dir/rombox.ucl"); # UCL for flashing
608 # Check for rombox.target
609 if ($image=~/(.*)\.(\w+)$/)
611 my $romfile = "rombox.$2";
612 if (filesize
($romfile) > 1000)
614 copy
($romfile, "$temp_dir/$romfile");
619 glob_mkdir
("$temp_dir/docs");
624 copy
("$ROOT/docs/$_", "$temp_dir/docs/$_.txt");
627 copy
("$ROOT/docs/profontdoc.txt", "$temp_dir/docs/profontdoc.txt");
629 for(("sample.colours",
632 copy
("$ROOT/docs/$_", "$temp_dir/docs/$_");
635 # Now do the WPS dance
637 my $wps_build_cmd="perl $ROOT/wps/wpsbuild.pl ";
638 $wps_build_cmd=$wps_build_cmd."-v " if $verbose;
639 $wps_build_cmd=$wps_build_cmd." --tempdir=$temp_dir --rbdir=$rbdir -r $ROOT -m $modelname $ROOT/wps/WPSLIST $target";
640 print "wpsbuild: $wps_build_cmd\n" if $verbose;
641 system("$wps_build_cmd");
642 print "wps_build_cmd: done\n" if $verbose;
645 print STDERR
"No wps module present, can't do the WPS magic!\n";
648 # until buildwps.pl is fixed, manually copy the classic_statusbar theme across
649 mkdir "$temp_dir/wps/classic_statusbar", 0777;
650 glob_copy
("$ROOT/wps/classic_statusbar/*.bmp", "$temp_dir/wps/classic_statusbar");
653 copy
("$ROOT/wps/classic_statusbar.sbs", "$temp_dir/wps");
654 } elsif ($depth > 1) {
655 copy
("$ROOT/wps/classic_statusbar.grey.sbs", "$temp_dir/wps/classic_statusbar.sbs");
657 copy
("$ROOT/wps/classic_statusbar.mono.sbs", "$temp_dir/wps/classic_statusbar.sbs");
660 copy
("$ROOT/wps/classic_statusbar.112x64x1.sbs", "$temp_dir/wps/classic_statusbar.sbs");
662 if ($remote_depth != $depth) {
663 copy
("$ROOT/wps/classic_statusbar.mono.sbs", "$temp_dir/wps/classic_statusbar.rsbs");
665 copy
("$temp_dir/wps/classic_statusbar.sbs", "$temp_dir/wps/classic_statusbar.rsbs");
667 copy
("$temp_dir/wps/rockbox_none.sbs", "$temp_dir/wps/rockbox_none.rsbs");
670 copy
("rockbox-info.txt", "$temp_dir/rockbox-info.txt");
672 # copy the already built lng files
673 glob_copy
('apps/lang/*lng', "$temp_dir/langs/");
675 # copy the .lua files
676 glob_mkdir
("$temp_dir/rocks/viewers/lua/");
677 glob_copy
('apps/plugins/lua/*.lua', "$temp_dir/rocks/viewers/lua/");
680 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
686 #$date=sprintf("%04d%02d%02d", $year,$mon, $mday);
687 #$shortdate=sprintf("%02d%02d%02d", $year%100,$mon, $mday);
689 # made once for all targets
691 my ($target, $fonts)=@_;
693 # Strip the leading / from $rbdir unless we are installing an application
694 # build - the layout is different (no .rockbox, but bin/lib/share)
695 unless ($app && $install) {
696 $rbdir = substr($rbdir, 1);
699 # build a full install .rockbox ($rbdir) directory
700 buildzip
($target, $fonts);
705 # Don't include image file in fonts-only package
708 if($target && ($target !~ /(mod|ajz|wma)\z/i)) {
709 # On some targets, the image goes into .rockbox.
710 copy
("$target", ".rockbox/$target");
717 symlink("$cwd/.rockbox", "$install/.rockbox");
718 print "link .rockbox $install\n" if $verbose;
720 make_install
(".rockbox", $install) or die "MKDIRFAILED\n";
722 print "rm .rockbox\n" if $verbose;
726 unless (".rockbox" eq $rbdir) {
729 move
(".rockbox", $rbdir);
730 print "mv .rockbox $rbdir\n" if $verbose;
732 system("$ziptool $output $rbdir $target >/dev/null");
733 print "$ziptool $output $rbdir $target >/dev/null\n" if $verbose;
735 print "rm $rbdir\n" if $verbose;
740 # not specified, guess!
741 if($target =~ /(recorder|ondio)/i) {
744 elsif($target =~ /iriver/i) {
745 $exe = "rockbox.iriver";
751 elsif(($exe =~ /rockboxui/)) {
752 # simulator, exclude the exe file
755 elsif($exe eq "librockbox.so") {
756 # android, exclude the binary
760 runone
($exe, $incfonts);