Skip to content
Permalink
Browse files

Make it build with prefix different from nqp location

If nqp is not specified and no --prefix provided then pick the default
from `nqp` binary in PATH.

Configure.pl will set git's configuration variable submodules.recurse to
true.

#2919
  • Loading branch information...
vrurg committed May 26, 2019
1 parent 906008f commit 2b1e5ab40f650e70dc6cff95f18337da421f304b
@@ -11,12 +11,15 @@
use FindBin;

BEGIN {
my $force_update = !!grep { $_ eq '--submodule-update' } @ARGV;
if ( $force_update || !-e '3rdparty/nqp-configure/LICENSE' ) {
my $set_config = ! qx{git config rakudo.initialized};
unless ( -e '3rdparty/nqp-configure/LICENSE' ) {
print "Updating nqp-configure submodule...\n";
my $msg =
qx{git submodule sync --quiet 3rdparty/nqp-configure && git submodule --quiet update --init 3rdparty/nqp-configure 2>&1};
if ( $? >> 8 == 0 ) { print "OK\n" }
if ( $? >> 8 == 0 ) {
say "OK";
$set_config = 1;
}
else {
if ( $msg =~ /[']([^']+)[']\s+already exists and is not an empty/ )
{
@@ -27,6 +30,10 @@ BEGIN
}
}
}
if ($set_config) {
system("git config submodule.recurse true");
system("git config rakudo.initialized 1");
}
}

use lib ( "$FindBin::Bin/tools/lib",
@@ -53,21 +60,20 @@ BEGIN
$config->{$config_status} = join ' ', map { qq("$_") } @ARGV;

GetOptions(
$cfg->options, 'help!',
'prefix=s', 'libdir=s',
'sysroot=s', 'sdkroot=s',
'no-relocatable', 'backends=s',
'no-clean', 'with-nqp=s',
'with-moar=s', 'gen-nqp:s',
'gen-moar:s', 'moar-option=s@',
'git-protocol=s', 'ignore-errors',
'make-install!', 'makefile-timing!',
'git-depth=s', 'git-reference=s',
'github-user=s', 'rakudo-repo=s',
'nqp-repo=s', 'moar-repo=s',
'roast-repo=s', 'expand=s',
'out=s', 'set-var=s@',
'submodule-update',
$cfg->options, 'help!',
'prefix=s', 'libdir=s',
'sysroot=s', 'sdkroot=s',
'no-relocatable', 'backends=s',
'no-clean', 'with-nqp=s',
'gen-nqp:s', 'gen-moar:s',
'moar-option=s@', 'git-protocol=s',
'ignore-errors', 'make-install!',
'makefile-timing!', 'git-depth=s',
'git-reference=s', 'github-user=s',
'rakudo-repo=s', 'nqp-repo=s',
'moar-repo=s', 'roast-repo=s',
'expand=s', 'out=s',
'set-var=s@',
)
or do {
print_help();
@@ -86,23 +92,19 @@ BEGIN

$cfg->configure_paths;
$cfg->configure_from_options;
$cfg->configure_refine_vars;
$cfg->configure_relocatability;
$cfg->configure_repo_urls;
$cfg->configure_commands;
$cfg->configure_misc;
$cfg->configure_nqp;
$cfg->configure_refine_vars;
$cfg->configure_backends;
$cfg->configure_misc;

# Save options in config.status
$cfg->save_config_status;

$cfg->options->{'gen-nqp'} ||= '' if $cfg->has_option('gen-moar');
$cfg->gen_nqp;

if ( defined $cfg->opt('submodule-update') ) {
exit(0);
}

$cfg->configure_active_backends;

$cfg->expand_template;
@@ -1,79 +1,141 @@
## Please see file perltidy.ERR
## Please see file perltidy.ERR
use v5.10.1;
use strict;
use warnings;

package NQP::Config::Rakudo;
use strict;
use warnings;
use Cwd;
use POSIX qw<strftime>;
use Digest::SHA;
use NQP::Config qw<slurp read_config cmp_rev system_or_die run_or_die>;
use IPC::Cmd qw<run>;
use IPC::Cmd qw<run can_run>;
use NQP::Macros;

use base qw<NQP::Config>;

sub configure_backends {
my $self = shift;
my $config = $self->{config};
sub configure_nqp {
my $self = shift;
my $nqp_bin;

my $prefix = $config->{prefix};
my $have_dir_opts =
defined( $self->opt('prefix') || $self->opt('sysroot') );

if ( $nqp_bin = $self->opt('with-nqp') ) {
$nqp_bin = can_run( $self->nfp($nqp_bin) );
$self->sorry( "Could not find nqp '" . $self->opt('with-nqp') . "' defined with --with-nqp" )
unless $nqp_bin;
}
elsif ( !$have_dir_opts ) {
$nqp_bin = can_run('nqp');
}

### Consider what backends are to be built. ###
my $passed_backends = $self->opt('backends');
if ( my $nqp_bin = $self->opt('with-nqp') ) {
die "Could not find $nqp_bin" unless -e $nqp_bin;
if ($nqp_bin) {
my $nqp_backend;
run(
command =>
[ $nqp_bin, '-e', 'print(nqp::getcomp("nqp").backend.name)' ],
buffer => \$nqp_backend
) or die "Could not get backend information from '$nqp_bin'";
) or self->sorry("Could not get backend information from '$nqp_bin'");
$self->use_backend($nqp_backend);
$self->backend_config( $nqp_backend, nqp_bin => $nqp_bin );
my $passed_backends = $self->opt('backends');
if ( defined $passed_backends && $nqp_backend ne $passed_backends ) {
die
"Passed value to --backends ($passed_backends) is overwritten by the one infered by --with-nqp ($nqp_backend)";
$self->sorry(
"Passed value to --backends ($passed_backends) is overwritten ",
"by the one infered by --with-nqp ($nqp_backend)"
);
}
$self->set( nqp_default => $nqp_bin );
}
if ($passed_backends) {
my @use_backends = $self->parse_backends($passed_backends);
for my $b (@use_backends) {
if ( $b eq 'parrot' ) {
die "The Parrot backend has been suspended.\n"
. "Please use Rakudo 2015.02 (which still supports parrot), or the MoarVM backend instead\n";
}

sub configure_backends {
my $self = shift;

my $prefix = $self->cfg('prefix');

#
unless ( $self->cfg('nqp_default') ) {
### Consider what backends are to be built. ###
my $passed_backends = $self->opt('backends');
if ($passed_backends) {
my @use_backends = $self->parse_backends($passed_backends);
for my $b (@use_backends) {
if ( $b eq 'parrot' ) {
$self->sorry(
"The Parrot backend has been suspended.\n",
"Please use Rakudo 2015.02 ",
"(which still supports parrot), ",
"or the MoarVM backend instead"
);
}
unless ( $self->known_backend($b) ) {
$self->sorry(
"Unknown backend '$b'; Supported backends are: "
. join( ", ", sort $self->known_backends )
. "\n" );
}
$self->use_backend($b);
}
unless ( $self->known_backend($b) ) {
die "Unknown backend '$b'; Supported backends are: "
. join( ", ", sort $self->known_backends ) . "\n";
unless ( $self->active_backends ) {
$self->sorry("--prefix given, but no valid backend?!");
}
$self->use_backend($b);
}
unless ( $self->active_backends ) {
die "--prefix given, but no valid backend?!\n";
}
}
else {
for my $a ( $self->known_abbrs ) {
if ( my $nqp_bin = $self->is_executable("$prefix/bin/nqp-$a") ) {
my $b = $self->abbr_to_backend($a);
$self->msg("Found $nqp_bin (backend $b)\n");
$self->use_backend($b);
else {
if ($prefix) {
for my $a ( $self->known_abbrs ) {
my $nqp_cmd = "nqp-$a";
my $nqp_bin = $self->is_executable("$prefix/bin/$nqp_cmd");
if ($nqp_bin) {
my $b = $self->abbr_to_backend($a);
$self->msg("Found $nqp_bin (backend $b)\n");
$self->use_backend($b);
$self->backend_config( $b, nqp_bin => $nqp_bin );
}
}
}
}

$self->use_backend('moar') if $self->has_option('gen-moar');

unless ( $self->active_backends or $self->has_option('with-nqp') ) {
die
"No suitable nqp executables found! Please specify some --backends, or a --prefix that contains nqp-{js,j,m} executables\n\n"
. "Example to build for all backends (which will take a while):\n"
. "\tperl Configure.pl --backends=ALL --gen-moar\n\n"
. "Example to build for MoarVM only:\n"
. "\tperl Configure.pl --gen-moar\n\n"
. "Example to build for JVM only:\n"
. "\tperl Configure.pl --backends=jvm --gen-nqp\n\n";
$self->use_backend('moar') if $self->has_option('gen-moar');

unless ( $self->active_backends or $self->has_option('with-nqp') ) {
$self->sorry(
"No suitable nqp executables found! ",
"Please specify some --backends, ",
"or a --prefix that contains nqp-{js,j,m} executables\n\n",
"Example to build for all backends ",
"(which will take a while):\n",
"\tperl Configure.pl --backends=ALL --gen-moar\n\n",
"Example to build for MoarVM only:\n",
"\tperl Configure.pl --gen-moar\n\n",
"Example to build for JVM only:\n",
"\tperl Configure.pl --backends=jvm --gen-nqp\n\n"
);
}
}
}
}

sub configure_refine_vars {
my $self = shift;

if ( !$self->cfg('prefix') && ( my $nqp_bin = $self->cfg('nqp_default') ) )
{
my ( $vol, $dir, undef ) = File::Spec->splitpath($nqp_bin);
my $nqp_prefix = File::Spec->catpath( $vol,
File::Spec->catdir( $dir, File::Spec->updir ) );
$self->set( prefix => $nqp_prefix );
$self->note(
"ATTENTION",
"No --prefix supplied, ",
"building and installing to $nqp_prefix\n",
"Based on found executable $nqp_bin"
);
}

$self->SUPER::configure_refine_vars(@_);
}

sub configure_misc {
my $self = shift;
my $config = $self->{config};
@@ -312,6 +374,16 @@ sub configure_js_backend {
);
}

sub opts_for_configure {
my $self = shift;
my @opts = $self->SUPER::opts_for_configure(@_);

my $nqp_bin = $self->cfg('nqp_bin');
push @opts, "--with-nqp=" . $self->cfg('nqp_bin') if $nqp_bin;

return wantarray ? @opts : join( " ", @opts );
}

# Returns all active language specification entries except for .c
sub perl6_specs {
my $self = shift;
@@ -367,7 +439,7 @@ sub gen_nqp {
my $options = $self->{options};
my $config = $self->{config};

my $nqp_bin = $options->{'with-nqp'};
#my $nqp_bin = $options->{'with-nqp'};
my $nqp_git_spec = $options->{'gen-nqp'};
my $gen_nqp = defined $options->{'gen-nqp'};
my $gen_moar = $options->{'gen-moar'};
@@ -384,9 +456,10 @@ sub gen_nqp {
my %need;

for my $b ( $self->active_backends ) {
my $bconfig = $self->backend_config($b);
my $postfix = $self->backend_abbr($b);
my $tpath = File::Spec->catfile( $prefix, 'bin', "nqp-$postfix$bat" );
my $bin = $self->nfp($nqp_bin)
my $bin = $bconfig->{nqp_bin}
|| (
$sdkroot
? File::Spec->catfile( $self->nfp($sdkroot),
@@ -1 +1 @@
@shquot(--execname="\@envvar(EXEC)@" --libpath="\@envvar(DIR)@" --libpath="\@nfp(\@envvar(DIR)@/blib)@" --libpath="\@nfp(\@libdir@/nqp/lib)@" "\@nfp(\@envvar(DIR)@/perl6.moarvm)@" --nqp-lib="\@nfp(\@envvar(DIR)@/blib)@")@
@shquot(--execname="\@envvar(EXEC)@" --libpath="\@envvar(DIR)@" --libpath="\@nfp(\@envvar(DIR)@/blib)@" --libpath="\@nfp(\@nqp_libdir@)@" --libpath="\@nfp(\@libdir@/nqp/lib)@" "\@nfp(\@envvar(DIR)@/perl6.moarvm)@" --nqp-lib="\@nfp(\@envvar(DIR)@/blib)@")@
@@ -16,6 +16,7 @@ MOAR = @nfpq(@moar::bindir@/moar@moar::exe@)@
M_NQP = @nfpq(@m_nqp@)@
M_LIBDEFPATH = $(PREFIX)@nfp(/share/nqp/lib)@
M_LIBPATH = $(LIBDIR)@nfp(/nqp/lib)@
M_NQP_LIBDIR = @nqp::libdir@
M_INCPATH = $(MOAR_PREFIX)@nfp(/include)@
M_MOAR_INC_PATHS = \
$(M_CCINC)@nfpq($(M_INCPATH))@ \
@@ -28,7 +29,7 @@ M_MOAR_INC_PATHS = \
$(M_CCINC)@nfpq($(M_INCPATH)/libtommath)@ \
$(M_CCINC)@nfpq($(M_INCPATH)/libuv)@

M_RUN_PERL6 = $(MOAR) --libpath=blib --libpath=@q($(M_LIBPATH))@ perl6.moarvm --nqp-lib=blib
M_RUN_PERL6 = $(MOAR) --libpath=@nfpq($(BASE_DIR)/blib)@ --libpath=@q($(M_NQP_LIBDIR))@ --libpath=@q($(M_LIBPATH))@ perl6.moarvm --nqp-lib=@nfpq($(BASE_DIR)/blib)@

M_BAT = @runner_suffix@
M_BAT_RUNNER = perl6-m@runner_suffix@
@@ -225,6 +226,7 @@ $(M_BAT_RUNNER): @@configure_script@@ $(M_C_RUNNER) $(PERL6_MOAR) $(SETTING_MOAR
--set-var=MOAR=$(MOAR) \
--set-var=mbc=perl6.moarvm \
--set-var=ctx_subdir=@backend_subdir@ \
--set-var=nqp_libdir=@shquot(@nqp::libdir@)@ \
--set-var=runner_opts=@chomp(@insert(Makefile-runner_opts)@)@
-$(CHMOD) 755 $(M_BAT_RUNNER)

@@ -234,6 +236,7 @@ $(M_BAT_DEBUG_RUNNER): @@configure_script@@ $(M_C_DEBUG_RUNNER) $(PERL6_DEBUG_MO
--set-var=MOAR=$(MOAR) \
--set-var=mbc=perl6-debug.moarvm \
--set-var=ctx_subdir=@backend_subdir@ \
--set-var=nqp_libdir=@shquot(@nqp::libdir@)@ \
--set-var=runner_opts=@chomp(@insert(Makefile-runner_opts)@)@
-$(CHMOD) 755 $(M_BAT_DEBUG_RUNNER)

0 comments on commit 2b1e5ab

Please sign in to comment.
You can’t perform that action at this time.