Skip to content

Commit

Permalink
Convert create-moar-runner to perl 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Leont committed Apr 24, 2016
1 parent 8a5b0be commit 531a044
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 42 deletions.
4 changes: 2 additions & 2 deletions Configure.pl
Expand Up @@ -271,8 +271,8 @@
unless ($win) {
$config{'m_cleanups'} = " \$(M_GDB_RUNNER) \\\n \$(M_VALGRIND_RUNNER)";
$config{'m_all'} = '$(M_GDB_RUNNER) $(M_VALGRIND_RUNNER)';
$config{'m_install'} = ' $(PERL) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-gdb-m "$(PERL6_LANG_DIR)/runtime" "gdb" "$(M_LIBPATH)" "$(PERL6_LANG_DIR)/lib" "$(PERL6_LANG_DIR)/runtime"' . "\n"
. ' $(PERL) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-valgrind-m "$(PERL6_LANG_DIR)/runtime" "valgrind" "$(M_LIBPATH)" "$(PERL6_LANG_DIR)/lib" "$(PERL6_LANG_DIR)/runtime"';
$config{'m_install'} = ' $(M_RUN_PERL6) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-gdb-m "$(PERL6_LANG_DIR)/runtime" "gdb" "$(M_LIBPATH)" "$(PERL6_LANG_DIR)/lib" "$(PERL6_LANG_DIR)/runtime"' . "\n"
. ' $(M_RUN_PERL6) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-valgrind-m "$(PERL6_LANG_DIR)/runtime" "valgrind" "$(M_LIBPATH)" "$(PERL6_LANG_DIR)/lib" "$(PERL6_LANG_DIR)/runtime"';
}

