# New Ticket Created by Geoffrey Broadwell # Please include the string: [perl #64440] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=64440 >
Attached patch squashes the following: [Configure] Use Getopt::Long instead of manual options parsing [Configure] Add --parrot-opt passthrough to parrot configure [gen_parrot.pl] Pass @ARGV to Configure; exit on Configure fail; visual tweaks [Configure] Visual tweaks Diffstat: Configure.pl | 45 ++++++++++++++------------------------------- build/gen_parrot.pl | 14 ++++++++------ 2 files changed, 22 insertions(+), 37 deletions(-) -'f
diff --git a/Configure.pl b/Configure.pl index 8d566a9..6e24616 100644 --- a/Configure.pl +++ b/Configure.pl @@ -1,19 +1,14 @@ #! perl # Copyright (C) 2009 The Perl Foundation +use 5.008; use strict; use warnings; -use 5.008; +use Getopt::Long; MAIN: { - my %valid_options = ( - 'help' => 'Display configuration help', - 'parrot-config' => 'Use configuration given by parrot_config binary', - 'gen-parrot' => 'Automatically retrieve and build Parrot', - ); - - # Get any options from the command line - my %options = get_command_options( \%valid_options ); + my %options; + GetOptions(\%options, 'help!', 'parrot-config=s', 'gen-parrot!', 'parrot-opt=s@'); # Print help if it's requested if ($options{'help'}) { @@ -23,7 +18,12 @@ MAIN: { # Update/generate parrot build if needed if ($options{'gen-parrot'}) { - system($^X, "build/gen_parrot.pl"); + my @opts = $options{'parrot-opt'} ? @{$options{'parrot-opt'}} : (); + my @command = ($^X, "build/gen_parrot.pl", @opts); + + print "Generating Parrot ...\n"; + print "@command\n\n"; + system @command; } # Get a list of parrot-configs to invoke. @@ -66,31 +66,13 @@ END } -# Process command line arguments into a hash. -sub get_command_options { - my $valid_options = shift; - - my %options = (); - for my $arg (@ARGV) { - if ($arg =~ /^--(\w[-\w]*)(?:=(.*))?/ && $valid_options->{$1}) { - my ($key, $value) = ($1, $2); - $value = 1 unless defined $value; - $options{$key} = $value; - next; - } - die qq/Invalid option "$arg". See "perl Configure.pl --help" for valid options.\n/; - } - return %options; -} - - sub read_parrot_config { my @parrot_config_exe = @_; my %config = (); for my $exe (@parrot_config_exe) { no warnings; if (open my $PARROT_CONFIG, '-|', "$exe --dump") { - print "Reading configuration information from $exe\n"; + print "\nReading configuration information from $exe ...\n"; while (<$PARROT_CONFIG>) { if (/(\w+) => '(.*)'/) { $config{$1} = $2 } } @@ -116,7 +98,7 @@ sub create_makefile { } my $outfile = 'Makefile'; - print "Creating $outfile\n"; + print "\nCreating $outfile ...\n"; open(my $MAKEOUT, '>', $outfile) || die "Unable to write $outfile\n"; print {$MAKEOUT} $maketext; @@ -147,7 +129,8 @@ General Options: --gen-parrot Download and build a copy of Parrot to use --parrot-config=(config) Use configuration information from config - + --parrot-opt='--option=value' + Set parrot config option when using --gen-parrot END return; diff --git a/build/gen_parrot.pl b/build/gen_parrot.pl index adc5bac..a77223a 100644 --- a/build/gen_parrot.pl +++ b/build/gen_parrot.pl @@ -7,7 +7,7 @@ gen_parrot.pl - script to obtain and build Parrot for Rakudo =head2 SYNOPSIS - perl gen_parrot.pl + perl gen_parrot.pl [--parrot --configure=options] =head2 DESCRIPTION @@ -54,17 +54,19 @@ if (-f 'Makefile') { my %config = read_parrot_config(); my $make = $config{'make'}; if ($make) { - print "Performing '$make realclean'\n"; + print "\nPerforming '$make realclean' ...\n"; system($make, "realclean"); } } -## Configure Parrot -system($^X, "Configure.pl"); +print "\nConfiguring Parrot ...\n"; +my @config_command = ($^X, 'Configure.pl', @ARGV); +print "@config_command\n"; +system @config_command; +print "\nBuilding Parrot ...\n"; my %config = read_parrot_config(); -my $make = $config{'make'}; - +my $make = $config{'make'} or exit(1); system($make); sub read_parrot_config {