aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorpmichaud <pmichaud@pobox.com>2010-07-27 15:22:02 -0500
committerpmichaud <pmichaud@pobox.com>2010-07-27 15:22:02 -0500
commit3d63808fe750acf7fd7ba319ddc284e8d1e50c38 (patch)
tree59f9cce47788084530eceff536ecbdd338153961 /build
parent5cfe6b289455ffb2d0a17f1cab70f96083df0447 (diff)
Add gen_parrot.pl script.
Diffstat (limited to 'build')
-rw-r--r--build/gen_parrot.pl84
1 files changed, 84 insertions, 0 deletions
diff --git a/build/gen_parrot.pl b/build/gen_parrot.pl
new file mode 100644
index 0000000..b5faaa2
--- /dev/null
+++ b/build/gen_parrot.pl
@@ -0,0 +1,84 @@
+#! perl
+# Copyright (C) 2009 The Perl Foundation
+
+=head1 TITLE
+
+gen_parrot.pl - script to obtain and build Parrot for Rakudo
+
+=head2 SYNOPSIS
+
+ perl gen_parrot.pl [--parrot --configure=options]
+
+=head2 DESCRIPTION
+
+Maintains an appropriate copy of Parrot in the parrot/ subdirectory.
+The revision of Parrot to be used in the build is given by the
+build/PARROT_REVISION file.
+
+=cut
+
+use strict;
+use warnings;
+use 5.008;
+
+# 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 ($reqsvn, $reqpar) = split(' ', <$REQ>);
+$reqsvn += 0;
+close $REQ;
+
+{
+ no warnings;
+ if (open my $REV, '-|', "parrot_install${slash}bin${slash}parrot_config revision") {
+ my $revision = 0+<$REV>;
+ close $REV;
+ if ($revision >= $reqsvn) { print "Parrot r$revision already available (r$reqsvn required)\n";
+ exit(0);
+ }
+ }
+}
+
+chdir('parrot-2.6.0') || die "Can't chdir to 'parrot-2.6.0': $!";
+
+
+## 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, 'Configure.pl', @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;
+ }
+ %config;
+}
+
+sub system_or_die {
+ my @cmd = @_;
+
+ system( @cmd ) == 0
+ or die "Command failed (status $?): @cmd\n";
+}