Skip to content
Browse files

Configure improvements

[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

Signed-off-by: Moritz Lenz <moritz@faui2k3.org>
  • Loading branch information...
1 parent f16219e commit 0bb68ee0bcd5f026866108fae42152123d042bcc @japhb japhb committed with moritz
Showing with 22 additions and 37 deletions.
  1. +14 −31 Configure.pl
  2. +8 −6 build/gen_parrot.pl
View
45 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 @@
# 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 @@ sub print_help {
--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;
View
14 build/gen_parrot.pl
@@ -7,7 +7,7 @@ =head1 TITLE
=head2 SYNOPSIS
- perl gen_parrot.pl
+ perl gen_parrot.pl [--parrot --configure=options]
=head2 DESCRIPTION
@@ -54,17 +54,19 @@ =head2 DESCRIPTION
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 {

0 comments on commit 0bb68ee

Please sign in to comment.
Something went wrong with that request. Please try again.