Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 1 | #!/usr/bin/perl |
Daniel Stenberg | 51413e4 | 2005-11-14 15:06:51 +0000 | [diff] [blame] | 2 | # __________ __ ___. |
| 3 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | # \/ \/ \/ \/ \/ |
| 8 | # $Id$ |
| 9 | # |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 10 | |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 11 | use strict; |
| 12 | |
Jonas Häggqvist | 4077f23 | 2008-07-20 22:20:32 +0000 | [diff] [blame] | 13 | use File::Copy; # For move() and copy() |
| 14 | use File::Find; # For find() |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 15 | use File::Path qw(mkpath rmtree); # For rmtree() |
Michael Stummvoll | 1f06ca4 | 2010-12-28 10:30:46 +0000 | [diff] [blame] | 16 | use Cwd; |
Jonas Häggqvist | 4077f23 | 2008-07-20 22:20:32 +0000 | [diff] [blame] | 17 | use Cwd 'abs_path'; |
Dave Chapman | efe556f | 2011-02-26 21:30:20 +0000 | [diff] [blame] | 18 | use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF |
Jonas Häggqvist | 4077f23 | 2008-07-20 22:20:32 +0000 | [diff] [blame] | 19 | |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 20 | my $ROOT=".."; |
Daniel Stenberg | d1851e3 | 2004-08-24 15:13:08 +0000 | [diff] [blame] | 21 | |
Thomas Martitz | 9321ce3 | 2010-11-14 15:29:11 +0000 | [diff] [blame] | 22 | my $ziptool; |
| 23 | my $output; |
Daniel Stenberg | e07b0bb | 2005-12-13 10:20:23 +0000 | [diff] [blame] | 24 | my $verbose; |
Rafaël Carré | 80fa0ef | 2010-07-07 20:31:34 +0000 | [diff] [blame] | 25 | my $install; |
Daniel Stenberg | e07b0bb | 2005-12-13 10:20:23 +0000 | [diff] [blame] | 26 | my $exe; |
| 27 | my $target; |
Bertrik Sikken | 31c8eee | 2009-01-31 12:23:35 +0000 | [diff] [blame] | 28 | my $modelname; |
Daniel Stenberg | a420dc3 | 2006-05-10 21:57:08 +0000 | [diff] [blame] | 29 | my $incfonts; |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 30 | my $target_id; # passed in, not currently used |
Thomas Martitz | 9321ce3 | 2010-11-14 15:29:11 +0000 | [diff] [blame] | 31 | my $rbdir; # can be non-.rockbox for special builds |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 32 | my $app; |
Michael Stummvoll | 1f06ca4 | 2010-12-28 10:30:46 +0000 | [diff] [blame] | 33 | my $mklinks; |
Björn Stenberg | ad8d603 | 2008-11-24 22:16:07 +0000 | [diff] [blame] | 34 | |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 35 | sub glob_mkdir { |
| 36 | my ($dir) = @_; |
| 37 | mkpath ($dir, $verbose, 0777); |
| 38 | return 1; |
| 39 | } |
| 40 | |
| 41 | sub glob_install { |
| 42 | my ($_src, $dest, $opts) = @_; |
| 43 | |
| 44 | unless ($opts) { |
| 45 | $opts = "-m 0664"; |
| 46 | } |
| 47 | |
| 48 | foreach my $src (glob($_src)) { |
| 49 | unless ( -d $src || !(-e $src)) { |
Thomas Martitz | 19a21a2 | 2010-07-13 14:53:10 +0000 | [diff] [blame] | 50 | system("install $opts \"$src\" \"$dest\""); |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 51 | print "install $opts \"$src\" -> \"$dest\"\n" if $verbose; |
| 52 | } |
| 53 | } |
| 54 | return 1; |
| 55 | } |
Björn Stenberg | ad8d603 | 2008-11-24 22:16:07 +0000 | [diff] [blame] | 56 | |
| 57 | sub glob_copy { |
| 58 | my ($pattern, $destination) = @_; |
| 59 | print "glob_copy: $pattern -> $destination\n" if $verbose; |
| 60 | foreach my $path (glob($pattern)) { |
| 61 | copy($path, $destination); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | sub glob_move { |
| 66 | my ($pattern, $destination) = @_; |
| 67 | print "glob_move: $pattern -> $destination\n" if $verbose; |
| 68 | foreach my $path (glob($pattern)) { |
| 69 | move($path, $destination); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | sub glob_unlink { |
| 74 | my ($pattern) = @_; |
| 75 | print "glob_unlink: $pattern\n" if $verbose; |
| 76 | foreach my $path (glob($pattern)) { |
| 77 | unlink($path); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | sub find_copyfile { |
| 82 | my ($pattern, $destination) = @_; |
| 83 | print "find_copyfile: $pattern -> $destination\n" if $verbose; |
| 84 | return sub { |
| 85 | my $path = $_; |
Michael Stummvoll | 1f06ca4 | 2010-12-28 10:30:46 +0000 | [diff] [blame] | 86 | my $source = getcwd(); |
Björn Stenberg | ad8d603 | 2008-11-24 22:16:07 +0000 | [diff] [blame] | 87 | if ($path =~ $pattern && filesize($path) > 0 && !($path =~ /$rbdir/)) { |
Michael Stummvoll | 1f06ca4 | 2010-12-28 10:30:46 +0000 | [diff] [blame] | 88 | if($mklinks) { |
| 89 | print "link $path $destination\n" if $verbose; |
| 90 | symlink($source.'/'.$path, $destination.'/'.$path); |
| 91 | } else { |
| 92 | print "cp $path $destination\n" if $verbose; |
| 93 | copy($path, $destination); |
| 94 | chmod(0755, $destination.'/'.$path); |
| 95 | } |
Björn Stenberg | ad8d603 | 2008-11-24 22:16:07 +0000 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | } |
Daniel Stenberg | e07b0bb | 2005-12-13 10:20:23 +0000 | [diff] [blame] | 99 | |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 100 | sub find_installfile { |
| 101 | my ($pattern, $destination) = @_; |
| 102 | print "find_installfile: $pattern -> $destination\n" if $verbose; |
| 103 | return sub { |
| 104 | my $path = $_; |
| 105 | if ($path =~ $pattern) { |
| 106 | print "FIND_INSTALLFILE: $path\n"; |
| 107 | glob_install($path, $destination); |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | |
| 113 | sub make_install { |
| 114 | my ($src, $dest) = @_; |
| 115 | |
| 116 | my $bindir = $dest; |
| 117 | my $libdir = $dest; |
| 118 | my $userdir = $dest; |
| 119 | |
| 120 | my @plugins = ( "games", "apps", "demos", "viewers" ); |
| 121 | my @userstuff = ( "backdrops", "codepages", "docs", "fonts", "langs", "themes", "wps", "eqs", "icons" ); |
| 122 | my @files = (); |
| 123 | |
| 124 | if ($app) { |
| 125 | $bindir .= "/bin"; |
| 126 | $libdir .= "/lib/rockbox"; |
| 127 | $userdir .= "/share/rockbox"; |
| 128 | } else { |
| 129 | # for non-app builds we expect the prefix to be the dir above .rockbox |
Teruaki Kawashima | 3c11c56 | 2010-09-25 14:47:11 +0000 | [diff] [blame] | 130 | $bindir .= "/$rbdir"; |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 131 | $libdir = $userdir = $bindir; |
| 132 | } |
| 133 | if ($dest =~ /\/dev\/null/) { |
| 134 | die "ERROR: No PREFIX given\n" |
| 135 | } |
| 136 | |
Teruaki Kawashima | b03b891 | 2010-12-17 11:41:43 +0000 | [diff] [blame] | 137 | if ((!$app) && -e $bindir && -e $src && (abs_path($bindir) eq abs_path($src))) { |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 138 | return 1; |
| 139 | } |
| 140 | |
| 141 | # binary |
| 142 | unless ($exe eq "") { |
| 143 | unless (glob_mkdir($bindir)) { |
| 144 | return 0; |
| 145 | } |
| 146 | glob_install($exe, $bindir, "-m 0775"); |
| 147 | } |
| 148 | |
| 149 | # codecs |
| 150 | unless (glob_mkdir("$libdir/codecs")) { |
| 151 | return 0; |
| 152 | } |
Dominik Riebeling | 70b81e6 | 2011-05-31 21:26:18 +0000 | [diff] [blame] | 153 | # Android has codecs installed as native libraries so they are not needed |
| 154 | # in the zip. |
| 155 | if ($modelname !~ /android/) { |
| 156 | glob_install("$src/codecs/*", "$libdir/codecs", "-m 0755"); |
| 157 | } |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 158 | |
| 159 | # plugins |
| 160 | unless (glob_mkdir("$libdir/rocks")) { |
| 161 | return 0; |
| 162 | } |
| 163 | foreach my $t (@plugins) { |
| 164 | unless (glob_mkdir("$libdir/rocks/$t")) { |
| 165 | return 0; |
| 166 | } |
Magnus Holmgren | 47c510b | 2010-08-29 12:29:34 +0000 | [diff] [blame] | 167 | glob_install("$src/rocks/$t/*", "$libdir/rocks/$t", "-m 0755"); |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | # rocks/viewers/lua |
| 171 | unless (glob_mkdir("$libdir/rocks/viewers/lua")) { |
| 172 | return 0; |
| 173 | } |
| 174 | glob_install("$src/rocks/viewers/lua/*", "$libdir/rocks/viewers/lua"); |
| 175 | |
William Wilgus | 90118f1 | 2019-07-26 01:30:00 -0500 | [diff] [blame^] | 176 | #lua example scripts |
| 177 | if(-e "$ROOT/apps/plugins/lua_scripts") { |
| 178 | unless (glob_mkdir("$libdir/rocks/demos/lua_scripts")) { |
| 179 | return 0; |
| 180 | } |
| 181 | glob_install("$ROOT/apps/plugins/lua_scripts/*.lua", "$libdir/rocks/demos/lua_scripts"); |
| 182 | #glob_mkdir("$temp_dir/rocks/demos/lua_scripts"); |
| 183 | #glob_copy("$ROOT/apps/plugins/lua_scripts/*.lua", "$temp_dir/rocks/demos/lua_scripts/"); |
| 184 | } |
| 185 | |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 186 | # all the rest directories |
| 187 | foreach my $t (@userstuff) { |
| 188 | unless (glob_mkdir("$userdir/$t")) { |
| 189 | return 0; |
| 190 | } |
| 191 | glob_install("$src/$t/*", "$userdir/$t"); |
| 192 | } |
| 193 | |
| 194 | # wps/ subfolders and bitmaps |
| 195 | opendir(DIR, $src . "/wps"); |
| 196 | @files = readdir(DIR); |
| 197 | closedir(DIR); |
| 198 | |
| 199 | foreach my $_dir (@files) { |
| 200 | my $dir = "wps/" . $_dir; |
| 201 | if ( -d "$src/$dir" && $_dir !~ /\.\.?/) { |
| 202 | unless (glob_mkdir("$userdir/$dir")) { |
| 203 | return 0; |
| 204 | } |
| 205 | glob_install("$src/$dir/*", "$userdir/$dir"); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | # rest of the files, excluding the binary |
| 210 | opendir(DIR,$src); |
| 211 | @files = readdir(DIR); |
| 212 | closedir(DIR); |
| 213 | |
Thomas Martitz | 249bba0 | 2011-12-24 11:56:46 +0000 | [diff] [blame] | 214 | foreach my $file (grep (/[a-zA-Z]+\.(txt|config|ignore|sh)/,@files)) { |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 215 | glob_install("$src/$file", "$userdir/"); |
| 216 | } |
| 217 | return 1; |
| 218 | } |
| 219 | |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 220 | # Get options |
Dave Chapman | efe556f | 2011-02-26 21:30:20 +0000 | [diff] [blame] | 221 | GetOptions ( 'r|root=s' => \$ROOT, |
| 222 | 'z|ziptool:s' => \$ziptool, |
| 223 | 'm|modelname=s' => \$modelname, # The model name as used in ARCHOS in the root makefile |
| 224 | 'i|id=s' => \$target_id, # The target id name as used in TARGET_ID in the root makefile |
| 225 | 'o|output:s' => \$output, |
| 226 | 'f|fonts=s' => \$incfonts, # 0 - no fonts, 1 - fonts only 2 - fonts and package |
| 227 | 'v|verbose' => \$verbose, |
| 228 | 'install=s' => \$install, # install destination |
| 229 | 'rbdir:s' => \$rbdir, # If we want to put in a different directory |
| 230 | 'l|link' => \$mklinks, # If we want to create links instead of copying files |
Dave Chapman | 376c9f3 | 2011-02-27 11:37:39 +0000 | [diff] [blame] | 231 | 'a|app:s' => \$app, # Is this an Application build? |
Björn Stenberg | ad8d603 | 2008-11-24 22:16:07 +0000 | [diff] [blame] | 232 | ); |
Daniel Stenberg | e07b0bb | 2005-12-13 10:20:23 +0000 | [diff] [blame] | 233 | |
Thomas Martitz | 9321ce3 | 2010-11-14 15:29:11 +0000 | [diff] [blame] | 234 | # GetOptions() doesn't remove the params from @ARGV if their value was "" |
| 235 | # Thus we use the ":" for those for which we use a default value in case of "" |
| 236 | # and assign the default value afterwards |
| 237 | if ($ziptool eq '') { |
| 238 | $ziptool = "zip -r9"; |
| 239 | } |
| 240 | if ($output eq '') { |
| 241 | $output = "rockbox.zip" |
| 242 | } |
| 243 | if ($rbdir eq '') { |
| 244 | $rbdir = ".rockbox"; |
| 245 | } |
| 246 | |
| 247 | # Now @ARGV shuold be free of any left-overs GetOptions left |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 248 | ($target, $exe) = @ARGV; |
Daniel Stenberg | e07b0bb | 2005-12-13 10:20:23 +0000 | [diff] [blame] | 249 | |
Daniel Stenberg | 9990dec | 2005-08-04 18:11:46 +0000 | [diff] [blame] | 250 | my $firmdir="$ROOT/firmware"; |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 251 | my $appsdir="$ROOT/apps"; |
| 252 | my $viewer_bmpdir="$ROOT/apps/plugins/bitmaps/viewer_defaults"; |
Daniel Stenberg | 9990dec | 2005-08-04 18:11:46 +0000 | [diff] [blame] | 253 | |
Daniel Stenberg | 0f820d6 | 2005-08-03 21:31:51 +0000 | [diff] [blame] | 254 | my $cppdef = $target; |
| 255 | |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 256 | sub gettargetinfo { |
| 257 | open(GCC, ">gcctemp"); |
| 258 | # Get the LCD screen depth and graphical status |
| 259 | print GCC <<STOP |
| 260 | \#include "config.h" |
| 261 | #ifdef HAVE_LCD_BITMAP |
| 262 | Bitmap: yes |
| 263 | Depth: LCD_DEPTH |
Andrew Mahone | 802ea46 | 2009-05-23 07:55:14 +0000 | [diff] [blame] | 264 | LCD Width: LCD_WIDTH |
| 265 | LCD Height: LCD_HEIGHT |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 266 | Icon Width: CONFIG_DEFAULT_ICON_WIDTH |
| 267 | Icon Height: CONFIG_DEFAULT_ICON_HEIGHT |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 268 | #endif |
| 269 | Codec: CONFIG_CODEC |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 270 | #ifdef HAVE_REMOTE_LCD |
| 271 | Remote Depth: LCD_REMOTE_DEPTH |
| 272 | Remote Icon Width: CONFIG_REMOTE_DEFAULT_ICON_WIDTH |
Jonathan Gordon | bfa5577 | 2007-04-16 09:59:27 +0000 | [diff] [blame] | 273 | Remote Icon Height: CONFIG_REMOTE_DEFAULT_ICON_HEIGHT |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 274 | #else |
| 275 | Remote Depth: 0 |
| 276 | #endif |
Jonathan Gordon | b2ecf1b | 2007-05-29 08:17:32 +0000 | [diff] [blame] | 277 | #ifdef HAVE_RECORDING |
| 278 | Recording: yes |
| 279 | #endif |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 280 | STOP |
| 281 | ; |
Daniel Stenberg | b46f1ac | 2007-03-12 12:56:35 +0000 | [diff] [blame] | 282 | close(GCC); |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 283 | |
| 284 | my $c="cat gcctemp | gcc $cppdef -I. -I$firmdir/export -E -P -"; |
| 285 | |
| 286 | # print STDERR "CMD $c\n"; |
| 287 | |
| 288 | open(TARGET, "$c|"); |
| 289 | |
Andrew Mahone | 802ea46 | 2009-05-23 07:55:14 +0000 | [diff] [blame] | 290 | my ($bitmap, $width, $height, $depth, $swcodec, $icon_h, $icon_w); |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 291 | my ($remote_depth, $remote_icon_h, $remote_icon_w); |
Jonathan Gordon | b2ecf1b | 2007-05-29 08:17:32 +0000 | [diff] [blame] | 292 | my ($recording); |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 293 | my $icon_count = 1; |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 294 | while(<TARGET>) { |
| 295 | # print STDERR "DATA: $_"; |
| 296 | if($_ =~ /^Bitmap: (.*)/) { |
| 297 | $bitmap = $1; |
| 298 | } |
| 299 | elsif($_ =~ /^Depth: (\d*)/) { |
| 300 | $depth = $1; |
| 301 | } |
Andrew Mahone | 802ea46 | 2009-05-23 07:55:14 +0000 | [diff] [blame] | 302 | elsif($_ =~ /^LCD Width: (\d*)/) { |
| 303 | $width = $1; |
| 304 | } |
| 305 | elsif($_ =~ /^LCD Height: (\d*)/) { |
| 306 | $height = $1; |
| 307 | } |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 308 | elsif($_ =~ /^Icon Width: (\d*)/) { |
| 309 | $icon_w = $1; |
| 310 | } |
| 311 | elsif($_ =~ /^Icon Height: (\d*)/) { |
| 312 | $icon_h = $1; |
| 313 | } |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 314 | elsif($_ =~ /^Codec: (\d*)/) { |
| 315 | # SWCODEC is 1, the others are HWCODEC |
| 316 | $swcodec = ($1 == 1); |
| 317 | } |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 318 | elsif($_ =~ /^Remote Depth: (\d*)/) { |
| 319 | $remote_depth = $1; |
| 320 | } |
| 321 | elsif($_ =~ /^Remote Icon Width: (\d*)/) { |
| 322 | $remote_icon_w = $1; |
| 323 | } |
| 324 | elsif($_ =~ /^Remote Icon Height: (\d*)/) { |
| 325 | $remote_icon_h = $1; |
| 326 | } |
Jonathan Gordon | b2ecf1b | 2007-05-29 08:17:32 +0000 | [diff] [blame] | 327 | if($_ =~ /^Recording: (.*)/) { |
| 328 | $recording = $1; |
| 329 | } |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 330 | } |
| 331 | close(TARGET); |
| 332 | unlink("gcctemp"); |
| 333 | |
Andrew Mahone | 802ea46 | 2009-05-23 07:55:14 +0000 | [diff] [blame] | 334 | return ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording, |
Jonathan Gordon | 6a5cc0b | 2007-04-16 09:14:36 +0000 | [diff] [blame] | 335 | $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h); |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 336 | } |
Daniel Stenberg | d1851e3 | 2004-08-24 15:13:08 +0000 | [diff] [blame] | 337 | |
Daniel Stenberg | c4d463b | 2004-08-24 09:38:26 +0000 | [diff] [blame] | 338 | sub filesize { |
| 339 | my ($filename)=@_; |
| 340 | my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, |
| 341 | $atime,$mtime,$ctime,$blksize,$blocks) |
| 342 | = stat($filename); |
| 343 | return $size; |
| 344 | } |
| 345 | |
Jonathan Gordon | 9928e34 | 2010-09-14 11:56:50 +0000 | [diff] [blame] | 346 | |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 347 | sub buildzip { |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 348 | my ($image, $fonts)=@_; |
| 349 | my $libdir = $install; |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 350 | my $temp_dir = ".rockbox"; |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 351 | |
Björn Stenberg | ad8d603 | 2008-11-24 22:16:07 +0000 | [diff] [blame] | 352 | print "buildzip: image=$image fonts=$fonts\n" if $verbose; |
| 353 | |
Andrew Mahone | 802ea46 | 2009-05-23 07:55:14 +0000 | [diff] [blame] | 354 | my ($bitmap, $depth, $width, $height, $icon_w, $icon_h, $recording, |
| 355 | $swcodec, $remote_depth, $remote_icon_w, $remote_icon_h) = |
| 356 | &gettargetinfo(); |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 357 | |
Daniel Stenberg | a1d0ad9 | 2007-03-20 12:38:54 +0000 | [diff] [blame] | 358 | # print "Bitmap: $bitmap\nDepth: $depth\nSwcodec: $swcodec\n"; |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 359 | |
| 360 | # remove old traces |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 361 | rmtree($temp_dir); |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 362 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 363 | glob_mkdir($temp_dir); |
Daniel Stenberg | a420dc3 | 2006-05-10 21:57:08 +0000 | [diff] [blame] | 364 | |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 365 | if(!$bitmap) { |
| 366 | # always disable fonts on non-bitmap targets |
| 367 | $fonts = 0; |
| 368 | } |
Daniel Stenberg | a420dc3 | 2006-05-10 21:57:08 +0000 | [diff] [blame] | 369 | if($fonts) { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 370 | glob_mkdir("$temp_dir/fonts"); |
| 371 | chdir "$temp_dir/fonts"; |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 372 | my $cmd = "$ROOT/tools/convbdf -f $ROOT/fonts/*bdf >/dev/null 2>&1"; |
Jonas Häggqvist | 45290b4 | 2008-07-20 23:16:39 +0000 | [diff] [blame] | 373 | print($cmd."\n") if $verbose; |
Jonas Häggqvist | ca61b5b | 2008-07-20 23:12:03 +0000 | [diff] [blame] | 374 | system($cmd); |
| 375 | chdir("../../"); |
Daniel Stenberg | a420dc3 | 2006-05-10 21:57:08 +0000 | [diff] [blame] | 376 | |
Daniel Stenberg | a420dc3 | 2006-05-10 21:57:08 +0000 | [diff] [blame] | 377 | if($fonts < 2) { |
| 378 | # fonts-only package, return |
| 379 | return; |
| 380 | } |
| 381 | } |
| 382 | |
Jens Arnold | 109a867 | 2008-08-26 23:41:52 +0000 | [diff] [blame] | 383 | # create the file so the database does not try indexing a folder |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 384 | open(IGNORE, ">$temp_dir/database.ignore") || die "can't open database.ignore"; |
Jens Arnold | 109a867 | 2008-08-26 23:41:52 +0000 | [diff] [blame] | 385 | close(IGNORE); |
Thomas Martitz | 249bba0 | 2011-12-24 11:56:46 +0000 | [diff] [blame] | 386 | |
| 387 | # the samsung ypr0 has a loader script that's needed in the zip |
Lorenzo Miori | e876f4d | 2013-09-10 22:48:34 +0200 | [diff] [blame] | 388 | if ($modelname =~ /samsungypr[01]/) { |
Thomas Martitz | 249bba0 | 2011-12-24 11:56:46 +0000 | [diff] [blame] | 389 | glob_copy("$ROOT/utils/ypr0tools/rockbox.sh", "$temp_dir/"); |
| 390 | } |
Dominik Riebeling | 6eebdb3 | 2012-05-19 11:00:16 +0200 | [diff] [blame] | 391 | # add .nomedia on Android |
| 392 | # in the zip. |
| 393 | if ($modelname =~ /android/) { |
| 394 | open(NOMEDIA, ">$temp_dir/.nomedia") || die "can't open .nomedia"; |
| 395 | close(NOMEDIA); |
| 396 | } |
| 397 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 398 | glob_mkdir("$temp_dir/langs"); |
| 399 | glob_mkdir("$temp_dir/rocks"); |
| 400 | glob_mkdir("$temp_dir/rocks/games"); |
| 401 | glob_mkdir("$temp_dir/rocks/apps"); |
| 402 | glob_mkdir("$temp_dir/rocks/demos"); |
| 403 | glob_mkdir("$temp_dir/rocks/viewers"); |
Jonathan Gordon | fda7d72 | 2007-08-06 13:42:52 +0000 | [diff] [blame] | 404 | |
Jonathan Gordon | b2ecf1b | 2007-05-29 08:17:32 +0000 | [diff] [blame] | 405 | if ($recording) { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 406 | glob_mkdir("$temp_dir/recpresets"); |
Jonathan Gordon | b2ecf1b | 2007-05-29 08:17:32 +0000 | [diff] [blame] | 407 | } |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 408 | |
| 409 | if($swcodec) { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 410 | glob_mkdir("$temp_dir/eqs"); |
Daniel Stenberg | 25bb98d | 2005-07-12 11:11:50 +0000 | [diff] [blame] | 411 | |
Sean Bartell | b5716df | 2011-06-24 01:25:21 -0400 | [diff] [blame] | 412 | glob_copy("$ROOT/lib/rbcodec/dsp/eqs/*.cfg", "$temp_dir/eqs/"); # equalizer presets |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 413 | } |
| 414 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 415 | glob_mkdir("$temp_dir/wps"); |
Thomas Martitz | 66b6fdb | 2012-06-10 20:28:36 +0200 | [diff] [blame] | 416 | glob_mkdir("$temp_dir/icons"); |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 417 | glob_mkdir("$temp_dir/themes"); |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 418 | glob_mkdir("$temp_dir/codepages"); |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 419 | |
| 420 | if($bitmap) { |
Jens Arnold | 738c37c | 2007-04-01 13:09:22 +0000 | [diff] [blame] | 421 | system("$ROOT/tools/codepages"); |
| 422 | } |
| 423 | else { |
| 424 | system("$ROOT/tools/codepages -m"); |
| 425 | } |
Jonas Häggqvist | 4077f23 | 2008-07-20 22:20:32 +0000 | [diff] [blame] | 426 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 427 | glob_move('*.cp', "$temp_dir/codepages/"); |
Jens Arnold | 738c37c | 2007-04-01 13:09:22 +0000 | [diff] [blame] | 428 | |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 429 | if($bitmap && $depth > 1) { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 430 | glob_mkdir("$temp_dir/backdrops"); |
Daniel Stenberg | a52018c | 2005-08-11 20:48:34 +0000 | [diff] [blame] | 431 | } |
| 432 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 433 | glob_mkdir("$temp_dir/codecs"); |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 434 | |
Dominik Riebeling | 70b81e6 | 2011-05-31 21:26:18 +0000 | [diff] [blame] | 435 | # Android has codecs installed as native libraries so they are not needed |
| 436 | # in the zip. |
| 437 | if ($modelname !~ /android/) { |
Sean Bartell | f40bfc9 | 2011-06-25 21:32:25 -0400 | [diff] [blame] | 438 | find(find_copyfile(qr/.*\.codec/, abs_path("$temp_dir/codecs/")), 'lib/rbcodec/codecs'); |
Dominik Riebeling | 70b81e6 | 2011-05-31 21:26:18 +0000 | [diff] [blame] | 439 | } |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 440 | |
| 441 | # remove directory again if no codec was copied |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 442 | rmdir("$temp_dir/codecs"); |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 443 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 444 | find(find_copyfile(qr/\.(rock|ovl|lua)/, abs_path("$temp_dir/rocks/")), 'apps/plugins'); |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 445 | |
William Wilgus | 90118f1 | 2019-07-26 01:30:00 -0500 | [diff] [blame^] | 446 | #lua example scripts |
| 447 | if(-e "$ROOT/apps/plugins/lua_scripts") { |
| 448 | glob_mkdir("$temp_dir/rocks/demos/lua_scripts"); |
| 449 | glob_copy("$ROOT/apps/plugins/lua_scripts/*.lua", "$temp_dir/rocks/demos/lua_scripts/"); |
| 450 | } |
| 451 | |
Teruaki Kawashima | e5b1a7d | 2010-11-21 13:47:56 +0000 | [diff] [blame] | 452 | # exclude entries for the image file types not supported by the imageviewer for the target. |
| 453 | my $viewers = "$ROOT/apps/plugins/viewers.config"; |
| 454 | my $c="cat $viewers | gcc $cppdef -I. -I$firmdir/export -E -P -include config.h -"; |
| 455 | |
| 456 | open VIEWERS, "$c|" or die "can't open viewers.config"; |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 457 | my @viewers = <VIEWERS>; |
Linus Nielsen Feltzing | 8287ce5 | 2004-07-13 09:45:39 +0000 | [diff] [blame] | 458 | close VIEWERS; |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 459 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 460 | open VIEWERS, ">$temp_dir/viewers.config" or |
| 461 | die "can't create $temp_dir/viewers.config"; |
Jonathan Gordon | fda7d72 | 2007-08-06 13:42:52 +0000 | [diff] [blame] | 462 | |
Daniel Stenberg | af48260 | 2005-10-05 08:02:10 +0000 | [diff] [blame] | 463 | foreach my $line (@viewers) { |
| 464 | if ($line =~ /([^,]*),([^,]*),/) { |
| 465 | my ($ext, $plugin)=($1, $2); |
| 466 | my $r = "${plugin}.rock"; |
Daniel Stenberg | 006d6c5 | 2005-11-02 07:32:16 +0000 | [diff] [blame] | 467 | my $oname; |
Daniel Stenberg | af48260 | 2005-10-05 08:02:10 +0000 | [diff] [blame] | 468 | |
| 469 | my $dir = $r; |
| 470 | my $name; |
| 471 | |
| 472 | # strip off the last slash and file name part |
| 473 | $dir =~ s/(.*)\/(.*)/$1/; |
| 474 | # store the file name part |
| 475 | $name = $2; |
| 476 | |
Daniel Stenberg | 006d6c5 | 2005-11-02 07:32:16 +0000 | [diff] [blame] | 477 | # get .ovl name (file part only) |
| 478 | $oname = $name; |
| 479 | $oname =~ s/\.rock$/.ovl/; |
| 480 | |
Daniel Stenberg | af48260 | 2005-10-05 08:02:10 +0000 | [diff] [blame] | 481 | # print STDERR "$ext $plugin $dir $name $r\n"; |
| 482 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 483 | if(-e "$temp_dir/rocks/$name") { |
Daniel Stenberg | af48260 | 2005-10-05 08:02:10 +0000 | [diff] [blame] | 484 | if($dir ne "rocks") { |
| 485 | # target is not 'rocks' but the plugins are always in that |
| 486 | # dir at first! |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 487 | move("$temp_dir/rocks/$name", "$temp_dir/rocks/$r"); |
Daniel Stenberg | af48260 | 2005-10-05 08:02:10 +0000 | [diff] [blame] | 488 | } |
| 489 | print VIEWERS $line; |
Björn Stenberg | 0d53b48 | 2004-05-21 21:01:20 +0000 | [diff] [blame] | 490 | } |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 491 | elsif(-e "$temp_dir/rocks/$r") { |
Daniel Stenberg | efae754 | 2005-03-03 22:09:41 +0000 | [diff] [blame] | 492 | # in case the same plugin works for multiple extensions, it |
| 493 | # was already moved to the viewers dir |
Daniel Stenberg | af48260 | 2005-10-05 08:02:10 +0000 | [diff] [blame] | 494 | print VIEWERS $line; |
Daniel Stenberg | efae754 | 2005-03-03 22:09:41 +0000 | [diff] [blame] | 495 | } |
Daniel Stenberg | 006d6c5 | 2005-11-02 07:32:16 +0000 | [diff] [blame] | 496 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 497 | if(-e "$temp_dir/rocks/$oname") { |
Daniel Stenberg | db44b29 | 2005-03-04 08:19:56 +0000 | [diff] [blame] | 498 | # if there's an "overlay" file for the .rock, move that as |
| 499 | # well |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 500 | move("$temp_dir/rocks/$oname", "$temp_dir/rocks/$dir"); |
Daniel Stenberg | db44b29 | 2005-03-04 08:19:56 +0000 | [diff] [blame] | 501 | } |
Björn Stenberg | 0d53b48 | 2004-05-21 21:01:20 +0000 | [diff] [blame] | 502 | } |
Linus Nielsen Feltzing | 8287ce5 | 2004-07-13 09:45:39 +0000 | [diff] [blame] | 503 | } |
| 504 | close VIEWERS; |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 505 | |
Jonathan Gordon | fda7d72 | 2007-08-06 13:42:52 +0000 | [diff] [blame] | 506 | open CATEGORIES, "$ROOT/apps/plugins/CATEGORIES" or |
| 507 | die "can't open CATEGORIES"; |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 508 | my @rock_targetdirs = <CATEGORIES>; |
Jonathan Gordon | fda7d72 | 2007-08-06 13:42:52 +0000 | [diff] [blame] | 509 | close CATEGORIES; |
| 510 | foreach my $line (@rock_targetdirs) { |
| 511 | if ($line =~ /([^,]*),(.*)/) { |
| 512 | my ($plugin, $dir)=($1, $2); |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 513 | move("$temp_dir/rocks/${plugin}.rock", "$temp_dir/rocks/$dir/${plugin}.rock"); |
| 514 | if(-e "$temp_dir/rocks/${plugin}.ovl") { |
Andrew Mahone | 5621fd3 | 2009-05-07 01:23:13 +0000 | [diff] [blame] | 515 | # if there's an "overlay" file for the .rock, move that as |
| 516 | # well |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 517 | move("$temp_dir/rocks/${plugin}.ovl", "$temp_dir/rocks/$dir"); |
Andrew Mahone | 5621fd3 | 2009-05-07 01:23:13 +0000 | [diff] [blame] | 518 | } |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 519 | if(-e "$temp_dir/rocks/${plugin}.lua") { |
Maurus Cuelenaere | 78e98fd | 2009-10-28 23:05:02 +0000 | [diff] [blame] | 520 | # if this is a lua script, move it to the appropriate dir |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 521 | move("$temp_dir/rocks/${plugin}.lua", "$temp_dir/rocks/$dir/"); |
Maurus Cuelenaere | 78e98fd | 2009-10-28 23:05:02 +0000 | [diff] [blame] | 522 | } |
Jonathan Gordon | fda7d72 | 2007-08-06 13:42:52 +0000 | [diff] [blame] | 523 | } |
| 524 | } |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 525 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 526 | glob_unlink("$temp_dir/rocks/*.lua"); # Clean up unwanted *.lua files (e.g. actions.lua, buttons.lua) |
Maurus Cuelenaere | 78e98fd | 2009-10-28 23:05:02 +0000 | [diff] [blame] | 527 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 528 | copy("$ROOT/apps/tagnavi.config", "$temp_dir/"); |
| 529 | copy("$ROOT/apps/plugins/disktidy.config", "$temp_dir/rocks/apps/"); |
Linus Nielsen Feltzing | 7afbb49 | 2008-11-17 10:14:48 +0000 | [diff] [blame] | 530 | |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 531 | if($bitmap) { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 532 | copy("$ROOT/apps/plugins/sokoban.levels", "$temp_dir/rocks/games/sokoban.levels"); # sokoban levels |
| 533 | copy("$ROOT/apps/plugins/snake2.levels", "$temp_dir/rocks/games/snake2.levels"); # snake2 levels |
| 534 | copy("$ROOT/apps/plugins/rockbox-fonts.config", "$temp_dir/rocks/viewers/"); |
Jens Arnold | bdba1d0 | 2004-11-20 10:45:27 +0000 | [diff] [blame] | 535 | } |
| 536 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 537 | if(-e "$temp_dir/rocks/demos/pictureflow.rock") { |
Andrew Mahone | 802ea46 | 2009-05-23 07:55:14 +0000 | [diff] [blame] | 538 | copy("$ROOT/apps/plugins/bitmaps/native/pictureflow_emptyslide.100x100x16.bmp", |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 539 | "$temp_dir/rocks/demos/pictureflow_emptyslide.bmp"); |
Andrew Mahone | 802ea46 | 2009-05-23 07:55:14 +0000 | [diff] [blame] | 540 | my ($pf_logo); |
| 541 | if ($width < 200) { |
| 542 | $pf_logo = "pictureflow_logo.100x18x16.bmp"; |
| 543 | } else { |
| 544 | $pf_logo = "pictureflow_logo.193x34x16.bmp"; |
| 545 | } |
| 546 | copy("$ROOT/apps/plugins/bitmaps/native/$pf_logo", |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 547 | "$temp_dir/rocks/demos/pictureflow_splash.bmp"); |
Andrew Mahone | 802ea46 | 2009-05-23 07:55:14 +0000 | [diff] [blame] | 548 | |
Andrew Mahone | 932f30d | 2008-12-27 00:26:15 +0000 | [diff] [blame] | 549 | } |
| 550 | |
Jens Arnold | bdba1d0 | 2004-11-20 10:45:27 +0000 | [diff] [blame] | 551 | if($image) { |
| 552 | # image is blank when this is a simulator |
| 553 | if( filesize("rockbox.ucl") > 1000 ) { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 554 | copy("rockbox.ucl", "$temp_dir/rockbox.ucl"); # UCL for flashing |
Jens Arnold | bdba1d0 | 2004-11-20 10:45:27 +0000 | [diff] [blame] | 555 | } |
| 556 | if( filesize("rombox.ucl") > 1000) { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 557 | copy("rombox.ucl", "$temp_dir/rombox.ucl"); # UCL for flashing |
Daniel Stenberg | b156352 | 2004-06-14 15:04:46 +0000 | [diff] [blame] | 558 | } |
Miika Pekkarinen | b1af4e6 | 2007-01-08 18:21:12 +0000 | [diff] [blame] | 559 | |
| 560 | # Check for rombox.target |
| 561 | if ($image=~/(.*)\.(\w+)$/) |
| 562 | { |
| 563 | my $romfile = "rombox.$2"; |
| 564 | if (filesize($romfile) > 1000) |
| 565 | { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 566 | copy($romfile, "$temp_dir/$romfile"); |
Miika Pekkarinen | b1af4e6 | 2007-01-08 18:21:12 +0000 | [diff] [blame] | 567 | } |
| 568 | } |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 569 | } |
| 570 | |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 571 | glob_mkdir("$temp_dir/docs"); |
Daniel Stenberg | 50d40ea | 2006-03-25 22:52:28 +0000 | [diff] [blame] | 572 | for(("COPYING", |
Brandon Low | 05dccc3 | 2006-01-18 20:54:13 +0000 | [diff] [blame] | 573 | "LICENSES", |
Jonathan Gordon | 06797c2 | 2007-06-18 09:32:28 +0000 | [diff] [blame] | 574 | "KNOWN_ISSUES" |
Daniel Stenberg | 50d40ea | 2006-03-25 22:52:28 +0000 | [diff] [blame] | 575 | )) { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 576 | copy("$ROOT/docs/$_", "$temp_dir/docs/$_.txt"); |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 577 | } |
Jonathan Gordon | 06797c2 | 2007-06-18 09:32:28 +0000 | [diff] [blame] | 578 | if ($fonts) { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 579 | copy("$ROOT/docs/profontdoc.txt", "$temp_dir/docs/profontdoc.txt"); |
Jonathan Gordon | 06797c2 | 2007-06-18 09:32:28 +0000 | [diff] [blame] | 580 | } |
Paul Louden | f8b5913 | 2007-06-19 04:21:06 +0000 | [diff] [blame] | 581 | for(("sample.colours", |
Jonathan Gordon | 06797c2 | 2007-06-18 09:32:28 +0000 | [diff] [blame] | 582 | "sample.icons" |
| 583 | )) { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 584 | copy("$ROOT/docs/$_", "$temp_dir/docs/$_"); |
Jonathan Gordon | 06797c2 | 2007-06-18 09:32:28 +0000 | [diff] [blame] | 585 | } |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 586 | |
Daniel Stenberg | 51413e4 | 2005-11-14 15:06:51 +0000 | [diff] [blame] | 587 | # Now do the WPS dance |
| 588 | if(-d "$ROOT/wps") { |
Dave Chapman | efe556f | 2011-02-26 21:30:20 +0000 | [diff] [blame] | 589 | my $wps_build_cmd="perl $ROOT/wps/wpsbuild.pl "; |
| 590 | $wps_build_cmd=$wps_build_cmd."-v " if $verbose; |
| 591 | $wps_build_cmd=$wps_build_cmd." --tempdir=$temp_dir --rbdir=$rbdir -r $ROOT -m $modelname $ROOT/wps/WPSLIST $target"; |
| 592 | print "wpsbuild: $wps_build_cmd\n" if $verbose; |
Björn Stenberg | ad8d603 | 2008-11-24 22:16:07 +0000 | [diff] [blame] | 593 | system("$wps_build_cmd"); |
Dave Chapman | efe556f | 2011-02-26 21:30:20 +0000 | [diff] [blame] | 594 | print "wps_build_cmd: done\n" if $verbose; |
Daniel Stenberg | 51413e4 | 2005-11-14 15:06:51 +0000 | [diff] [blame] | 595 | } |
| 596 | else { |
| 597 | print STDERR "No wps module present, can't do the WPS magic!\n"; |
| 598 | } |
Jonathan Gordon | 3114f2c | 2009-11-16 03:53:49 +0000 | [diff] [blame] | 599 | |
| 600 | # until buildwps.pl is fixed, manually copy the classic_statusbar theme across |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 601 | mkdir "$temp_dir/wps/classic_statusbar", 0777; |
| 602 | glob_copy("$ROOT/wps/classic_statusbar/*.bmp", "$temp_dir/wps/classic_statusbar"); |
Jonathan Gordon | 3114f2c | 2009-11-16 03:53:49 +0000 | [diff] [blame] | 603 | if ($swcodec) { |
Dave Chapman | efe556f | 2011-02-26 21:30:20 +0000 | [diff] [blame] | 604 | if ($depth == 16) { |
| 605 | copy("$ROOT/wps/classic_statusbar.sbs", "$temp_dir/wps"); |
| 606 | } elsif ($depth > 1) { |
| 607 | copy("$ROOT/wps/classic_statusbar.grey.sbs", "$temp_dir/wps/classic_statusbar.sbs"); |
| 608 | } else { |
| 609 | copy("$ROOT/wps/classic_statusbar.mono.sbs", "$temp_dir/wps/classic_statusbar.sbs"); |
| 610 | } |
Jonathan Gordon | 3114f2c | 2009-11-16 03:53:49 +0000 | [diff] [blame] | 611 | } else { |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 612 | copy("$ROOT/wps/classic_statusbar.112x64x1.sbs", "$temp_dir/wps/classic_statusbar.sbs"); |
Jonathan Gordon | 3114f2c | 2009-11-16 03:53:49 +0000 | [diff] [blame] | 613 | } |
Jonathan Gordon | 6ec176c | 2009-11-20 07:05:22 +0000 | [diff] [blame] | 614 | if ($remote_depth != $depth) { |
Dave Chapman | efe556f | 2011-02-26 21:30:20 +0000 | [diff] [blame] | 615 | copy("$ROOT/wps/classic_statusbar.mono.sbs", "$temp_dir/wps/classic_statusbar.rsbs"); |
| 616 | } else { |
| 617 | copy("$temp_dir/wps/classic_statusbar.sbs", "$temp_dir/wps/classic_statusbar.rsbs"); |
| 618 | } |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 619 | copy("$temp_dir/wps/rockbox_none.sbs", "$temp_dir/wps/rockbox_none.rsbs"); |
Daniel Stenberg | 51413e4 | 2005-11-14 15:06:51 +0000 | [diff] [blame] | 620 | |
Daniel Stenberg | 10d11ff | 2007-04-20 12:53:40 +0000 | [diff] [blame] | 621 | # and the info file |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 622 | copy("rockbox-info.txt", "$temp_dir/rockbox-info.txt"); |
Daniel Stenberg | 10d11ff | 2007-04-20 12:53:40 +0000 | [diff] [blame] | 623 | |
Daniel Stenberg | 8ebbe99 | 2008-02-18 12:17:34 +0000 | [diff] [blame] | 624 | # copy the already built lng files |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 625 | glob_copy('apps/lang/*lng', "$temp_dir/langs/"); |
Dominik Riebeling | d6ef5a0 | 2012-05-19 17:14:35 +0200 | [diff] [blame] | 626 | glob_copy('apps/lang/*.zip', "$temp_dir/langs/"); |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 627 | |
Maurus Cuelenaere | bcfba08 | 2009-05-21 21:58:18 +0000 | [diff] [blame] | 628 | # copy the .lua files |
Thomas Martitz | 67d61f2 | 2010-07-25 13:44:30 +0000 | [diff] [blame] | 629 | glob_mkdir("$temp_dir/rocks/viewers/lua/"); |
| 630 | glob_copy('apps/plugins/lua/*.lua', "$temp_dir/rocks/viewers/lua/"); |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = |
| 634 | localtime(time); |
| 635 | |
| 636 | $mon+=1; |
| 637 | $year+=1900; |
| 638 | |
Daniel Stenberg | b46f1ac | 2007-03-12 12:56:35 +0000 | [diff] [blame] | 639 | #$date=sprintf("%04d%02d%02d", $year,$mon, $mday); |
| 640 | #$shortdate=sprintf("%02d%02d%02d", $year%100,$mon, $mday); |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 641 | |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 642 | # made once for all targets |
| 643 | sub runone { |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 644 | my ($target, $fonts)=@_; |
Rafaël Carré | f984a65 | 2010-07-07 18:30:17 +0000 | [diff] [blame] | 645 | |
Dave Chapman | eddf624 | 2011-02-26 21:23:20 +0000 | [diff] [blame] | 646 | # Strip the leading / from $rbdir unless we are installing an application |
| 647 | # build - the layout is different (no .rockbox, but bin/lib/share) |
| 648 | unless ($app && $install) { |
Thomas Martitz | 9c0b247 | 2010-08-01 16:15:27 +0000 | [diff] [blame] | 649 | $rbdir = substr($rbdir, 1); |
| 650 | } |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 651 | |
Björn Stenberg | ad8d603 | 2008-11-24 22:16:07 +0000 | [diff] [blame] | 652 | # build a full install .rockbox ($rbdir) directory |
Antoine Cellerier | 32c65bb | 2008-08-26 22:00:37 +0000 | [diff] [blame] | 653 | buildzip($target, $fonts); |
Daniel Stenberg | a420dc3 | 2006-05-10 21:57:08 +0000 | [diff] [blame] | 654 | |
Jonas Häggqvist | 4077f23 | 2008-07-20 22:20:32 +0000 | [diff] [blame] | 655 | unlink($output); |
Daniel Stenberg | a420dc3 | 2006-05-10 21:57:08 +0000 | [diff] [blame] | 656 | |
Jens Arnold | 96aba33 | 2008-08-26 23:21:20 +0000 | [diff] [blame] | 657 | if($fonts == 1) { |
| 658 | # Don't include image file in fonts-only package |
| 659 | undef $target; |
Daniel Stenberg | a420dc3 | 2006-05-10 21:57:08 +0000 | [diff] [blame] | 660 | } |
Jens Arnold | 96aba33 | 2008-08-26 23:21:20 +0000 | [diff] [blame] | 661 | if($target && ($target !~ /(mod|ajz|wma)\z/i)) { |
| 662 | # On some targets, the image goes into .rockbox. |
Teruaki Kawashima | 3c11c56 | 2010-09-25 14:47:11 +0000 | [diff] [blame] | 663 | copy("$target", ".rockbox/$target"); |
Jens Arnold | 96aba33 | 2008-08-26 23:21:20 +0000 | [diff] [blame] | 664 | undef $target; |
| 665 | } |
| 666 | |
Thomas Martitz | 7ed1a5f | 2009-04-12 01:28:33 +0000 | [diff] [blame] | 667 | if($install) { |
Michael Stummvoll | 1f06ca4 | 2010-12-28 10:30:46 +0000 | [diff] [blame] | 668 | if($mklinks) { |
| 669 | my $cwd = getcwd(); |
| 670 | symlink("$cwd/.rockbox", "$install/.rockbox"); |
| 671 | print "link .rockbox $install\n" if $verbose; |
| 672 | } else { |
| 673 | make_install(".rockbox", $install) or die "MKDIRFAILED\n"; |
| 674 | rmtree(".rockbox"); |
| 675 | print "rm .rockbox\n" if $verbose; |
| 676 | } |
Nils Wallménius | c6ccf75 | 2008-11-04 10:47:48 +0000 | [diff] [blame] | 677 | } |
| 678 | else { |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 679 | unless (".rockbox" eq $rbdir) { |
Thomas Martitz | 240923a | 2010-08-02 20:34:47 +0000 | [diff] [blame] | 680 | mkpath($rbdir); |
| 681 | rmtree($rbdir); |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 682 | move(".rockbox", $rbdir); |
| 683 | print "mv .rockbox $rbdir\n" if $verbose; |
| 684 | } |
Björn Stenberg | ad8d603 | 2008-11-24 22:16:07 +0000 | [diff] [blame] | 685 | system("$ziptool $output $rbdir $target >/dev/null"); |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 686 | print "$ziptool $output $rbdir $target >/dev/null\n" if $verbose; |
Teruaki Kawashima | 3c11c56 | 2010-09-25 14:47:11 +0000 | [diff] [blame] | 687 | rmtree("$rbdir"); |
| 688 | print "rm $rbdir\n" if $verbose; |
Nils Wallménius | c6ccf75 | 2008-11-04 10:47:48 +0000 | [diff] [blame] | 689 | } |
Daniel Stenberg | 760b7b9 | 2004-05-21 19:05:27 +0000 | [diff] [blame] | 690 | }; |
| 691 | |
Daniel Stenberg | cdde25b | 2005-02-18 13:47:17 +0000 | [diff] [blame] | 692 | if(!$exe) { |
| 693 | # not specified, guess! |
Daniel Stenberg | 4392463 | 2004-09-15 13:20:49 +0000 | [diff] [blame] | 694 | if($target =~ /(recorder|ondio)/i) { |
Daniel Stenberg | b156352 | 2004-06-14 15:04:46 +0000 | [diff] [blame] | 695 | $exe = "ajbrec.ajz"; |
| 696 | } |
Daniel Stenberg | 6af4a6c | 2005-01-31 19:33:39 +0000 | [diff] [blame] | 697 | elsif($target =~ /iriver/i) { |
| 698 | $exe = "rockbox.iriver"; |
| 699 | } |
Daniel Stenberg | b156352 | 2004-06-14 15:04:46 +0000 | [diff] [blame] | 700 | else { |
| 701 | $exe = "archos.mod"; |
| 702 | } |
| 703 | } |
Thomas Martitz | 35ac407 | 2010-07-13 14:17:52 +0000 | [diff] [blame] | 704 | elsif(($exe =~ /rockboxui/)) { |
Daniel Stenberg | f9e18ae | 2005-03-03 22:31:30 +0000 | [diff] [blame] | 705 | # simulator, exclude the exe file |
| 706 | $exe = ""; |
| 707 | } |
Thomas Martitz | 43cdfde | 2010-09-26 10:32:43 +0000 | [diff] [blame] | 708 | elsif($exe eq "librockbox.so") { |
| 709 | # android, exclude the binary |
| 710 | $exe=""; |
| 711 | } |
Daniel Stenberg | b156352 | 2004-06-14 15:04:46 +0000 | [diff] [blame] | 712 | |
Daniel Stenberg | 19bba74 | 2007-03-12 10:51:08 +0000 | [diff] [blame] | 713 | runone($exe, $incfonts); |