Skip to content

Commit d24a375

Browse files
committed
Generate a runner for MoarVM.
So after the build, ./nqp works. Needs testing on non-Windows.
1 parent eb9ac3b commit d24a375

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

tools/build/Makefile-Moar.in

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ STAGE2_OUTPUT = $(STAGE2)/$(NQP_MO_MOAR) $(STAGE2)/$(MODULE_LOADER_MOAR) \
130130
$(STAGE2)/$(QAST_MOAR) $(STAGE2)/$(P6QREGEX_MOAR) \
131131
$(STAGE2)/$(NQP_MOAR)
132132

133-
all: $(NQP_MOAR) $(P5QREGEX_MOAR)
133+
RUNNER = @runner@
134+
135+
all: $(NQP_MOAR) $(RUNNER) $(P5QREGEX_MOAR)
134136

135137
clean:
136138
$(PERL) -MExtUtils::Command -e rm_rf *.moarvm src/stage1 src/stage2 nqp nqp.bat
@@ -290,34 +292,37 @@ $(NQP_MOAR): $(STAGE2_OUTPUT)
290292
$(CP) $(STAGE2)/$(P6QREGEX_MOAR) .
291293
$(CP) $(STAGE2)/$(NQP_MOAR) .
292294

293-
$(P5QREGEX_MOAR): $(NQP_MOAR) $(P5QREGEX_SOURCES)
295+
$(RUNNER): tools/build/gen-moar-runner.pl
296+
$(PERL) tools/build/gen-moar-runner.pl "$(MOAR)"
297+
298+
$(P5QREGEX_MOAR): $(P5QREGEX_SOURCES) $(NQP_MOAR) $(RUNNER)
294299
$(MKPATH) $(STAGE2)/gen
295300
$(PERL) tools/build/gen-cat.pl moar $(P5QREGEX_SOURCES) > $(STAGE2)/$(P5QREGEX_COMBINED)
296-
$(MOAR) $(NQP_MOAR) --target=mbc --output=$(P5QREGEX_MOAR) \
301+
$(RUNNER) --target=mbc --output=$(P5QREGEX_MOAR) \
297302
$(STAGE2)/$(P5QREGEX_COMBINED)
298303

299304
## testing
300305

301306
t/*/*.t: all
302-
prove -r -v --exec "$(MOAR) $(NQP_MOAR)" $@
307+
prove -r -v --exec .@slash@$(RUNNER) $@
303308

304309
test: all
305-
prove -r --exec "$(MOAR) $(NQP_MOAR)" t/nqp t/qregex t/p5regex t/qast t/serialization
310+
prove -r --exec .@slash@$(RUNNER) t/nqp t/qregex t/p5regex t/qast t/serialization
306311

307312
test-loud: all
308-
prove -r -v --exec "$(MOAR) $(NQP_MOAR)" t/nqp t/qregex t/p5regex t/qast t/serialization
313+
prove -r -v --exec .@slash@$(RUNNER) t/nqp t/qregex t/p5regex t/qast t/serialization
309314

310315
core-test: $(RUNNER)
311-
prove -r --exec "$(MOAR) $(NQP_MOAR)" t/nqp
316+
prove -r --exec .@slash@$(RUNNER) t/nqp
312317

313318
core-test-loud: $(RUNNER)
314-
prove -r -v --exec "$(MOAR) $(NQP_MOAR)" t/nqp
319+
prove -r -v --exec .@slash@$(RUNNER) t/nqp
315320

316321
qregex-test: $(RUNNER)
317-
prove -r --exec "$(MOAR) $(NQP_MOAR)" t/qregex
322+
prove -r --exec .@slash@$(RUNNER) t/qregex
318323

319324
qregex-test-loud: $(RUNNER)
320-
prove -r -v --exec "$(MOAR) $(NQP_MOAR)" t/qregex
325+
prove -r -v --exec .@slash@$(RUNNER) t/qregex
321326

322327
# nqp::makefile <-- tells NQP::Configure to treat this file as a makefile,
323328
# performing win32 slash and makefile conversions

tools/build/gen-moar-runner.pl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/perl
2+
# Copyright (C) 2013, The Perl Foundation.
3+
4+
use strict;
5+
use warnings;
6+
use 5.008;
7+
use File::Spec;
8+
9+
my ($moar) = @ARGV;
10+
11+
if ($^O eq 'MSWin32') {
12+
my $install_to = 'nqp.bat';
13+
open my $fh, ">", $install_to
14+
or die "Could not open $install_to: $!";
15+
print $fh '@ "' . $moar . '" nqp.moarvm %*' . "\n";
16+
close $fh
17+
or die "Could not close $install_to: $!";
18+
}
19+
else {
20+
my $install_to = 'nqp';
21+
open my $fh, ">", $install_to
22+
or die "Could not open $install_to: $!";
23+
print $fh "#!/bin/sh\n";
24+
print $fh "exec $moar nqp.moarvm \"\$\@\"\n";
25+
close $fh
26+
or die "Could not close $install_to: $!";
27+
chmod 0755, $install_to;
28+
}

0 commit comments

Comments
 (0)