Skip to content

Commit

Permalink
Obtain parrot configuration from 'parrot' executable instead of
Browse files Browse the repository at this point in the history
'parrot_config'.  Option --parrot-config is now --with-parrot.
  • Loading branch information
pmichaud committed Jun 4, 2011
1 parent 640b052 commit 70da0c1
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 29 deletions.
47 changes: 28 additions & 19 deletions Configure.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
use NQP::Configure qw(cmp_rev read_parrot_config slurp system_or_die);

MAIN: {
my $exe = $NQP::Configure::exe;

my %config;
$config{'nqp_config_status'} = join(' ', map { "\"$_\""} @ARGV);

my %options;
GetOptions(\%options, 'help!', 'parrot-config=s', 'prefix=s',
'gen-parrot!', 'gen-parrot-option=s@', 'min-parrot-revision=s',
GetOptions(\%options, 'help!', 'prefix=s',
'with-parrot=s', 'parrot-config=s',
'gen-parrot!', 'parrot-option=s@', 'min-parrot-revision=s',
'make-install!');

# Print help if it's requested
Expand All @@ -24,17 +27,24 @@
exit(0);
}

# Deprecated --parrot-config option
if ($options{'parrot-config'}) {
die "===SORRY!===\n"
. "The --parrot-config option has been removed.\n"
. "Use --with-parrot to specify the parrot executable to use.\n";
}

# Save options in config.status
if (open(my $CONFIG_STATUS, '>', 'config.status')) {
print $CONFIG_STATUS
"$^X Configure.pl $config{'nqp_config_status'} \$*\n";
close($CONFIG_STATUS);
}

my $parrot_config_exe = $options{'parrot-config'};
my $parrot_exe = $options{'with-parrot'};

if ($options{'gen-parrot'}) {
my @opts = @{ $options{'gen-parrot-option'} || [] };
my @opts = @{ $options{'parrot-option'} || [] };
push @opts, "--min-parrot-revision=$options{'min-parrot-revision'}"
if $options{'min-parrot-revision'};
my $prefix = $options{'prefix'} || cwd()."/install";
Expand All @@ -44,24 +54,23 @@
print "@cmd\n\n";
system_or_die(@cmd);
# use the newly-built parrot config
$parrot_config_exe = "$prefix/bin/parrot_config";
$parrot_exe= "$prefix/bin/parrot$exe";
}

my %parrot_config;
if ($parrot_config_exe) {
%parrot_config = read_parrot_config($parrot_config_exe);
if ($parrot_exe) {
%parrot_config = read_parrot_config($parrot_exe);
}
else {
# look in some standard locations
%parrot_config = read_parrot_config(qw(
install/bin/parrot_config
parrot_config
));
%parrot_config = read_parrot_config(
( "install/bin/parrot$exe", "parrot" )
);
}

my $errors;
if (!%parrot_config) {
$errors .= "Unable to locate parrot_config\n";
$errors .= "Unable to locate parrot\n";
}
%config = (%config, %parrot_config);

Expand All @@ -80,8 +89,8 @@
$errors
To automatically checkout (git) and build a copy of parrot $revision_want,
try re-running Configure.pl with the '--gen-parrot' option.
Or, use the the '--parrot-config' option to explicitly specify
the location of parrot_config to be used to build NQP.
Or, use the the '--with-parrot=' option to explicitly specify
the location of the parrot executable to be used to build NQP.
END
}
Expand Down Expand Up @@ -187,12 +196,12 @@ sub print_help {
General Options:
--help Show this text
--gen-parrot Download and build a copy of Parrot to use
--prefix=dir Install files in dir
--parrot-config=path/to/parrot_config
Use information from existing parrot_config
--gen-parrot-option='--option=value'
Pass option(s) to --gen-parrot configuration
--with-parrot=path/to/bin/parrot
Parrot executable to use to build NQP
--gen-parrot Download and build a copy of Parrot to use
--parrot-option='--option=value'
Options to pass to parrot configuration for --gen-parrot
END

return;
Expand Down
14 changes: 8 additions & 6 deletions tools/build/gen-parrot.pl
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@
my %options;
GetOptions(\%options, 'help!', 'prefix=s', 'min-parrot-revision=s');

my $exe = $NQP::Configure::exe;

# Print help if it's requested
if ($options{'help'}) {
print_help();
exit(0);
}

my $prefix = $options{'prefix'} || cwd()."/install";
my $revision_want = $options{'min-parrot-revision'};
my $prefix = $options{'prefix'} || cwd()."/install";
my $revision_want = $options{'min-parrot-revision'};
if (!defined $revision_want) {
($revision_want) = split(' ', slurp("tools/build/PARROT_REVISION"));
}
my $parrot_config_exe = "$options{'prefix'}/bin/parrot_config";
my %parrot_config = read_parrot_config($parrot_config_exe);
my $revision_have = %parrot_config
&& $parrot_config{'parrot::git_describe'};
my $parrot_exe = "$options{'prefix'}/bin/parrot$exe";
my %parrot_config = read_parrot_config($parrot_exe);
my $revision_have = %parrot_config
&& $parrot_config{'parrot::git_describe'};

if ($revision_have && cmp_rev($revision_have, $revision_want) >= 0) {
print "Parrot $revision_have already available",
Expand Down
46 changes: 46 additions & 0 deletions tools/build/parrot-config.pir
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env parrot

=head1 NAME

parrot-config.pir - display Parrot configuration for NQP

=head1 SYNOPSIS

./parrot parrot-config.pir ccflags

=head1 DESCRIPTION

Display the contents of Parrot's IGLOBALS_CONFIG_HASH, prefacing each
key with "parrot::".
Print out configuration items.
=cut
.include 'iglobals.pasm'
.sub "main" :main
.local pmc interp, config_hash, config_iter
interp = getinterp
config_hash = interp[.IGLOBALS_CONFIG_HASH]
config_iter = iter config_hash
config_loop:
unless config_iter goto config_done
$P0 = shift config_iter
print "parrot::"
$S0 = $P0.'key'()
print $S0
print "="
$S0 = $P0.'value'()
print $S0
print "\n"
goto config_loop
config_done:
.return ()
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
10 changes: 6 additions & 4 deletions tools/lib/NQP/Configure.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use warnings;
use base qw(Exporter);
our @EXPORT_OK = qw(cmp_rev read_parrot_config slurp system_or_die);

our $exe = $^O eq 'MSWin32' ? '.exe' : '';

sub parse_revision {
my $rev = shift;
my $sep = qr/[_.]/;
Expand Down Expand Up @@ -32,12 +34,12 @@ sub read_parrot_config {
my %config = ();
for my $file (@parrot_config_src) {
no warnings;
if (open my $PARROT_CONFIG, '-|', "$file --dump") {
if (open my $PARROT, '-|', "$file tools/build/parrot-config.pir") {
print "\nReading configuration information from $file ...\n";
while (<$PARROT_CONFIG>) {
if (/(\w+) => '(.*)'/) { $config{"parrot::$1"} = $2 }
while (<$PARROT>) {
if (/^([\w:]+)=(.*)/) { $config{$1} = $2 }
}
close($PARROT_CONFIG) or die $!;
close($PARROT) or die $!;
}
elsif (-r $file && open my $PARROT_CONFIG, '<', $file) {
print "\nReading configuration information from $file ...\n";
Expand Down

0 comments on commit 70da0c1

Please sign in to comment.