Skip to content

Commit

Permalink
Merge pull request #2970 from vrurg/build-revamp
Browse files Browse the repository at this point in the history
Prevent rebuild of nqp without --gen-nqp.
  • Loading branch information
vrurg committed Jun 10, 2019
2 parents bed0695 + f935bd2 commit 1ccfc01
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 21 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/nqp-configure
11 changes: 7 additions & 4 deletions Configure.pl
Expand Up @@ -11,7 +11,7 @@
use FindBin;

BEGIN {
my $set_config = ! qx{git config rakudo.initialized};
my $set_config = !qx{git config rakudo.initialized};
unless ( -e '3rdparty/nqp-configure/LICENSE' ) {
print "Updating nqp-configure submodule...\n";
my $msg =
Expand Down Expand Up @@ -63,7 +63,7 @@ BEGIN
$cfg->options, 'help!',
'prefix=s', 'libdir=s',
'sysroot=s', 'sdkroot=s',
'relocatable', 'backends=s',
'relocatable', 'backends=s',
'no-clean', 'with-nqp=s',
'gen-nqp:s', 'gen-moar:s',
'moar-option=s@', 'git-protocol=s',
Expand All @@ -86,8 +86,11 @@ BEGIN
exit(0);
}
if ( $cfg->opt('ignore-errors') ) {
print
"===WARNING!===\nErrors are being ignored.\nIn the case of any errors the script may behave unexpectedly.\n";
$cfg->note(
"WARNING!",
"Errors are being ignored.\n",
"In the case of any errors the script may behave unexpectedly."
);
}

$cfg->configure_paths;
Expand Down
55 changes: 39 additions & 16 deletions tools/lib/NQP/Config/Rakudo.pm
Expand Up @@ -22,7 +22,7 @@ sub configure_nqp {
defined( $self->opt('prefix') || $self->opt('sysroot') );

if ( $nqp_bin = $self->opt('with-nqp') ) {
$nqp_bin = File::Spec->rel2abs( $self->nfp( $nqp_bin ) );
$nqp_bin = File::Spec->rel2abs( $self->nfp($nqp_bin) );

$self->sorry( "Could not find nqp '"
. $self->opt('with-nqp')
Expand All @@ -33,7 +33,8 @@ sub configure_nqp {
command =>
[ $nqp_bin, '-e', 'print(nqp::getcomp(\'nqp\').backend.name)' ],
buffer => \$nqp_backend
) or $self->sorry("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');
Expand Down Expand Up @@ -138,7 +139,9 @@ sub configure_refine_vars {
"Based on found executable $nqp_bin"
);
}
elsif ( $self->cfg('relocatable') eq 'reloc' && abs_path($prefix) ne abs_path($nqp_prefix) ) {
elsif ( $self->cfg('relocatable') eq 'reloc'
&& abs_path($prefix) ne abs_path($nqp_prefix) )
{
$self->sorry(
"Installation directory '$prefix' is different from '",
abs_path($nqp_prefix),
Expand Down Expand Up @@ -339,13 +342,18 @@ sub configure_moar_backend {
}
else {
$config->{static_nqp_home} =
File::Spec->rel2abs(File::Spec->catdir( $nqp_config->{'nqp::prefix'}, 'share', 'nqp' ));
File::Spec->rel2abs(
File::Spec->catdir( $nqp_config->{'nqp::prefix'}, 'share', 'nqp' )
);
$config->{static_perl6_home} =
File::Spec->rel2abs(File::Spec->catdir( $config->{prefix}, 'share', 'perl6' ));
File::Spec->rel2abs(
File::Spec->catdir( $config->{prefix}, 'share', 'perl6' ) );
$config->{static_nqp_home_define} =
'-DSTATIC_NQP_HOME=' . $self->c_escape_string( $config->{static_nqp_home} );
'-DSTATIC_NQP_HOME='
. $self->c_escape_string( $config->{static_nqp_home} );
$config->{static_perl6_home_define} =
'-DSTATIC_PERL6_HOME=' . $self->c_escape_string( $config->{static_perl6_home} );
'-DSTATIC_PERL6_HOME='
. $self->c_escape_string( $config->{static_perl6_home} );
}

# Strip rpath from ldflags so we can set it differently ourself.
Expand Down Expand Up @@ -465,6 +473,19 @@ sub configure_js_backend {
);
}

sub configure_active_backends {
my $self = shift;

my $impls = $self->{impls};
for my $k ( $self->active_backends ) {
my %c = read_config( $impls->{$k}{bin} );
$self->backend_config( $k, \%c );
$impls->{$k}{ok} = 1;
}

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

sub opts_for_configure {
my $self = shift;
my @opts = $self->SUPER::opts_for_configure(@_);
Expand Down Expand Up @@ -532,7 +553,7 @@ sub gen_nqp {

#my $nqp_bin = $options->{'with-nqp'};
my $nqp_git_spec = $options->{'gen-nqp'};
my $gen_nqp = defined $options->{'gen-nqp'};
my $gen_nqp = $options->{'gen-nqp'};
my $gen_moar = $options->{'gen-moar'};
my $prefix = $config->{prefix};
my $sdkroot = $config->{'sdkroot'};
Expand Down Expand Up @@ -561,20 +582,27 @@ sub gen_nqp {
my %c = read_config($bin);
my $nqp_have = $c{'nqp::version'} || '';
$self->backend_config( $b, \%c ) if %c;
my $nqp_ok = $nqp_have && 0 <= cmp_rev( $nqp_have, $nqp_want );
my $nqp_ver_ok = $nqp_have ? (0 <= cmp_rev( $nqp_have, $nqp_want )) : 0;
my $nqp_ok = $nqp_have && $nqp_ver_ok;

unless ( !$nqp_have || $nqp_ver_ok || $options->{'ignore-errors'} ) {
$self->note( "WARNING",
"$bin version $nqp_have is outdated, $nqp_want expected.\n" );
}

if ( $nqp_ok or $options->{'ignore-errors'} ) {
$impls->{$b}{ok} = 1;
}
elsif ( $self->opt('with-nqp') ) {
$self->sorry(
"$bin version $nqp_have is outdated, $nqp_want expected.");
$self->sorry("$bin version cannot be used");
}
else {
$need{$b} = 1;
}
}

say "need?";

return unless %need;

return unless defined($gen_nqp) || defined($gen_moar);
Expand Down Expand Up @@ -615,11 +643,6 @@ sub gen_nqp {
system_or_die(@cmd);
chdir($pwd);

for my $k ( keys %need ) {
my %c = read_config( $impls->{$k}{bin} );
$self->backend_config( $k, \%c );
$impls->{$k}{ok} = 1;
}
return;
}

Expand Down

0 comments on commit 1ccfc01

Please sign in to comment.