unless (@errors) {
Expand Down
14 changes: 7 additions & 7 deletions tools/build/Makefile-Moar.in
Expand Up @@ -155,7 +155,7 @@ $(R_SETTING_MOAR): $(PERL6_MOAR) $(SETTING_MOAR) $(R_SETTING_SRC)

$(M_RUNNER): tools/build/create-moar-runner.pl $(PERL6_MOAR)
$(RM_F) $(M_RUNNER)
$(PERL5) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm perl6-m . "" "$(M_LIBPATH)" .
$(M_RUN_PERL6) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm perl6-m . "" "$(M_LIBPATH)" .
-$(CHMOD) 755 $(M_RUNNER)

m-runner-default: $(M_RUNNER)
Expand All @@ -169,16 +169,16 @@ $(PERL6_DEBUG_MOAR): src/perl6-debug.nqp $(PERL6_MOAR)
--vmlibs=$(M_PERL6_OPS_DLL)=Rakudo_ops_init $(M_BUILD_DIR)/m-perl6-debug.nqp

$(M_DEBUG_RUNNER): tools/build/create-moar-runner.pl $(PERL6_DEBUG_MOAR)
$(PERL5) tools/build/create-moar-runner.pl "$(MOAR)" perl6-debug.moarvm perl6-debug-m . "" "$(M_LIBPATH)" .
$(M_RUN_PERL6) tools/build/create-moar-runner.pl "$(MOAR)" perl6-debug.moarvm perl6-debug-m . "" "$(M_LIBPATH)" .

$(M_GDB_RUNNER): tools/build/create-moar-runner.pl $(PERL6_MOAR)
$(RM_F) $(M_GDB_RUNNER)
$(PERL5) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm perl6-gdb-m . "gdb" "$(M_LIBPATH)" .
$(M_RUN_PERL6) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm perl6-gdb-m . "gdb" "$(M_LIBPATH)" .
-$(CHMOD) 755 $(M_GDB_RUNNER)

$(M_VALGRIND_RUNNER): tools/build/create-moar-runner.pl $(PERL6_MOAR)
$(RM_F) $(M_VALGRIND_RUNNER)
$(PERL5) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm perl6-valgrind-m . "valgrind" "$(M_LIBPATH)" .
$(M_RUN_PERL6) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm perl6-valgrind-m . "valgrind" "$(M_LIBPATH)" .
-$(CHMOD) 755 $(M_VALGRIND_RUNNER)


Expand Down Expand Up @@ -247,13 +247,13 @@ m-install: m-all tools/build/create-moar-runner.pl tools/build/install-core-dist
$(MKPATH) $(DESTDIR)$(PERL6_LANG_DIR)/site/bin
$(MKPATH) $(DESTDIR)$(PERL6_LANG_DIR)/site/short
.@slash@$(M_RUNNER) tools/build/install-core-dist.pl $(DESTDIR)$(PERL6_LANG_DIR)
$(PERL5) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-m "$(PERL6_LANG_DIR)/runtime" "" "$(M_LIBPATH)" "$(PERL6_LANG_DIR)/lib" "$(PERL6_LANG_DIR)/runtime"
$(PERL5) tools/build/create-moar-runner.pl "$(MOAR)" perl6-debug.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-debug-m "$(PERL6_LANG_DIR)/runtime" "" "$(M_LIBPATH)" "$(PERL6_LANG_DIR)/lib" "$(PERL6_LANG_DIR)/runtime"
$(M_RUN_PERL6) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-m "$(PERL6_LANG_DIR)/runtime" "" "$(M_LIBPATH)" "$(PERL6_LANG_DIR)/lib" "$(PERL6_LANG_DIR)/runtime"
$(M_RUN_PERL6) tools/build/create-moar-runner.pl "$(MOAR)" perl6-debug.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-debug-m "$(PERL6_LANG_DIR)/runtime" "" "$(M_LIBPATH)" "$(PERL6_LANG_DIR)/lib" "$(PERL6_LANG_DIR)/runtime"
$(CHMOD) 755 $(DESTDIR)$(PREFIX)/bin/perl6-m$(M_BAT)
@m_install@

m-runner-default-install: m-install
$(PERL5) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-m "$(PERL6_LANG_DIR)/runtime" "" "$(M_LIBPATH)" "$(PERL6_LANG_DIR)/lib" "$(PERL6_LANG_DIR)/runtime"
$(M_RUN_PERL6) tools/build/create-moar-runner.pl "$(MOAR)" perl6.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-m "$(PERL6_LANG_DIR)/runtime" "" "$(M_LIBPATH)" "$(PERL6_LANG_DIR)/lib" "$(PERL6_LANG_DIR)/runtime"
$(CP) $(DESTDIR)$(PREFIX)/bin/perl6-m$(M_BAT) $(DESTDIR)$(PREFIX)/bin/perl6$(M_BAT)
$(CHMOD) 755 $(DESTDIR)$(PREFIX)/bin/perl6$(M_BAT)

Expand Down
55 changes: 22 additions & 33 deletions tools/build/create-moar-runner.pl
@@ -1,28 +1,22 @@
#!/usr/bin/perl
#! perl6
# Copyright (C) 2013, The Perl Foundation.

use strict;
use warnings;
use 5.008;
use File::Spec;
use v6;

my ($moar, $mbc, $install_to, $p6_mbc_path, $toolchain, @libpaths) = @ARGV;
$p6_mbc_path = File::Spec->rel2abs($p6_mbc_path || '.');
my ($moar, $mbc, $install_to, $p6_mbc_path, $toolchain, @libpaths) = @*ARGS;
$p6_mbc_path = $*SPEC.rel2abs($p6_mbc_path || $*SPEC.curdir);

if ($^O eq 'MSWin32') {
if ($*DISTRO eq 'MSWin32') {
exit if $toolchain;
$install_to .= '.bat';
open my $fh, ">", $install_to
or die "Could not open $install_to: $!";
printf $fh q[@ "%s" --execname="%%~dpf0" --libpath="%s" %s\\%s %%*] . "\n",
$moar, join('" --libpath="', @libpaths), $p6_mbc_path, $mbc;
close $fh
or die "Could not close $install_to: $!";
$install_to ~= '.bat';
my $fh = open $install_to, :w;
$fh.print(sprintf(qq[@ "%s" --execname="%%~dpf0" --libpath="%s" %s\\%s %%*\n],
$moar, @libpaths.join('" --libpath="'), $p6_mbc_path, $mbc));
$fh.close;
}
elsif ($toolchain eq 'gdb') {
open my $fh, ">", $install_to
or die "Could not open $install_to: $!";
printf $fh <<'EOS', ($moar, join('" --libpath="', @libpaths), $p6_mbc_path, $mbc) x 2;
my $fh = open $install_to, :w;
$fh.print(sprintf(q:to/EOS/, ($moar, @libpaths.join('" --libpath="'), $p6_mbc_path, $mbc) xx 2));
#!/bin/sh
%s --execname="$0" --libpath="%s" %s/%s -e '
say "=" x 96;
Expand All @@ -39,14 +33,12 @@
say "-" x 96;'
gdb --quiet --ex=run --args %s --execname="$0" --libpath="%s" %s/%s "$@"
EOS
close $fh
or die "Could not close $install_to: $!";
chmod 0755, $install_to;
$fh.close;
chmod(0o755, $install_to);
}
elsif ($toolchain eq 'valgrind') {
open my $fh, ">", $install_to
or die "Could not open $install_to: $!";
printf $fh <<'EOS', ($moar, join('" --libpath="', @libpaths), $p6_mbc_path, $mbc) x 2;
my $fh = open $install_to, :w;
$fh.print(sprintf(q:to/EOS/, ($moar, @libpaths.join('" --libpath="'), $p6_mbc_path, $mbc) xx 2));
#!/bin/sh
%s --execname="$0" --libpath="%s" %s/%s -e '
say "=" x 96;
Expand All @@ -59,18 +51,15 @@
say "-" x 96;'
valgrind %s --execname="$0" --libpath="%s" %s/%s "$@"
EOS
close $fh
or die "Could not close $install_to: $!";
chmod 0755, $install_to;
$fh.close;
chmod(0o755, $install_to);
}
else {
open my $fh, ">", $install_to
or die "Could not open $install_to: $!";
printf $fh <<'EOS', $moar, join('" --libpath="', @libpaths), $p6_mbc_path, $mbc;
my $fh = open $install_to, :w;
$fh.print(sprintf(q:to/EOS/, $moar, join('" --libpath="', @libpaths), $p6_mbc_path, $mbc));
#!/bin/sh
exec %s --execname="$0" --libpath="%s" %s/%s "$@"
EOS
close $fh
or die "Could not close $install_to: $!";
chmod 0755, $install_to;
$fh.close;
chmod(0o755, $install_to);
}

0 comments on commit 531a044

Please sign in to comment.