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
; # 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
35 my ($pattern, $destination) = @_;
36 print "glob_copy: $pattern -> $destination\n" if $verbose;
37 foreach my $path (glob($pattern)) {
38 copy
($path, $destination);
43 my ($pattern, $destination) = @_;
44 print "glob_move: $pattern -> $destination\n" if $verbose;
45 foreach my $path (glob($pattern)) {
46 move
($path, $destination);
52 print "glob_unlink: $pattern\n" if $verbose;
53 foreach my $path (glob($pattern)) {
59 my ($pattern, $destination) = @_;
60 print "find_copyfile: $pattern -> $destination\n" if $verbose;
63 if ($path =~ $pattern && filesize
($path) > 0 && !($path =~ /$rbdir/)) {
64 copy
($path, $destination);
65 chmod(0755, $destination.'/'.$path);
71 GetOptions
( 'r|root=s' => \
$ROOT,
72 'z|ziptool=s' => \
$ziptool,
73 'm|modelname=s' => \
$modelname, # The model name as used in ARCHOS in the root makefile
74 'i|id=s' => \
$target_id, # The target id name as used in TARGET_ID in the root makefile
75 'o|output=s' => \
$output,
76 'f|fonts=s' => \
$incfonts, # 0 - no fonts, 1 - fonts only 2 - fonts and package
77 'v|verbose' => \
$verbose,
78 'install=s' => \
$install, # install destination
79 'rbdir=s' => \
$rbdir, # If we want to put in a different directory
82 ($target, $exe) = @ARGV;
84 my $firmdir="$ROOT/firmware";
85 my $appsdir="$ROOT/apps";
86 my $viewer_bmpdir="$ROOT/apps/plugins/bitmaps/viewer_defaults";
91 open(GCC
, ">gcctemp");
92 # Get the LCD screen depth and graphical status
95 #ifdef HAVE_LCD_BITMAP
99 LCD Height: LCD_HEIGHT
100 Icon Width: CONFIG_DEFAULT_ICON_WIDTH
101 Icon Height: CONFIG_DEFAULT_ICON_HEIGHT
104 #ifdef HAVE_REMOTE_LCD
105 Remote Depth: LCD_REMOTE_DEPTH
106 Remote Icon Width: CONFIG_REMOTE_DEFAULT_ICON_WIDTH
107 Remote Icon Height: CONFIG_REMOTE_DEFAULT_ICON_HEIGHT
111 #ifdef HAVE_RECORDING
118 my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -";
120 # print STDERR "CMD $c\n";
124 my ($bitmap, $width, $height, $depth, $swcodec, $icon_h, $icon_w);
125 my ($remote_depth, $remote_icon_h, $remote_icon_w);
129 # print STDERR "DATA: $_";
130 if($_ =~ /^Bitmap: (.*)/) {
133 elsif($_ =~ /^Depth: (\d*)/) {
136 elsif($_ =~ /^LCD Width: (\d*)/) {
139 elsif($_ =~ /^LCD Height: (\d*)/) {
142 elsif($_ =~ /^Icon Width: (\d*)/) {
145 elsif($_ =~ /^Icon Height: (\d*)/) {
148 elsif($_ =~ /^Codec: (\d*)/) {
149 # SWCODEC is 1, the others are HWCODEC
150 $swcodec = ($1 == 1);
152 elsif($_ =~ /^Remote Depth: (\d*)/) {
155 elsif($_ =~ /^Remote Icon Width: (\d*)/) {
158 elsif($_ =~ /^Remote Icon Height: (\d*)/) {
161 if($_ =~ /^Recording: (.*)/) {
168 return ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
169 $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h);
174 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
175 $atime,$mtime,$ctime,$blksize,$blocks)
181 my ($image, $fonts)=@_;
183 print "buildzip: image=$image fonts=$fonts\n" if $verbose;
185 my ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording,
186 $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h) =
189 # print "Bitmap: $bitmap\nDepth: $depth\nSwcodec: $swcodec\n";
197 # always disable fonts on non-bitmap targets
201 mkdir "$rbdir/fonts", 0777;
202 chdir "$rbdir/fonts";
203 my $cmd = "$ROOT/tools/convbdf -f $ROOT/fonts/*bdf >/dev/null 2>&1";
204 print($cmd."\n") if $verbose;
209 # fonts-only package, return
214 # create the file so the database does not try indexing a folder
215 open(IGNORE
, ">$rbdir/database.ignore") || die "can't open database.ignore";
218 mkdir "$rbdir/langs", 0777;
219 mkdir "$rbdir/rocks", 0777;
220 mkdir "$rbdir/rocks/games", 0777;
221 mkdir "$rbdir/rocks/apps", 0777;
222 mkdir "$rbdir/rocks/demos", 0777;
223 mkdir "$rbdir/rocks/viewers", 0777;
226 mkdir "$rbdir/recpresets", 0777;
230 mkdir "$rbdir/eqs", 0777;
232 glob_copy
("$ROOT/apps/eqs/*.cfg", "$rbdir/eqs/"); # equalizer presets
235 mkdir "$rbdir/wps", 0777;
236 mkdir "$rbdir/themes", 0777;
238 open(THEME
, ">$rbdir/themes/rockbox_default_icons.cfg");
240 # this config file was auto-generated to make it
241 # easy to reset the icons back to default
243 # taken from apps/gui/icon.c
244 viewers iconset: /$rbdir/icons/viewers.bmp
246 # taken from apps/gui/icon.c
247 remote viewers iconset: /$rbdir/icons/remote_viewers.bmp
254 mkdir "$rbdir/codepages", 0777;
257 system("$ROOT/tools/codepages");
260 system("$ROOT/tools/codepages -m");
263 glob_move
('*.cp', "$rbdir/codepages/");
266 mkdir "$rbdir/codecs", 0777;
268 mkdir "$rbdir/backdrops", 0777;
271 find
(find_copyfile
(qr/.*\.codec/, abs_path
("$rbdir/codecs/")), 'apps/codecs');
273 # remove directory again if no codec was copied
274 rmdir("$rbdir/codecs");
277 find
(find_copyfile
(qr/\.(rock|ovl)/, abs_path
("$rbdir/rocks/")), 'apps/plugins');
279 open VIEWERS
, "$ROOT/apps/plugins/viewers.config" or
280 die "can't open viewers.config";
281 my @viewers = <VIEWERS
>;
284 open VIEWERS
, ">$rbdir/viewers.config" or
285 die "can't create $rbdir/viewers.config";
287 foreach my $line (@viewers) {
288 if ($line =~ /([^,]*),([^,]*),/) {
289 my ($ext, $plugin)=($1, $2);
290 my $r = "${plugin}.rock";
296 # strip off the last slash and file name part
297 $dir =~ s/(.*)\/(.*)/$1/;
298 # store the file name part
301 # get .ovl name (file part only)
303 $oname =~ s/\.rock$/.ovl/;
305 # print STDERR "$ext $plugin $dir $name $r\n";
307 if(-e
"$rbdir/rocks/$name") {
308 if($dir ne "rocks") {
309 # target is not 'rocks' but the plugins are always in that
311 move
("$rbdir/rocks/$name", "$rbdir/rocks/$r");
315 elsif(-e
"$rbdir/rocks/$r") {
316 # in case the same plugin works for multiple extensions, it
317 # was already moved to the viewers dir
321 if(-e
"$rbdir/rocks/$oname") {
322 # if there's an "overlay" file for the .rock, move that as
324 move
("$rbdir/rocks/$oname", "$rbdir/rocks/$dir");
330 open CATEGORIES
, "$ROOT/apps/plugins/CATEGORIES" or
331 die "can't open CATEGORIES";
332 my @rock_targetdirs = <CATEGORIES
>;
334 foreach my $line (@rock_targetdirs) {
335 if ($line =~ /([^,]*),(.*)/) {
336 my ($plugin, $dir)=($1, $2);
337 move
("$rbdir/rocks/${plugin}.rock", "$rbdir/rocks/$dir/${plugin}.rock");
338 if(-e
"$rbdir/rocks/${plugin}.ovl") {
339 # if there's an "overlay" file for the .rock, move that as
341 move
("$rbdir/rocks/${plugin}.ovl", "$rbdir/rocks/$dir");
347 mkdir "$rbdir/icons", 0777;
348 copy
("$viewer_bmpdir/viewers.${icon_w}x${icon_h}x$depth.bmp", "$rbdir/icons/viewers.bmp");
350 copy
("$viewer_bmpdir/remote_viewers.${remote_icon_w}x${remote_icon_h}x$remote_depth.bmp", "$rbdir/icons/remote_viewers.bmp");
354 copy
("$ROOT/apps/tagnavi.config", "$rbdir/");
355 copy
("$ROOT/apps/plugins/disktidy.config", "$rbdir/rocks/apps/");
358 copy
("$ROOT/apps/plugins/sokoban.levels", "$rbdir/rocks/games/sokoban.levels"); # sokoban levels
359 copy
("$ROOT/apps/plugins/snake2.levels", "$rbdir/rocks/games/snake2.levels"); # snake2 levels
362 if(-e
"$rbdir/rocks/demos/pictureflow.rock") {
363 copy
("$ROOT/apps/plugins/bitmaps/native/pictureflow_emptyslide.100x100x16.bmp",
364 "$rbdir/rocks/demos/pictureflow_emptyslide.bmp");
367 $pf_logo = "pictureflow_logo.100x18x16.bmp";
369 $pf_logo = "pictureflow_logo.193x34x16.bmp";
371 copy
("$ROOT/apps/plugins/bitmaps/native/$pf_logo",
372 "$rbdir/rocks/demos/pictureflow_splash.bmp");
377 # image is blank when this is a simulator
378 if( filesize
("rockbox.ucl") > 1000 ) {
379 copy
("rockbox.ucl", "$rbdir/rockbox.ucl"); # UCL for flashing
381 if( filesize
("rombox.ucl") > 1000) {
382 copy
("rombox.ucl", "$rbdir/rombox.ucl"); # UCL for flashing
385 # Check for rombox.target
386 if ($image=~/(.*)\.(\w+)$/)
388 my $romfile = "rombox.$2";
389 if (filesize
($romfile) > 1000)
391 copy
($romfile, "$rbdir/$romfile");
396 mkdir "$rbdir/docs", 0777;
401 copy
("$ROOT/docs/$_", "$rbdir/docs/$_.txt");
404 copy
("$ROOT/docs/profontdoc.txt", "$rbdir/docs/profontdoc.txt");
406 for(("sample.colours",
409 copy
("$ROOT/docs/$_", "$rbdir/docs/$_");
412 # Now do the WPS dance
414 my $wps_build_cmd="perl $ROOT/wps/wpsbuild.pl ";
415 $wps_build_cmd=$wps_build_cmd."-v " if $verbose;
416 $wps_build_cmd=$wps_build_cmd." --rbdir=$rbdir -r $ROOT -m $modelname $ROOT/wps/WPSLIST $target";
417 print "wpsbuild: $wps_build_cmd\n" if $verbose;
418 system("$wps_build_cmd");
419 print "wps_build_cmd: done\n" if $verbose;
422 print STDERR
"No wps module present, can't do the WPS magic!\n";
426 copy
("rockbox-info.txt", "$rbdir/rockbox-info.txt");
428 # copy the already built lng files
429 glob_copy
('apps/lang/*lng', "$rbdir/langs/");
431 # copy the .lua files
432 mkdir "$rbdir/rocks/viewers/lua/", 0777;
433 glob_copy
('apps/plugins/lua/*.lua', "$rbdir/rocks/viewers/lua/");
436 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
442 #$date=sprintf("%04d%02d%02d", $year,$mon, $mday);
443 #$shortdate=sprintf("%02d%02d%02d", $year%100,$mon, $mday);
445 # made once for all targets
447 my ($target, $fonts)=@_;
449 # build a full install .rockbox ($rbdir) directory
450 buildzip
($target, $fonts);
455 # Don't include image file in fonts-only package
458 if($target && ($target !~ /(mod|ajz|wma)\z/i)) {
459 # On some targets, the image goes into .rockbox.
460 copy
("$target", "$rbdir/$target");
465 print "$ziptool $output $rbdir $target >/dev/null\n";
469 if ($install =~ /\/dev\
/null/) {
470 die "ERROR: No PREFIX given\n"
472 system("cp -r $rbdir \"$install\" >/dev/null");
475 system("$ziptool $output $rbdir $target >/dev/null");
478 # remove the $rbdir afterwards
483 # not specified, guess!
484 if($target =~ /(recorder|ondio)/i) {
487 elsif($target =~ /iriver/i) {
488 $exe = "rockbox.iriver";
494 elsif($exe =~ /rockboxui/) {
495 # simulator, exclude the exe file
499 runone
($exe, $incfonts);