Skip to content

Commit

Permalink
Use moar from PATH only when no other prefix-defining options are used.
Browse files Browse the repository at this point in the history
  • Loading branch information
vrurg committed May 25, 2019
1 parent 2a742cd commit a3721a3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/nqp-configure
5 changes: 2 additions & 3 deletions Configure.pl
Expand Up @@ -47,7 +47,7 @@ BEGIN
GetOptions(
$cfg->options, 'help!',
'prefix=s', 'libdir=s',
'sysroot=s', 'sdkroot=s',
'sdkroot=s', 'sysroot=s',
'backends=s', 'no-clean',
'with-moar=s', 'gen-moar:s',
'moar-option=s@', 'with-asm=s',
Expand Down Expand Up @@ -78,13 +78,12 @@ BEGIN

$cfg->configure_paths;
$cfg->configure_from_options;
$cfg->configure_refine_vars;
$cfg->configure_relocatability;
$cfg->configure_repo_urls;
$cfg->configure_commands;
$cfg->configure_jars;

$cfg->configure_backends;
$cfg->configure_refine_vars;
$cfg->configure_misc;

# XXX Why Windows only?
Expand Down
64 changes: 46 additions & 18 deletions tools/lib/NQP/Config/NQP.pm
@@ -1,3 +1,4 @@
## Please see file perltidy.ERR
package NQP::Config::NQP;
use v5.10.1;
use strict;
Expand Down Expand Up @@ -25,12 +26,13 @@ sub configure_backends {
}
else {
my $have_gen_moar = defined $options->{'gen-moar'};
my $moar_exe = $self->moar_config->{moar};
my $moar_exe = can_run( $self->moar_config->{moar} );
if ( $moar_exe || $have_gen_moar ) {
say "===WARNING!===\n",
" No backends specified on the command line.\n",
" Using 'moar' because we found '$moar_exe' executable."
unless $have_gen_moar;
$self->note(
"WARNING!",
"No backends specified on the command line.\n",
"Using 'moar' because we found '$moar_exe' executable."
) unless $have_gen_moar;
$self->use_backend('moar');
}
else {
Expand All @@ -45,6 +47,24 @@ sub configure_backends {
}
}

sub configure_refine_vars {
my $self = shift;

unless ( $self->cfg('prefix') ) {
my $moar_prefix = $self->moar_config->{moar_prefix};
if ($moar_prefix) {
$self->set( prefix => $moar_prefix );
$self->note(
'ATTENTION',
"No --prefix supplied, using moar executable location.\n",
"Building and installing to '$moar_prefix'"
);
}
}

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

sub configure_misc {
my $self = shift;
my $config = $self->{config};
Expand Down Expand Up @@ -170,23 +190,31 @@ sub post_active_backends {
sub moar_config {
my $self = shift;
my $moar_config = $self->backend_config('moar');

return $moar_config if $moar_config->{moar};
my $sdkroot = $self->cfg('sdkroot');
my $prefix = $self->cfg('prefix');

my $moar_exe = $self->opt('with-moar');
unless ($moar_exe) {
my $moar_dir =
$sdkroot ? File::Spec->catdir( $sdkroot, $prefix ) : $prefix;
$moar_exe =
File::Spec->catfile( $moar_dir, 'bin', "moar" . $self->cfg('exe') );
if ( !can_run($moar_exe) && ( my $mbin = can_run('moar') ) )
{ # Pick from PATH
$moar_exe = $mbin;
my $prefix = $self->cfg('prefix');
my $moar_prefix;

if ( !$moar_exe ) {
if ($prefix) {
my $sdkroot = $self->cfg('sdkroot');
$moar_prefix =
$sdkroot ? File::Spec->catdir( $sdkroot, $prefix ) : $prefix;
$moar_exe ||= File::Spec->catfile( $moar_prefix, 'bin',
"moar" . $self->cfg('exe') );
}
elsif (!defined $self->opt('sysroot')) {
# Pick from PATH
$moar_exe = can_run('moar');
if ($moar_exe) {
my ( $vol, $dir, undef ) = File::Spec->splitpath($moar_exe);
$moar_prefix = File::Spec->catpath( $vol,
File::Spec->catdir( $dir, File::Spec->updir ) );
}
}
}
my $moar_prefix =
File::Spec->catpath( ( File::Spec->splitpath($moar_exe) )[ 0, 1 ],
File::Spec->updir );
return $self->backend_config( 'moar',
{ moar => $moar_exe, moar_prefix => $moar_prefix, } );
}
Expand Down

0 comments on commit a3721a3

Please sign in to comment.