1
- # # Please see file perltidy.ERR
2
1
package NQP::Config::NQP ;
3
2
use v5.10.1;
4
3
use strict;
5
4
use warnings;
6
5
use Cwd;
7
6
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> ;
9
9
10
10
use base qw< NQP::Config> ;
11
11
@@ -48,7 +48,7 @@ sub configure_backends {
48
48
}
49
49
50
50
sub configure_refine_vars {
51
- my $self = shift ;
51
+ my $self = shift ;
52
52
my $config = $self -> {config };
53
53
54
54
unless ( $self -> cfg(' prefix' ) ) {
@@ -70,8 +70,8 @@ sub configure_refine_vars {
70
70
71
71
$config -> {nqp_home } = $self -> nfp(
72
72
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' )
75
75
)
76
76
);
77
77
}
@@ -95,8 +95,8 @@ sub configure_misc {
95
95
}
96
96
97
97
sub configure_moar_backend {
98
- my $self = shift ;
99
- my $imoar = $self -> {impls }{moar };
98
+ my $self = shift ;
99
+ my $imoar = $self -> {impls }{moar };
100
100
my $config = $self -> {config };
101
101
102
102
$self -> gen_moar;
@@ -116,14 +116,17 @@ sub configure_moar_backend {
116
116
my $qchar = $config -> {quote };
117
117
$imoar -> {config }{static_nqp_home } = $config -> {nqp_home };
118
118
$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 ;
121
123
}
122
124
123
125
# Strip rpath from ldflags so we can set it differently ourself.
124
126
$imoar -> {config }{ldflags } = $moar_config -> {' moar::ldflags' };
125
127
$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 ?// ;
127
130
if ( $self -> cfg(' prefix' ) ne ' /usr' ) {
128
131
$imoar -> {config }{ldflags } .= ' '
129
132
. (
@@ -146,7 +149,8 @@ sub configure_moar_backend {
146
149
if ( $moar_config -> {' moar::os' } eq ' mingw32' ) {
147
150
$imoar -> {config }{mingw_unicode } = ' -municode' ;
148
151
}
149
- push @c_runner_libs , sprintf ( $moar_config -> {' moar::ldusr' }, ' Shlwapi' );
152
+ push @c_runner_libs ,
153
+ sprintf ( $moar_config -> {' moar::ldusr' }, ' Shlwapi' );
150
154
}
151
155
$imoar -> {config }{c_runner_libs } = join ( " " , @c_runner_libs );
152
156
$imoar -> {config }{moar_lib } = sprintf (
@@ -249,12 +253,12 @@ sub moar_config {
249
253
250
254
return $moar_config if $moar_config && keys %{$moar_config } > 2;
251
255
252
- my $prefix = $self -> cfg(' prefix' );
256
+ my $prefix = $self -> cfg(' prefix' );
253
257
my $moar_prefix ;
254
258
my $moar_exe ;
255
259
256
260
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' ) );
258
262
}
259
263
else {
260
264
if ($prefix ) {
@@ -277,13 +281,16 @@ sub moar_config {
277
281
}
278
282
279
283
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 ;
287
294
}
288
295
289
296
return $self -> backend_config( ' moar' ,
@@ -302,10 +309,11 @@ sub gen_moar {
302
309
my $moar_have ;
303
310
my @errors ;
304
311
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' } || [] };
309
317
push @opts , " --optimize" ;
310
318
push @opts , ' --relocatable' if $options -> {relocatable };
311
319
my $startdir = $config -> {base_dir };
@@ -314,6 +322,12 @@ sub gen_moar {
314
322
my $moar_exe = $self -> moar_config-> {moar };
315
323
my $moar_version_output = " " ;
316
324
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
+
317
331
if ( $self -> is_executable($moar_exe ) ) {
318
332
$moar_version_output = run_or_die( [ $moar_exe , ' --version' ] );
319
333
@@ -325,37 +339,42 @@ sub gen_moar {
325
339
$try_generate = $has_gen_moar ;
326
340
}
327
341
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 \n Configure.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
+ }
347
366
}
348
367
349
368
if (@errors ) {
350
369
if ($try_generate ) {
351
- $self -> note(" ATTENTION!" , $_ ) foreach @errors ;
370
+ $self -> note( " ATTENTION!" , $_ ) foreach @errors ;
352
371
}
353
372
else {
354
373
$self -> sorry(@errors );
355
374
}
356
375
}
357
376
358
- if ( $try_generate ) {
377
+ if ( $try_generate || ( $has_gen_moar && $force_rebuild ) ) {
359
378
360
379
my $moar_repo =
361
380
$self -> git_checkout( ' moar' , ' MoarVM' , $gen_moar || $moar_want );
0 commit comments