Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
Geoffry Broadwell authored and moritz committed Apr 4, 2009
1 parent f16219e commit 0bb68ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 37 deletions.
45 changes: 14 additions & 31 deletions 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'}) {
Expand All @@ -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.
Expand Down Expand Up @@ -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 }
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 8 additions & 6 deletions build/gen_parrot.pl
Expand Up @@ -7,7 +7,7 @@ =head1 TITLE
=head2 SYNOPSIS
perl gen_parrot.pl
perl gen_parrot.pl [--parrot --configure=options]
=head2 DESCRIPTION
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0bb68ee

Please sign in to comment.