From: Nicholas Clark Date: Tue, 27 Jan 2009 21:59:02 +0000 (+0000) Subject: In buildext.pl, refactor the @ARGV parsing into a single loop. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4feb7f09863104b519a817212830509fc1dd677e;p=p5sagit%2Fp5-mst-13.2.git In buildext.pl, refactor the @ARGV parsing into a single loop. --- diff --git a/win32/buildext.pl b/win32/buildext.pl index f8cc432..675523d 100644 --- a/win32/buildext.pl +++ b/win32/buildext.pl @@ -33,20 +33,35 @@ use FindExt; use Config; # @ARGV with '!' at first position are exclusions -my %excl = map {$_=>1} map {/^!(.*)$/} @ARGV; -@ARGV = grep {!/^!/} @ARGV; # @ARGV with '+' at first position are inclusions -my %incl = map {$_=>1} map {/^\+(.*)$/} @ARGV; -@ARGV = grep {!/^\+/} @ARGV; - -# --static/--dynamic -my %opts = map {$_=>1} map {/^--([\w\-]+)$/} @ARGV; -@ARGV = grep {!/^--([\w\-]+)$/} @ARGV; -my ($static,$dynamic) = ((exists $opts{static}?1:0),(exists $opts{dynamic}?1:0)); -if ("$static,$dynamic" eq "0,0") { - ($static,$dynamic) = (1,1); +# -- are long options. + +my %excl, %incl, +my @argv; + +foreach (@ARGV) { + if (/^!(.*)$/) { + $excl{$1} = 1; + } elsif (/^\+(.*)$/) { + $incl{$1} = 1; + } elsif (/^--([\w\-]+)$/) { + $opts{$1} = 1; + } else { + push @argv, $_; + } } +my $static = $opts{static}; +my $dynamic = $opts{dynamic}; + +$static = $dynamic = 1 unless $static or $dynamic; + +my $make = shift @argv; +$make .= " " . shift @argv while $argv[0] =~ /^-/; +my $dep = shift @argv; +my $dir = shift @argv; +my $targ = shift @argv; + (my $here = getcwd()) =~ s{/}{\\}g; my $perl = $^X; if ($perl =~ m#^\.\.#) { @@ -61,13 +76,9 @@ unless (-f "$pl2bat.bat") { print "@args\n"; system(@args) unless defined $::Cross::platform; } -my $make = shift; -$make .= " ".shift while $ARGV[0]=~/^-/; -my $dep = shift; + my $dmod = -M $dep; -my $dir = shift; chdir($dir) || die "Cannot cd to $dir\n"; -my $targ = shift; (my $ext = getcwd()) =~ s{/}{\\}g; my $code; FindExt::scan_ext($ext);