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,14 +70,15 @@ 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
}
78
78
79
79
sub configure_misc {
80
80
my $self = shift ;
81
+ $self -> SUPER::configure_misc(@_ );
81
82
my $config = $self -> {config };
82
83
83
84
if ( $self -> active_backend(' moar' ) ) {
@@ -95,8 +96,8 @@ sub configure_misc {
95
96
}
96
97
97
98
sub configure_moar_backend {
98
- my $self = shift ;
99
- my $imoar = $self -> {impls }{moar };
99
+ my $self = shift ;
100
+ my $imoar = $self -> {impls }{moar };
100
101
my $config = $self -> {config };
101
102
102
103
$self -> gen_moar;
@@ -116,14 +117,17 @@ sub configure_moar_backend {
116
117
my $qchar = $config -> {quote };
117
118
$imoar -> {config }{static_nqp_home } = $config -> {nqp_home };
118
119
$imoar -> {config }{static_nqp_home_define } =
119
- ' -DSTATIC_NQP_HOME='
120
- . $qchar . $self -> c_escape_string( $imoar -> {config }{static_nqp_home } ) . $qchar ;
120
+ ' -DSTATIC_NQP_HOME='
121
+ . $qchar
122
+ . $self -> c_escape_string( $imoar -> {config }{static_nqp_home } )
123
+ . $qchar ;
121
124
}
122
125
123
126
# Strip rpath from ldflags so we can set it differently ourself.
124
127
$imoar -> {config }{ldflags } = $moar_config -> {' moar::ldflags' };
125
128
$imoar -> {config }{ldflags } =~ s /\Q $moar_config->{'moar::ldrpath'}\E ?// ;
126
- $imoar -> {config }{ldflags } =~ s /\Q $moar_config->{'moar::ldrpath_relocatable'}\E ?// ;
129
+ $imoar -> {config }{ldflags } =~
130
+ s /\Q $moar_config->{'moar::ldrpath_relocatable'}\E ?// ;
127
131
if ( $self -> cfg(' prefix' ) ne ' /usr' ) {
128
132
$imoar -> {config }{ldflags } .= ' '
129
133
. (
@@ -146,7 +150,8 @@ sub configure_moar_backend {
146
150
if ( $moar_config -> {' moar::os' } eq ' mingw32' ) {
147
151
$imoar -> {config }{mingw_unicode } = ' -municode' ;
148
152
}
149
- push @c_runner_libs , sprintf ( $moar_config -> {' moar::ldusr' }, ' Shlwapi' );
153
+ push @c_runner_libs ,
154
+ sprintf ( $moar_config -> {' moar::ldusr' }, ' Shlwapi' );
150
155
}
151
156
$imoar -> {config }{c_runner_libs } = join ( " " , @c_runner_libs );
152
157
$imoar -> {config }{moar_lib } = sprintf (
@@ -249,12 +254,12 @@ sub moar_config {
249
254
250
255
return $moar_config if $moar_config && keys %{$moar_config } > 2;
251
256
252
- my $prefix = $self -> cfg(' prefix' );
257
+ my $prefix = $self -> cfg(' prefix' );
253
258
my $moar_prefix ;
254
259
my $moar_exe ;
255
260
256
261
if ( $self -> opt(' with-moar' ) ) {
257
- $moar_exe = File::Spec-> rel2abs($self -> opt(' with-moar' ));
262
+ $moar_exe = File::Spec-> rel2abs( $self -> opt(' with-moar' ) );
258
263
}
259
264
else {
260
265
if ($prefix ) {
@@ -277,13 +282,16 @@ sub moar_config {
277
282
}
278
283
279
284
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 ;
285
+ if ( $self -> is_executable( $self -> nfp($moar_exe ) ) ) {
286
+ %c =
287
+ read_config_from_command( ' "'
288
+ . $self -> nfp($moar_exe ) . ' "'
289
+ . ' --libpath='
290
+ . $self -> nfp(' src/vm/moar/stage0' ) . ' '
291
+ . $self -> nfp(' src/vm/moar/stage0/nqp.moarvm' )
292
+ . ' --bootstrap --show-config' );
293
+ %c = map { rindex ( $_ , ' moar::' , 0 ) == 0 ? ( $_ => $c {$_ } ) : () }
294
+ keys %c ;
287
295
}
288
296
289
297
return $self -> backend_config( ' moar' ,
@@ -302,10 +310,11 @@ sub gen_moar {
302
310
my $moar_have ;
303
311
my @errors ;
304
312
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' } || [] };
313
+ my $prefix = $config -> {prefix };
314
+ my $gen_moar = $options -> {' gen-moar' };
315
+ my $force_rebuild = $options -> {' force-rebuild' };
316
+ my $has_gen_moar = defined $gen_moar ;
317
+ my @opts = @{ $options -> {' moar-option' } || [] };
309
318
push @opts , " --optimize" ;
310
319
push @opts , ' --relocatable' if $options -> {relocatable };
311
320
my $startdir = $config -> {base_dir };
@@ -314,6 +323,12 @@ sub gen_moar {
314
323
my $moar_exe = $self -> moar_config-> {moar };
315
324
my $moar_version_output = " " ;
316
325
326
+ if ( $force_rebuild && !$has_gen_moar ) {
327
+ $self -> note( " WARNING" ,
328
+ " Command line option --force-rebuild is ineffective without --gen-moar"
329
+ );
330
+ }
331
+
317
332
if ( $self -> is_executable($moar_exe ) ) {
318
333
$moar_version_output = run_or_die( [ $moar_exe , ' --version' ] );
319
334
@@ -325,37 +340,49 @@ sub gen_moar {
325
340
$try_generate = $has_gen_moar ;
326
341
}
327
342
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 ;
343
+ unless ($force_rebuild ) {
344
+ my $moar_ok =
345
+ $moar_have && cmp_rev( $moar_have , $moar_want , " MoarVM" ) >= 0;
346
+ if ($moar_ok ) {
347
+ $self -> msg(
348
+ " Found $moar_exe version $moar_have , which is new enough.\n " );
349
+ }
350
+ elsif ($moar_have ) {
351
+ push @errors ,
352
+ " Found $moar_exe version $moar_have , which is too old. "
353
+ . " Wanted at least $moar_want \n " ;
354
+ $try_generate = $has_gen_moar unless $options -> {' ignore-errors' };
355
+ }
356
+ elsif ($moar_version_output
357
+ && $moar_version_output =~ / This is MoarVM version/i )
358
+ {
359
+ push @errors ,
360
+ " Found a MoarVM binary "
361
+ . " but was not able to get its version number.\n "
362
+ . " If running `git describe` inside the MoarVM repository does not work,\n "
363
+ . " you need to make sure to checkout tags of the repository and run \n "
364
+ . " Configure.pl and make install again\n " ;
365
+ $try_generate = $has_gen_moar ;
366
+ }
347
367
}
348
368
349
369
if (@errors ) {
350
370
if ($try_generate ) {
351
- $self -> note(" ATTENTION!" , $_ ) foreach @errors ;
371
+ $self -> note( " ATTENTION!" , $_ ) foreach @errors ;
352
372
}
353
373
else {
354
374
$self -> sorry(@errors );
355
375
}
356
376
}
357
377
358
- if ( $try_generate ) {
378
+ if ( $try_generate || ( $has_gen_moar && $force_rebuild ) ) {
379
+
380
+ # Don't expect any particular commit in MoarVM/ if the repo is already
381
+ # checked out.
382
+ my $expected_spec =
383
+ -d File::Spec-> catdir( $self -> cfg(' base_dir' ), ' MoarVM' , ' .git' )
384
+ ? undef
385
+ : $moar_want ;
359
386
360
387
my $moar_repo =
361
388
$self -> git_checkout( ' moar' , ' MoarVM' , $gen_moar || $moar_want );
@@ -451,7 +478,7 @@ sub _m_stage_gencat {
451
478
return $self -> expand(<<TPL );
452
479
$text
453
480
\t\@ echo(+++ Generating\t\$\@ )@
454
- \t\@ noecho \@ \@ bpm(\@ ucstage\@ _GEN_CAT)\@ \@ prereqs\@ > \$\@
481
+ \t\$ (NOECHO) \@ bpm(\@ ucstage\@ _GEN_CAT)\@ \@ prereqs\@ > \$\@
455
482
TPL
456
483
}
457
484
@@ -465,7 +492,7 @@ sub _m_stage_precomp {
465
492
return $self -> expand(<<TPL );
466
493
$text
467
494
\t\@ echo(+++ Compiling\t\$\@ )@
468
- \t\@ noecho \@ \@ bpm(STAGE\@ prev_stage\@ _NQP)\@\@ expand(\@ setting_path_param\@\@ module_path_param\@ )\@ --no-regex-lib --target=\@ btarget\@ --setting=\@ nqp_setting\@ \@ bpm(PRECOMP_\@ ucstage\@ _FLAGS)\@ --output=\$\@ \@ prereqs\@
495
+ \t\$ (NOECHO) \@ bpm(STAGE\@ prev_stage\@ _NQP)\@\@ expand(\@ setting_path_param\@\@ module_path_param\@ )\@ --no-regex-lib --target=\@ btarget\@ --setting=\@ nqp_setting\@ \@ bpm(PRECOMP_\@ ucstage\@ _FLAGS)\@ --output=\$\@ \@ prereqs\@
469
496
TPL
470
497
}
471
498
0 commit comments