From 66ae34b69f031e1eaa563afb3cf7976ddcf289da Mon Sep 17 00:00:00 2001 From: Alex Bennee Date: Thu, 20 Nov 2008 17:48:14 +0000 Subject: [PATCH] Clean-up wpsbuild with some perl love. Allow passing of alternate rockbox dir --- tools/buildzip.pl | 15 +++++-- wps/wpsbuild.pl | 106 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 80 insertions(+), 41 deletions(-) diff --git a/tools/buildzip.pl b/tools/buildzip.pl index 1e5ed59..db79d1f 100755 --- a/tools/buildzip.pl +++ b/tools/buildzip.pl @@ -14,7 +14,7 @@ use File::Copy; # For move() and copy() use File::Find; # For find() use File::Path; # For rmtree() use Cwd 'abs_path'; -use Getopt::Long qw(:config pass_through); # pass_through so not +use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF my $ROOT=".."; @@ -29,7 +29,7 @@ my $incfonts; my $target_id; # passed in, not currently used my $rockbox_root=".rockbox"; # can be changed for special builds -# confused by -DTYPE_STUFF + sub glob_copy { my ($pattern, $destination) = @_; @@ -75,7 +75,9 @@ GetOptions ( 'r|root=s' => \$ROOT, 'o|output=s' => \$output, 'f|fonts=s' => \$incfonts, # 0 - no fonts, 1 - fonts only 2 - fonts and package 'v|verbose' => \$verbose, - 's|sim' => \$sim ); + 's|sim' => \$sim, + 'rockroot=s' => \$rockbox_root, # If we want to put in a different directory + ); ($target, $exe) = @ARGV; @@ -384,7 +386,12 @@ STOP # Now do the WPS dance if(-d "$ROOT/wps") { - system("perl $ROOT/wps/wpsbuild.pl -r $ROOT $ROOT/wps/WPSLIST $target"); + my $wps_build_cmd="perl $ROOT/wps/wpsbuild.pl "; + $wps_build_cmd=$wps_build_cmd."-v " if $verbose; + $wps_build_cmd=$wps_build_cmd." --rockroot=$rockbox_root -r $ROOT $ROOT/wps/WPSLIST $target"; + print "wpsbuild: $wps_build_cmd\n" if $verbose; + system("$wps_build_cmd"); + print "wps_build_cmd: done\n" if $verbose; } else { print STDERR "No wps module present, can't do the WPS magic!\n"; diff --git a/wps/wpsbuild.pl b/wps/wpsbuild.pl index f7d0952..f438613 100755 --- a/wps/wpsbuild.pl +++ b/wps/wpsbuild.pl @@ -8,32 +8,60 @@ # $Id$ # -$ROOT=".."; - -if($ARGV[0] eq "-r") { - $ROOT=$ARGV[1]; - shift @ARGV; - shift @ARGV; -} +use strict; +use Getopt::Long qw(:config pass_through); # pass_through so not confused by -DTYPE_STUFF +my $ROOT=".."; my $verbose; -if($ARGV[0] eq "-v") { - $verbose =1; - shift @ARGV; -} - my $firmdir="$ROOT/firmware"; +my $rockbox_root=".rockbox"; +my $wpslist; +my $target; -my $wpslist=$ARGV[0]; +# Get options +GetOptions ( 'r|root=s' => \$ROOT, + 'v|verbose' => \$verbose, + 'rockroot=s' => \$rockbox_root, # If we want to put in a different directory + ); + +($wpslist, $target) = @ARGV; -my $target = $ARGV[1]; my $cppdef = $target; my @depthlist = ( 16, 8, 4, 2, 1 ); +# These parameters are filled in as we parse wpslist +my $wps; +my $wps_prefix; +my $rwps; +my $width; +my $height; +my $font; +my $fgcolor; +my $bgcolor; +my $statusbar; +my $author; +my $req_g; +my $req_g_wps; +my $req_t_wps; +my $backdrop; +my $lineselectstart; +my $lineselectend; +my $selecttype; +my $iconset; +my $viewericon; +my $lineselecttextcolor; +my $filetylecolor; + +# LCD sizes +my ($main_height, $main_width, $main_depth); +my ($remote_height, $remote_width, $remote_depth); +my $has_remote; + + if(!$wpslist) { print "Usage: wpsbuilds.pl \n", "Run this script in the root of the target build, and it will put all the\n", - "stuff in .rockbox/wps/\n"; + "stuff in $rockbox_root/wps/\n"; exit; } @@ -71,7 +99,7 @@ STOP open(GETSIZE, "$c|"); - my ($height, $width); + my ($height, $width, $depth); while() { if($_ =~ /^Height: (\d*)/) { $height = $1; @@ -96,15 +124,15 @@ sub mkdirs { my $wpsdir = $wps; $wpsdir =~ s/\.(r|)wps//; - mkdir ".rockbox/wps", 0777; - mkdir ".rockbox/themes", 0777; + mkdir "$rockbox_root/wps", 0777; + mkdir "$rockbox_root/themes", 0777; - if( -d ".rockbox/wps/$wpsdir") { + if( -d "$rockbox_root/wps/$wpsdir") { #print STDERR "wpsbuild warning: directory wps/$wpsdir already exists!\n"; } else { - mkdir ".rockbox/wps/$wpsdir", 0777; + mkdir "$rockbox_root/wps/$wpsdir", 0777; } } @@ -112,9 +140,9 @@ sub copybackdrop { #copy the backdrop file into the build dir if ($backdrop ne '') { - $dst = $backdrop; + my $dst = $backdrop; $dst =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//; - $cmd = "cp $ROOT/$backdrop .rockbox/$dst"; + my $cmd = "cp $ROOT/$backdrop $rockbox_root/$dst"; `$cmd`; } } @@ -123,10 +151,10 @@ sub copythemefont { #copy the font specified by the theme - $o=$font; + my $o=$font; $o =~ s/\.fnt/\.bdf/; - `mkdir .rockbox/fonts/ >/dev/null 2>&1`; - $cmd ="$ROOT/tools/convbdf -f -o \".rockbox/fonts/$font\" \"$ROOT/fonts/$o\" "; + mkdir "$rockbox_root/fonts"; + my $cmd ="$ROOT/tools/convbdf -f -o \"$rockbox_root/fonts/$font\" \"$ROOT/fonts/$o\" "; `$cmd`; } @@ -164,10 +192,10 @@ sub copywps # print "$req_t_wps $req_g_wps\n"; if (-e "$dir/$req_t_wps" ) { - system("cp $dir/$req_t_wps .rockbox/wps/$wps"); + system("cp $dir/$req_t_wps $rockbox_root/wps/$wps"); } elsif (-e "$dir/$req_g_wps") { - system("cp $dir/$req_g_wps .rockbox/wps/$wps"); + system("cp $dir/$req_g_wps $rockbox_root/wps/$wps"); open(WPSFILE, "$dir/$req_g_wps"); while () { @@ -178,12 +206,12 @@ sub copywps if ($#filelist >= 0) { if (-e "$dir/$wps_prefix/$req_g") { foreach $file (@filelist) { - system("cp $dir/$wps_prefix/$req_g/$file .rockbox/wps/$wps_prefix/"); + system("cp $dir/$wps_prefix/$req_g/$file $rockbox_root/wps/$wps_prefix/"); } } elsif (-e "$dir/$wps_prefix") { foreach $file (@filelist) { - system("cp $dir/$wps_prefix/$file .rockbox/wps/$wps_prefix/"); + system("cp $dir/$wps_prefix/$file $rockbox_root/wps/$wps_prefix/"); } } else { @@ -210,11 +238,11 @@ sub buildcfg { \# $cfg generated by wpsbuild.pl \# $wps is made by $author \# -wps: /.rockbox/wps/$wps +wps: /$rockbox_root/wps/$wps MOO ; if($font) { - push @out, "font: /.rockbox/fonts/$font\n"; + push @out, "font: /$rockbox_root/fonts/$font\n"; } if($fgcolor && $main_depth > 2) { push @out, "foreground color: $fgcolor\n"; @@ -231,7 +259,7 @@ MOO } else { # clip resolution from filename $backdrop =~ s/(\.[0-9]*x[0-9]*x[0-9]*)//; - push @out, "backdrop: /.rockbox/$backdrop\n"; + push @out, "backdrop: /$rockbox_root/$backdrop\n"; } } if($lineselectstart && $main_depth > 2) { @@ -256,13 +284,13 @@ MOO push @out, "filetype colours: $filetylecolor\n"; } if($rwps && $has_remote ) { - push @out, "rwps: /.rockbox/wps/$rwps\n"; + push @out, "rwps: /$rockbox_root/wps/$rwps\n"; } - if(-f ".rockbox/wps/$cfg") { + if(-f "$rockbox_root/wps/$cfg") { print STDERR "wpsbuild warning: wps/$cfg already exists!\n"; } else { - open(CFG, ">.rockbox/themes/$cfg"); + open(CFG, ">$rockbox_root/themes/$cfg"); print CFG @out; close(CFG); } @@ -273,11 +301,15 @@ MOO ($remote_height, $remote_width, $remote_depth) = getlcdsizes(1); #print "LCD: ${main_height}x${main_width}x${main_depth}\n"; -$has_remote = 1 if ($remote_height && $remote_width && remote_depth); +$has_remote = 1 if ($remote_height && $remote_width && $remote_depth); + +my $isrwps; +my $within; open(WPS, "<$wpslist"); while() { my $l = $_; + # remove CR $l =~ s/\r//g; if($l =~ /^ *\#/) { @@ -334,7 +366,7 @@ while() { my $wpsdir = $1; # If this WPS installable on this platform, one of the following # two files will be present - foreach $d (@depthlist) { + foreach my $d (@depthlist) { next if ($d > $rdepth); $req_g = $rwidth . "x" . $rheight . "x" . $d; -- 1.5.6.4