Skip to content

Commit fcf5bf5

Browse files
committed
Added --force-rebuild command line option
Forces rebuild of MoarVM if `--gen-moar` was used too. Mostly good if bypassed from upstream (Rakudo) which might need total rebuild under certain circumstances.
1 parent 0d7250f commit fcf5bf5

File tree

3 files changed

+68
-47
lines changed

3 files changed

+68
-47
lines changed

3rdparty/nqp-configure

Configure.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ BEGIN
6969
'github-user=s', 'nqp-repo=s',
7070
'moar-repo=s', 'expand=s',
7171
'out=s', 'set-var=s@',
72-
'relocatable!', 'silent-build!'
72+
'relocatable!', 'silent-build!',
73+
'force-rebuild!'
7374
)
7475
or do {
7576
print_help();
@@ -149,6 +150,7 @@ sub print_help {
149150
--nqp-home=dir Directory to install NQP files to
150151
--backends=list Backends to use: $backends
151152
--gen-moar Download, build, and install a copy of MoarVM to use before writing the Makefile
153+
--force-rebuild Forces rebuild of moar if used with --gen-moar
152154
--moar-option='--option=value'
153155
Options to pass to MoarVM configuration for --gen-moar
154156
--with-moar='/path/to/moar'

tools/lib/NQP/Config/NQP.pm

Lines changed: 64 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
## Please see file perltidy.ERR
21
package NQP::Config::NQP;
32
use v5.10.1;
43
use strict;
54
use warnings;
65
use Cwd;
76
use IPC::Cmd qw<run>;
8-
use NQP::Config qw<slurp read_config_from_command cmp_rev system_or_die run_or_die>;
7+
use NQP::Config qw<slurp read_config_from_command cmp_rev system_or_die
8+
run_or_die>;
99

1010
use base qw<NQP::Config>;
1111

@@ -48,7 +48,7 @@ sub configure_backends {
4848
}
4949

5050
sub configure_refine_vars {
51-
my $self = shift;
51+
my $self = shift;
5252
my $config = $self->{config};
5353

5454
unless ( $self->cfg('prefix') ) {
@@ -70,8 +70,8 @@ sub configure_refine_vars {
7070

7171
$config->{nqp_home} = $self->nfp(
7272
File::Spec->rel2abs(
73-
$config->{nqp_home} ||
74-
File::Spec->catdir( $config->{'prefix'}, 'share', 'nqp' )
73+
$config->{nqp_home}
74+
|| File::Spec->catdir( $config->{'prefix'}, 'share', 'nqp' )
7575
)
7676
);
7777
}
@@ -95,8 +95,8 @@ sub configure_misc {
9595
}
9696

9797
sub configure_moar_backend {
98-
my $self = shift;
99-
my $imoar = $self->{impls}{moar};
98+
my $self = shift;
99+
my $imoar = $self->{impls}{moar};
100100
my $config = $self->{config};
101101

102102
$self->gen_moar;
@@ -116,14 +116,17 @@ sub configure_moar_backend {
116116
my $qchar = $config->{quote};
117117
$imoar->{config}{static_nqp_home} = $config->{nqp_home};
118118
$imoar->{config}{static_nqp_home_define} =
119-
'-DSTATIC_NQP_HOME='
120-
. $qchar . $self->c_escape_string( $imoar->{config}{static_nqp_home} ) . $qchar;
119+
'-DSTATIC_NQP_HOME='
120+
. $qchar
121+
. $self->c_escape_string( $imoar->{config}{static_nqp_home} )
122+
. $qchar;
121123
}
122124

123125
# Strip rpath from ldflags so we can set it differently ourself.
124126
$imoar->{config}{ldflags} = $moar_config->{'moar::ldflags'};
125127
$imoar->{config}{ldflags} =~ s/\Q$moar_config->{'moar::ldrpath'}\E ?//;
126-
$imoar->{config}{ldflags} =~ s/\Q$moar_config->{'moar::ldrpath_relocatable'}\E ?//;
128+
$imoar->{config}{ldflags} =~
129+
s/\Q$moar_config->{'moar::ldrpath_relocatable'}\E ?//;
127130
if ( $self->cfg('prefix') ne '/usr' ) {
128131
$imoar->{config}{ldflags} .= ' '
129132
. (
@@ -146,7 +149,8 @@ sub configure_moar_backend {
146149
if ( $moar_config->{'moar::os'} eq 'mingw32' ) {
147150
$imoar->{config}{mingw_unicode} = '-municode';
148151
}
149-
push @c_runner_libs, sprintf( $moar_config->{'moar::ldusr'}, 'Shlwapi' );
152+
push @c_runner_libs,
153+
sprintf( $moar_config->{'moar::ldusr'}, 'Shlwapi' );
150154
}
151155
$imoar->{config}{c_runner_libs} = join( " ", @c_runner_libs );
152156
$imoar->{config}{moar_lib} = sprintf(
@@ -249,12 +253,12 @@ sub moar_config {
249253

250254
return $moar_config if $moar_config && keys %{$moar_config} > 2;
251255

252-
my $prefix = $self->cfg('prefix');
256+
my $prefix = $self->cfg('prefix');
253257
my $moar_prefix;
254258
my $moar_exe;
255259

256260
if ( $self->opt('with-moar') ) {
257-
$moar_exe = File::Spec->rel2abs($self->opt('with-moar'));
261+
$moar_exe = File::Spec->rel2abs( $self->opt('with-moar') );
258262
}
259263
else {
260264
if ($prefix) {
@@ -277,13 +281,16 @@ sub moar_config {
277281
}
278282

279283
my %c;
280-
if ( $self->is_executable($self->nfp($moar_exe)) ) {
281-
%c = read_config_from_command(
282-
'"' . $self->nfp( $moar_exe ) . '"'
283-
. ' --libpath=' . $self->nfp( 'src/vm/moar/stage0' ) . ' '
284-
. $self->nfp( 'src/vm/moar/stage0/nqp.moarvm' )
285-
. ' --bootstrap --show-config' );
286-
%c = map { rindex($_, 'moar::', 0) == 0 ? ($_ => $c{$_}) : () } keys %c;
284+
if ( $self->is_executable( $self->nfp($moar_exe) ) ) {
285+
%c =
286+
read_config_from_command( '"'
287+
. $self->nfp($moar_exe) . '"'
288+
. ' --libpath='
289+
. $self->nfp('src/vm/moar/stage0') . ' '
290+
. $self->nfp('src/vm/moar/stage0/nqp.moarvm')
291+
. ' --bootstrap --show-config' );
292+
%c = map { rindex( $_, 'moar::', 0 ) == 0 ? ( $_ => $c{$_} ) : () }
293+
keys %c;
287294
}
288295

289296
return $self->backend_config( 'moar',
@@ -302,10 +309,11 @@ sub gen_moar {
302309
my $moar_have;
303310
my @errors;
304311

305-
my $prefix = $config->{prefix};
306-
my $gen_moar = $options->{'gen-moar'};
307-
my $has_gen_moar = defined $gen_moar;
308-
my @opts = @{ $options->{'moar-option'} || [] };
312+
my $prefix = $config->{prefix};
313+
my $gen_moar = $options->{'gen-moar'};
314+
my $force_rebuild = $options->{'force-rebuild'};
315+
my $has_gen_moar = defined $gen_moar;
316+
my @opts = @{ $options->{'moar-option'} || [] };
309317
push @opts, "--optimize";
310318
push @opts, '--relocatable' if $options->{relocatable};
311319
my $startdir = $config->{base_dir};
@@ -314,6 +322,12 @@ sub gen_moar {
314322
my $moar_exe = $self->moar_config->{moar};
315323
my $moar_version_output = "";
316324

325+
if ( $force_rebuild && !$has_gen_moar ) {
326+
$self->note( "WARNING",
327+
"Command line option --force-rebuild is ineffective without --gen-moar"
328+
);
329+
}
330+
317331
if ( $self->is_executable($moar_exe) ) {
318332
$moar_version_output = run_or_die( [ $moar_exe, '--version' ] );
319333

@@ -325,37 +339,42 @@ sub gen_moar {
325339
$try_generate = $has_gen_moar;
326340
}
327341

328-
my $moar_ok =
329-
$moar_have && cmp_rev( $moar_have, $moar_want, "MoarVM" ) >= 0;
330-
if ($moar_ok) {
331-
$self->msg(
332-
"Found $moar_exe version $moar_have, which is new enough.\n");
333-
}
334-
elsif ($moar_have) {
335-
push @errors,
336-
"Found $moar_exe version $moar_have, which is too old. Wanted at least $moar_want\n";
337-
$try_generate = $has_gen_moar unless $options->{'ignore-errors'};
338-
}
339-
elsif ($moar_version_output
340-
&& $moar_version_output =~ /This is MoarVM version/i )
341-
{
342-
push @errors,
343-
"Found a MoarVM binary but was not able to get its version number.\n"
344-
. "If running `git describe` inside the MoarVM repository does not work,\n"
345-
. "you need to make sure to checkout tags of the repository and run \nConfigure.pl and make install again\n";
346-
$try_generate = $has_gen_moar;
342+
unless ($force_rebuild) {
343+
my $moar_ok =
344+
$moar_have && cmp_rev( $moar_have, $moar_want, "MoarVM" ) >= 0;
345+
if ($moar_ok) {
346+
$self->msg(
347+
"Found $moar_exe version $moar_have, which is new enough.\n");
348+
}
349+
elsif ($moar_have) {
350+
push @errors,
351+
"Found $moar_exe version $moar_have, which is too old. "
352+
. "Wanted at least $moar_want\n";
353+
$try_generate = $has_gen_moar unless $options->{'ignore-errors'};
354+
}
355+
elsif ($moar_version_output
356+
&& $moar_version_output =~ /This is MoarVM version/i )
357+
{
358+
push @errors,
359+
"Found a MoarVM binary "
360+
. " but was not able to get its version number.\n"
361+
. "If running `git describe` inside the MoarVM repository does not work,\n"
362+
. "you need to make sure to checkout tags of the repository and run \n"
363+
. "Configure.pl and make install again\n";
364+
$try_generate = $has_gen_moar;
365+
}
347366
}
348367

349368
if (@errors) {
350369
if ($try_generate) {
351-
$self->note("ATTENTION!", $_) foreach @errors;
370+
$self->note( "ATTENTION!", $_ ) foreach @errors;
352371
}
353372
else {
354373
$self->sorry(@errors);
355374
}
356375
}
357376

358-
if ( $try_generate ) {
377+
if ( $try_generate || ( $has_gen_moar && $force_rebuild ) ) {
359378

360379
my $moar_repo =
361380
$self->git_checkout( 'moar', 'MoarVM', $gen_moar || $moar_want );

0 commit comments

Comments
 (0)