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 ($pattern, $destination) = @_;
42 print "glob_copy: $pattern -> $destination\n" if $verbose;
43 foreach my $path (glob($pattern)) {
44 copy
($path, $destination);
49 my ($pattern, $destination) = @_;
50 print "glob_move: $pattern -> $destination\n" if $verbose;
51 foreach my $path (glob($pattern)) {
52 move
($path, $destination);
58 print "glob_unlink: $pattern\n" if $verbose;
59 foreach my $path (glob($pattern)) {
65 my ($pattern, $destination) = @_;
66 print "find_copyfile: $pattern -> $destination\n" if $verbose;
69 if ($path =~ $pattern && filesize
($path) > 0 && !($path =~ /$rbdir/)) {
70 copy
($path, $destination);
71 print "cp $path $destination\n" if $verbose;
72 chmod(0755, $destination.'/'.$path);
80 if ($dest =~ /\/dev\
/null/) {
81 die "ERROR: No PREFIX given\n"
84 my $samedir = abs_path
("$dest/$rbdir") eq abs_path
($rbdir);
87 unless (glob_mkdir
($dest . "/bin")) {
91 system("cp $exe $dest/bin/");
92 chmod(0755, "$dest/bin/$exe");
93 print "cp $exe $dest/bin/\n" if $verbose;
94 unless (glob_mkdir
($dest . "/lib/rockbox/codecs")) {
98 find
(find_copyfile
(qr/.*\.codec/, abs_path
("$dest/lib/rockbox/codecs/")), 'apps/codecs');
102 #~ system("mkdir -p \"$install\" && cp -vr $rbdir \"$dest/\"");
109 GetOptions
( 'r|root=s' => \
$ROOT,
110 'z|ziptool=s' => \
$ziptool,
111 'm|modelname=s' => \
$modelname, # The model name as used in ARCHOS in the root makefile
112 'i|id=s' => \
$target_id, # The target id name as used in TARGET_ID in the root makefile
113 'o|output=s' => \
$output,
114 'f|fonts=s' => \
$incfonts, # 0 - no fonts, 1 - fonts only 2 - fonts and package
115 'v|verbose' => \
$verbose,
116 'install=s' => \
$install, # install destination
117 'rbdir=s' => \
$rbdir, # If we want to put in a different directory
120 ($target, $exe) = @ARGV;
122 my $firmdir="$ROOT/firmware";
123 my $appsdir="$ROOT/apps";
124 my $viewer_bmpdir="$ROOT/apps/plugins/bitmaps/viewer_defaults";
126 my $cppdef = $target;
129 open(GCC
, ">gcctemp");
130 # Get the LCD screen depth and graphical status
133 #ifdef HAVE_LCD_BITMAP
137 LCD Height: LCD_HEIGHT
138 Icon Width: CONFIG_DEFAULT_ICON_WIDTH
139 Icon Height: CONFIG_DEFAULT_ICON_HEIGHT
142 #ifdef HAVE_REMOTE_LCD
143 Remote Depth: LCD_REMOTE_DEPTH
144 Remote Icon Width: CONFIG_REMOTE_DEFAULT_ICON_WIDTH
145 Remote Icon Height: CONFIG_REMOTE_DEFAULT_ICON_HEIGHT
149 #ifdef HAVE_RECORDING
156 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
158 # print STDERR "CMD $c\n";
162 my ($bitmap, $width, $height, $depth, $swcodec, $icon_h, $icon_w);
163 my ($remote_depth, $remote_icon_h, $remote_icon_w);
167 # print STDERR "DATA: $_";
168 if($_ =~ /^Bitmap: (.*)/) {
171 elsif($_ =~ /^Depth: (\d*)/) {
174 elsif($_ =~ /^LCD Width: (\d*)/) {
177 elsif($_ =~ /^LCD Height: (\d*)/) {
180 elsif($_ =~ /^Icon Width: (\d*)/) {
183 elsif($_ =~ /^Icon Height: (\d*)/) {
186 elsif($_ =~ /^Codec: (\d*)/) {
187 # SWCODEC is 1, the others are HWCODEC
188 $swcodec = ($1 == 1);
190 elsif($_ =~ /^Remote Depth: (\d*)/) {
193 elsif($_ =~ /^Remote Icon Width: (\d*)/) {
196 elsif($_ =~ /^Remote Icon Height: (\d*)/) {
199 if($_ =~ /^Recording: (.*)/) {
206 return ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
207 $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h);
212 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
213 $atime,$mtime,$ctime,$blksize,$blocks)
219 my ($image, $fonts)=@_;
220 my $libdir = $install;
222 print "buildzip: image=$image fonts=$fonts\n" if $verbose;
224 my ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
225 $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h) =
232 # print "Bitmap: $bitmap\nDepth: $depth\nSwcodec: $swcodec\n";
240 # always disable fonts on non-bitmap targets
244 glob_mkdir
("$rbdir/fonts");
245 chdir "$rbdir/fonts";
246 my $cmd = "$ROOT/tools/convbdf -f $ROOT/fonts/*bdf >/dev/null 2>&1";
247 print($cmd."\n") if $verbose;
252 # fonts-only package, return
257 # create the file so the database does not try indexing a folder
258 open(IGNORE
, ">$rbdir/database.ignore") || die "can't open database.ignore";
261 glob_mkdir
("$rbdir/langs");
262 glob_mkdir
("$rbdir/rocks");
263 glob_mkdir
("$rbdir/rocks/games");
264 glob_mkdir
("$rbdir/rocks/apps");
265 glob_mkdir
("$rbdir/rocks/demos");
266 glob_mkdir
("$rbdir/rocks/viewers");
269 glob_mkdir
("$rbdir/recpresets");
273 glob_mkdir
("$rbdir/eqs");
275 glob_copy
("$ROOT/apps/eqs/*.cfg", "$rbdir/eqs/"); # equalizer presets
278 glob_mkdir
("$rbdir/wps");
279 glob_mkdir
("$rbdir/themes");
281 open(THEME
, ">$rbdir/themes/rockbox_default_icons.cfg");
283 # this config file was auto-generated to make it
284 # easy to reset the icons back to default
286 # taken from apps/gui/icon.c
287 viewers iconset: /$rbdir/icons/viewers.bmp
289 # taken from apps/gui/icon.c
290 remote viewers iconset: /$rbdir/icons/remote_viewers.bmp
297 glob_mkdir
("$rbdir/codepages");
300 system("$ROOT/tools/codepages");
303 system("$ROOT/tools/codepages -m");
306 glob_move
('*.cp', "$rbdir/codepages/");
308 if($bitmap && $depth > 1) {
309 glob_mkdir
("$rbdir/backdrops");
313 glob_mkdir
("$rbdir/codecs");
315 find
(find_copyfile
(qr/.*\.codec/, abs_path
("$rbdir/codecs/")), 'apps/codecs');
317 # remove directory again if no codec was copied
318 rmdir("$rbdir/codecs");
321 find
(find_copyfile
(qr/\.(rock|ovl|lua)/, abs_path
("$rbdir/rocks/")), 'apps/plugins');
323 open VIEWERS
, "$ROOT/apps/plugins/viewers.config" or
324 die "can't open viewers.config";
325 my @viewers = <VIEWERS
>;
328 open VIEWERS
, ">$rbdir/viewers.config" or
329 die "can't create $rbdir/viewers.config";
331 foreach my $line (@viewers) {
332 if ($line =~ /([^,]*),([^,]*),/) {
333 my ($ext, $plugin)=($1, $2);
334 my $r = "${plugin}.rock";
340 # strip off the last slash and file name part
341 $dir =~ s/(.*)\/(.*)/$1/;
342 # store the file name part
345 # get .ovl name (file part only)
347 $oname =~ s/\.rock$/.ovl/;
349 # print STDERR "$ext $plugin $dir $name $r\n";
351 if(-e
"$rbdir/rocks/$name") {
352 if($dir ne "rocks") {
353 # target is not 'rocks' but the plugins are always in that
355 move
("$rbdir/rocks/$name", "$rbdir/rocks/$r");
359 elsif(-e
"$rbdir/rocks/$r") {
360 # in case the same plugin works for multiple extensions, it
361 # was already moved to the viewers dir
365 if(-e
"$rbdir/rocks/$oname") {
366 # if there's an "overlay" file for the .rock, move that as
368 move
("$rbdir/rocks/$oname", "$rbdir/rocks/$dir");
374 open CATEGORIES
, "$ROOT/apps/plugins/CATEGORIES" or
375 die "can't open CATEGORIES";
376 my @rock_targetdirs = <CATEGORIES
>;
378 foreach my $line (@rock_targetdirs) {
379 if ($line =~ /([^,]*),(.*)/) {
380 my ($plugin, $dir)=($1, $2);
381 move
("$rbdir/rocks/${plugin}.rock", "$rbdir/rocks/$dir/${plugin}.rock");
382 if(-e
"$rbdir/rocks/${plugin}.ovl") {
383 # if there's an "overlay" file for the .rock, move that as
385 move
("$rbdir/rocks/${plugin}.ovl", "$rbdir/rocks/$dir");
387 if(-e
"$rbdir/rocks/${plugin}.lua") {
388 # if this is a lua script, move it to the appropriate dir
389 move
("$rbdir/rocks/${plugin}.lua", "$rbdir/rocks/$dir/");
394 glob_unlink
("$rbdir/rocks/*.lua"); # Clean up unwanted *.lua files (e.g. actions.lua, buttons.lua)
397 glob_mkdir
("$rbdir/icons");
398 copy
("$viewer_bmpdir/viewers.${icon_w}x${icon_h}x$depth.bmp", "$rbdir/icons/viewers.bmp");
400 copy
("$viewer_bmpdir/remote_viewers.${remote_icon_w}x${remote_icon_h}x$remote_depth.bmp", "$rbdir/icons/remote_viewers.bmp");
404 copy
("$ROOT/apps/tagnavi.config", "$rbdir/");
405 copy
("$ROOT/apps/plugins/disktidy.config", "$rbdir/rocks/apps/");
408 copy
("$ROOT/apps/plugins/sokoban.levels", "$rbdir/rocks/games/sokoban.levels"); # sokoban levels
409 copy
("$ROOT/apps/plugins/snake2.levels", "$rbdir/rocks/games/snake2.levels"); # snake2 levels
410 copy
("$ROOT/apps/plugins/rockbox-fonts.config", "$rbdir/rocks/viewers/");
413 if(-e
"$rbdir/rocks/demos/pictureflow.rock") {
414 copy
("$ROOT/apps/plugins/bitmaps/native/pictureflow_emptyslide.100x100x16.bmp",
415 "$rbdir/rocks/demos/pictureflow_emptyslide.bmp");
418 $pf_logo = "pictureflow_logo.100x18x16.bmp";
420 $pf_logo = "pictureflow_logo.193x34x16.bmp";
422 copy
("$ROOT/apps/plugins/bitmaps/native/$pf_logo",
423 "$rbdir/rocks/demos/pictureflow_splash.bmp");
428 # image is blank when this is a simulator
429 if( filesize
("rockbox.ucl") > 1000 ) {
430 copy
("rockbox.ucl", "$rbdir/rockbox.ucl"); # UCL for flashing
432 if( filesize
("rombox.ucl") > 1000) {
433 copy
("rombox.ucl", "$rbdir/rombox.ucl"); # UCL for flashing
436 # Check for rombox.target
437 if ($image=~/(.*)\.(\w+)$/)
439 my $romfile = "rombox.$2";
440 if (filesize
($romfile) > 1000)
442 copy
($romfile, "$rbdir/$romfile");
447 glob_mkdir
("$rbdir/docs");
452 copy
("$ROOT/docs/$_", "$rbdir/docs/$_.txt");
455 copy
("$ROOT/docs/profontdoc.txt", "$rbdir/docs/profontdoc.txt");
457 for(("sample.colours",
460 copy
("$ROOT/docs/$_", "$rbdir/docs/$_");
463 # Now do the WPS dance
465 my $wps_build_cmd="perl $ROOT/wps/wpsbuild.pl ";
466 $wps_build_cmd=$wps_build_cmd."-v " if $verbose;
467 $wps_build_cmd=$wps_build_cmd." --rbdir=$rbdir -r $ROOT -m $modelname $ROOT/wps/WPSLIST $target";
468 print "wpsbuild: $wps_build_cmd\n" if $verbose;
469 system("$wps_build_cmd");
470 print "wps_build_cmd: done\n" if $verbose;
473 print STDERR
"No wps module present, can't do the WPS magic!\n";
476 # until buildwps.pl is fixed, manually copy the classic_statusbar theme across
477 mkdir "$rbdir/wps/classic_statusbar", 0777;
478 glob_copy
("$ROOT/wps/classic_statusbar/*.bmp", "$rbdir/wps/classic_statusbar");
481 copy
("$ROOT/wps/classic_statusbar.sbs", "$rbdir/wps");
482 } elsif ($depth > 1) {
483 copy
("$ROOT/wps/classic_statusbar.grey.sbs", "$rbdir/wps/classic_statusbar.sbs");
485 copy
("$ROOT/wps/classic_statusbar.mono.sbs", "$rbdir/wps/classic_statusbar.sbs");
488 copy
("$ROOT/wps/classic_statusbar.112x64x1.sbs", "$rbdir/wps/classic_statusbar.sbs");
490 system("touch $rbdir/wps/rockbox_none.sbs");
491 if ($remote_depth != $depth) {
492 copy
("$ROOT/wps/classic_statusbar.mono.sbs", "$rbdir/wps/classic_statusbar.rsbs");
494 copy
("$rbdir/wps/classic_statusbar.sbs", "$rbdir/wps/classic_statusbar.rsbs");
496 copy
("$rbdir/wps/rockbox_none.sbs", "$rbdir/wps/rockbox_none.rsbs");
499 copy
("rockbox-info.txt", "$rbdir/rockbox-info.txt");
501 # copy the already built lng files
502 glob_copy
('apps/lang/*lng', "$rbdir/langs/");
504 # copy the .lua files
505 glob_mkdir
("$rbdir/rocks/viewers/lua/");
506 glob_copy
('apps/plugins/lua/*.lua', "$rbdir/rocks/viewers/lua/");
509 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
515 #$date=sprintf("%04d%02d%02d", $year,$mon, $mday);
516 #$shortdate=sprintf("%02d%02d%02d", $year%100,$mon, $mday);
518 # made once for all targets
520 my ($target, $fonts)=@_;
522 $app = ($modelname eq "application");
524 # build a full install .rockbox ($rbdir) directory
525 buildzip
($target, $fonts);
530 # Don't include image file in fonts-only package
533 if($target && ($target !~ /(mod|ajz|wma)\z/i)) {
534 # On some targets, the image goes into .rockbox.
535 copy
("$target", "$rbdir/$target");
540 print "$ziptool $output $rbdir $target >/dev/null\n";
543 my $samedir = 1; # is the destination dir equal to source dir ?
546 make_install
($install) or die "MKDIRFAILED\n";
549 system("$ziptool $output $rbdir $target >/dev/null");
552 # remove the $rbdir afterwards
559 # not specified, guess!
560 if($target =~ /(recorder|ondio)/i) {
563 elsif($target =~ /iriver/i) {
564 $exe = "rockbox.iriver";
570 elsif(($exe =~ /rockboxui/)) {
571 # simulator, exclude the exe file
575 runone
($exe, $incfonts);