Fetching contributors…
Cannot retrieve contributors at this time
105 lines (83 sloc) 2.67 KB
#! perl
# Copyright (C) 2009 The Perl Foundation
=head1 TITLE - script to obtain and build Parrot for Rakudo
perl [--parrot --configure=options]
Maintains an appropriate copy of Parrot in the parrot/ subdirectory.
The revision of Parrot to be used in the build is given by the
use strict;
use warnings;
use 5.008;
use lib "build/lib";
use Rakudo::CompareRevisions qw(compare_parrot_revs);
# Work out slash character to use.
my $slash = $^O eq 'MSWin32' ? '\\' : '/';
## determine what revision of Parrot we require
open my $REQ, "build/PARROT_REVISION"
|| die "cannot open build/PARROT_REVISION\n";
my ($req, $reqpar) = split(' ', <$REQ>);
close $REQ;
no warnings;
if (open my $REV, '-|', "parrot_install${slash}bin${slash}parrot_config git_describe") {
my $revision = <$REV>;
close $REV;
$revision =~ s/\s.*//s;
if (compare_parrot_revs($revision, $req) >= 0) {
print "Parrot $revision already available ($req required)\n";
print "Checking out Parrot $req via git...\n";
if (-d 'parrot') {
if (-d 'parrot/.svn') {
die "===SORRY===\n"
."Your 'parrot' directory is still an SVN repository.\n"
."Parrot switched to git recently; in order to replace your\n"
."repository by a git repository, please manually delete\n"
."the 'parrot' directory, and then re-run the command that caused\n"
."this error message\n";
system_or_die(qw(git fetch));
} else {
system_or_die(qw(git clone git:// parrot));
chdir('parrot') || die "Can't chdir to 'parrot': $!";
system_or_die(qw(git checkout), $req);
## If we have a Makefile from a previous build, do a 'make realclean'
if (-f 'Makefile') {
my %config = read_parrot_config();
my $make = $config{'make'};
if ($make) {
print "\nPerforming '$make realclean' ...\n";
system_or_die($make, "realclean");
print "\nConfiguring Parrot ...\n";
my @config_command = ($^X, '', @ARGV);
print "@config_command\n";
system_or_die( @config_command );
print "\nBuilding Parrot ...\n";
my %config = read_parrot_config();
my $make = $config{'make'} or exit(1);
system_or_die($make, 'install-dev');
sub read_parrot_config {
my %config = ();
if (open my $CFG, "config_lib.pir") {
while (<$CFG>) {
if (/P0\["(.*?)"], "(.*?)"/) { $config{$1} = $2 }
close $CFG;
sub system_or_die {
my @cmd = @_;
system( @cmd ) == 0
or die "Command failed (status $?): @cmd\n";