Skip to content

Commit 77f6891

Browse files
committed
Merge branch 'master' of github.com:/perl6/nqp
2 parents 031cc32 + 6437a71 commit 77f6891

File tree

4 files changed

+67
-16
lines changed

4 files changed

+67
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ nqp-runtime.jar
5252
/nqp-m.bat
5353
/jvmconfig.properties
5454
*.moarvm
55+
MoarVM

Configure.pl

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Getopt::Long;
99
use Cwd qw/abs_path cwd/;
1010
use lib "tools/lib";
11-
use NQP::Configure qw(cmp_rev read_parrot_config
11+
use NQP::Configure qw(cmp_rev read_parrot_config gen_moar
1212
fill_template_file fill_template_text
1313
slurp system_or_die verify_install sorry gen_parrot);
1414

@@ -27,7 +27,7 @@
2727
GetOptions(\%options, 'help!', 'prefix=s',
2828
'with-parrot=s', 'gen-parrot:s',
2929
'make-install!', 'makefile-timing!',
30-
'backends=s',
30+
'backends=s', 'gen-moar:s',
3131
'parrot-config=s', 'parrot-option=s@');
3232

3333
# Print help if it's requested
@@ -56,7 +56,15 @@
5656
$backends{$be} = 1;
5757
}
5858
}
59-
else {
59+
if (defined $options{'gen-parrot'}) {
60+
$backends{parrot} = 1;
61+
$default_backend ||= 'parrot';
62+
}
63+
if (defined $options{'gen-moar'}) {
64+
$backends{moar} = 1;
65+
$default_backend ||= 'moar';
66+
}
67+
unless (%backends) {
6068
# TODO: come up with more sensible defaults
6169
$backends{parrot} = 1;
6270
$default_backend = 'parrot';
@@ -197,22 +205,15 @@
197205
}
198206
if ($backends{moar}) {
199207
my @errors;
200-
my $moar_path = "$prefix${slash}bin${slash}moar" . ($^O =~ /MSWin32/ ? '.exe' : '');
201-
my @moar_info = `$moar_path --help`;
202-
my $moar_found = 0;
203-
for (@moar_info) {
204-
if (/USAGE: moar/) {
205-
$moar_found = 1;
206-
last;
207-
}
208-
}
209-
if (!$moar_found) {
208+
my ($moar_want) = split(' ', slurp('tools/build/MOAR_REVISION'));
209+
my $moar_path = gen_moar($moar_want, %config, %options);
210+
if (!$moar_path) {
210211
push @errors,
211-
"No MoarVM (moar executable) found using the --prefix";
212+
"No suitable MoarVM (moar executable) found using the --prefix";
212213
}
213214
sorry(@errors) if @errors;
214215
$config{'make'} = $^O eq 'MSWin32' ? 'nmake' : 'make';
215-
$config{'runner'} = $^O eq 'MSWin32' ? 'nqp.bat' : 'nqp';
216+
$config{moar} = $moar_path;
216217
fill_template_file(
217218
'tools/build/Makefile-Moar.in',
218219
$MAKEFILE,

tools/build/MOAR_REVISION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2013.10-4-gb85d5e6

tools/lib/NQP/Configure.pm

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ our @EXPORT_OK = qw(sorry slurp system_or_die
1010
read_parrot_config read_config
1111
fill_template_file fill_template_text
1212
git_checkout
13-
verify_install
13+
verify_install gen_moar
1414
gen_nqp gen_parrot);
1515

1616
our $exe = $^O eq 'MSWin32' ? '.exe' : '';
@@ -31,9 +31,11 @@ our @required_nqp_files = qw(
3131

3232
our $nqp_git = 'http://github.com/perl6/nqp.git';
3333
our $par_git = 'http://github.com/parrot/parrot.git';
34+
our $moar_git= 'https://github.com/MoarVM/MoarVM.git';
3435

3536
our $nqp_push = 'git@github.com:perl6/nqp.git';
3637
our $par_push = 'git@github.com:parrot/parrot.git';
38+
our $moar_push= 'git@github.com:MoarVM/MoarVM.git';
3739

3840
sub sorry {
3941
my @msg = @_;
@@ -408,5 +410,51 @@ sub gen_parrot {
408410
return fill_template_text('@bindir@/parrot@exe@', %config);
409411
}
410412

413+
sub gen_moar {
414+
my $moar_want = shift;
415+
my %options = @_;
416+
417+
my $prefix = $options{'prefix'} || cwd()."/install";
418+
my $gen_moar = $options{'gen-moar'};
419+
my @opts = @{ $options{'moar-option'} || [] };
420+
# push @opts, "--optimize";
421+
my $startdir = cwd();
422+
423+
my $moar_exe = "$prefix/bin/moar$exe";
424+
my $moar_have = qx{ $moar_exe --version };
425+
if ($moar_have) {
426+
$moar_have = $moar_have =~ /version (\S+)/ ? $1 : undef;
427+
}
428+
429+
my $moar_ok = $moar_have && cmp_rev($moar_have, $moar_want) >= 0;
430+
if ($moar_ok) {
431+
print "Found $moar_exe version $moar_have, which is new enough.\n";
432+
return $moar_exe;
433+
}
434+
elsif ($moar_have) {
435+
print "Found $moar_exe version $moar_have, which is too old.\n";
436+
}
437+
438+
return unless defined $gen_moar;
439+
440+
my $moar_repo = git_checkout($moar_git, 'MoarVM', $gen_moar || $moar_want, $moar_push);
441+
442+
unless (cmp_rev($moar_repo, $moar_want) >= 0) {
443+
die "You asked me to build $gen_moar, but $moar_repo is not new enough to satisfy version $moar_want\n";
444+
}
445+
446+
chdir("$startdir/MoarVM") or die $!;
447+
448+
$prefix =~ s{\\}{/}g;
449+
print "\nConfiguring and building MoarVM ...\n";
450+
my @cmd = ($^X, "Configure.pl", @opts, "--prefix=\"$prefix\"", '--make-install');
451+
print "@cmd\n";
452+
system_or_die(@cmd);
453+
454+
chdir($startdir);
455+
456+
return $moar_exe;
457+
}
458+
411459

412460
1;

0 commit comments

Comments
 (0)