Skip to content

Commit

Permalink
Merge pull request #3166 from vrurg/rakudo_3151
Browse files Browse the repository at this point in the history
[WIP] [HEADSUP] Extract common parts of backend makefiles into a common template

Unify the build across different backends as much as possible.
  • Loading branch information
vrurg committed Sep 8, 2019
2 parents 6b2739a + e4cee3e commit 66e0561
Show file tree
Hide file tree
Showing 15 changed files with 479 additions and 636 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Expand Up @@ -23,6 +23,8 @@ Makefile
*.lib
*.jar
*.moarvm
*.js.map
blib/Perl6/**/*.js
lib/Test.pir
lib/Pod/To/Text.pir
lib/lib.pir
Expand Down Expand Up @@ -63,7 +65,7 @@ perl6.rc
/perl6-eval-server
/perl6-eval-server.bat
/eval-client.pl
/rakudo.js
/perl6.js
/perl6-js
/perl6-js.bat
/perl6-m.c
Expand Down Expand Up @@ -107,7 +109,8 @@ config.status
config.default
/bin
rakudo-runtime.jar
CORE.setting.class
CORE.?.setting.class
CORE.?.setting.js
*.rakudo.moar
*.rakudo.jvm
.precomp
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/nqp-configure
3 changes: 2 additions & 1 deletion Configure.pl
Expand Up @@ -75,7 +75,7 @@ BEGIN
'rakudo-repo=s', 'nqp-repo=s',
'moar-repo=s', 'roast-repo=s',
'expand=s', 'out=s',
'set-var=s@',
'set-var=s@', 'silent-build!'
)
or do {
print_help();
Expand Down Expand Up @@ -204,6 +204,7 @@ sub print_help {
--set-var="config_variable=value"
Sets a config_variable to "value". Can be used multiple
times.
--no-silent-build Don't echo commands in Makefile target receipt.
Please note that the --gen-moar and --gen-nqp options are there for convenience
only and will actually immediately - at Configure time - compile and install
Expand Down
3 changes: 3 additions & 0 deletions gen/js/BOOTSTRAP/.gitignore
@@ -0,0 +1,3 @@
Makefile-JS.in
CORE.setting
*.nqp
1 change: 1 addition & 0 deletions gen/jvm/BOOTSTRAP/.gitignore
@@ -0,0 +1 @@
*
1 change: 1 addition & 0 deletions gen/moar/BOOTSTRAP/.gitignore
@@ -0,0 +1 @@
*
87 changes: 67 additions & 20 deletions tools/lib/NQP/Config/Rakudo.pm
@@ -1,5 +1,3 @@
## Please see file perltidy.ERR
## Please see file perltidy.ERR
use v5.10.1;

package NQP::Config::Rakudo;
Expand Down Expand Up @@ -241,7 +239,7 @@ sub configure_misc {
#];

# Get version info from VERSION template and git.
my $VERSION = slurp( File::Spec->catfile( $self->cfg('base_dir'), 'VERSION') );
my $VERSION = slurp( File::Spec->catfile( $self->cfg('base_dir'), 'VERSION' ) );
chomp $VERSION;
@{$config}{qw<version release codename>} = split( ' ', $VERSION, 3 );

Expand Down Expand Up @@ -350,17 +348,22 @@ sub configure_moar_backend {
File::Spec->rel2abs(
File::Spec->catdir( $config->{prefix}, 'share', 'perl6' ) );
$nqp_config->{static_nqp_home_define} =
'-DSTATIC_NQP_HOME='
. $qchar . $self->c_escape_string( $nqp_config->{static_nqp_home} ) . $qchar;
'-DSTATIC_NQP_HOME='
. $qchar
. $self->c_escape_string( $nqp_config->{static_nqp_home} )
. $qchar;
$nqp_config->{static_perl6_home_define} =
'-DSTATIC_PERL6_HOME='
. $qchar . $self->c_escape_string( $nqp_config->{static_perl6_home} ) . $qchar;
'-DSTATIC_PERL6_HOME='
. $qchar
. $self->c_escape_string( $nqp_config->{static_perl6_home} )
. $qchar;
}

# Strip rpath from ldflags so we can set it differently ourself.
$nqp_config->{ldflags} = $nqp_config->{'moar::ldflags'};
$nqp_config->{ldflags} =~ s/\Q$nqp_config->{'moar::ldrpath'}\E ?//;
$nqp_config->{ldflags} =~ s/\Q$nqp_config->{'moar::ldrpath_relocatable'}\E ?//;
$nqp_config->{ldflags} =~
s/\Q$nqp_config->{'moar::ldrpath_relocatable'}\E ?//;
if ( $config->{prefix} ne '/usr' ) {
$nqp_config->{ldflags} .= ' '
. (
Expand Down Expand Up @@ -444,8 +447,6 @@ sub configure_js_backend {
$config->{js_nqp} = $ijs->{bin};
$config->{'perl6_runtime'} =
File::Spec->rel2abs( $self->nfp('src/vm/js/perl6-runtime') );
$config->{'perl6_lowlevel_libs'} =
File::Spec->rel2abs('node_modules') . $slash;
$config->{'perl6_js_runner'} =
$self->batch_file( File::Spec->rel2abs('perl6-js') );

Expand Down Expand Up @@ -491,28 +492,37 @@ sub opts_for_configure {
}

sub clean_old_p6_libs {
my $self = shift;
my $is_moar = $self->active_backend('moar');
if ( $is_moar ) {
my $self = shift;
my $is_moar = $self->active_backend('moar');
if ($is_moar) {
my $nqp_config = $self->{impls}{moar}->{config};
my $lib_dir = File::Spec->rel2abs(File::Spec->catdir( $nqp_config->{'nqp::prefix'}, 'share', 'nqp', 'lib', 'Perl6' ));
my $lib_dir = File::Spec->rel2abs(
File::Spec->catdir(
$nqp_config->{'nqp::prefix'},
'share', 'nqp', 'lib', 'Perl6'
)
);

return if !-d $lib_dir;

my @files = qw(Actions.moarvm BOOTSTRAP.moarvm Compiler.moarvm Grammar.moarvm Metamodel.moarvm ModuleLoader.moarvm Ops.moarvm Optimizer.moarvm Pod.moarvm World.moarvm);
my @files =
qw(Actions.moarvm BOOTSTRAP.moarvm Compiler.moarvm Grammar.moarvm Metamodel.moarvm ModuleLoader.moarvm Ops.moarvm Optimizer.moarvm Pod.moarvm World.moarvm);

my @notes;
for ( @files ) {
for (@files) {
my $file = File::Spec->catdir( $lib_dir, $_ );
next unless -f $file;
push @notes, "Will remove: $file\n";
$self->{config}->{clean_old_p6_libs} .= "\t\$(RM_F) $file\n";
}
$self->note('NOTICE',
$self->note(
'NOTICE',
"Found stale files in $lib_dir.\n",
"These files were left by a previous install and cause breakage\n",
"in this Rakudo version. The files will be removed during install.\n",
"\n", @notes) if @notes;
"in this Rakudo version. The files will be removed during install.\n",
"\n",
@notes
) if @notes;
}
}

Expand Down Expand Up @@ -602,7 +612,8 @@ sub gen_nqp {
my %c = read_config($bin);
my $nqp_have = $c{'nqp::version'} || '';
$self->backend_config( $b, \%c ) if %c;
my $nqp_ver_ok = $nqp_have ? (0 <= cmp_rev( $nqp_have, $nqp_want )) : 0;
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'} ) {
Expand Down Expand Up @@ -753,9 +764,45 @@ sub _m_source_digest {
return $sha->hexdigest;
}

sub _m_gencat {
my $self = shift;
my $text = shift;
my $all_prereq = $self->cfg->cfg('make_all_prereq');
return $self->expand(<<TPL);
$text
\t\@echo(+++ Generating\t\$\@)@
\t\@noecho\@\@bpm(NQP)\@ \@bpm(GEN_CAT)\@ $all_prereq > \$\@
TPL
}

sub _m_comp {
my $self = shift;
my $text = shift;
my $first_prereq = $self->cfg->cfg('make_first_prereq');
return $self->expand(<<TPL);
$text
\t\@echo(+++ Compiling\t\$@)@
\t\@noecho@\@bpm(NQP)@ \@bpm(NQP_FLAGS)@ --target=\@btarget@ --output=\$@ $first_prereq
TPL
}

sub _m_comp_rr {
my $self = shift;
my $text = shift;
my $first_prereq = $self->cfg->cfg('make_first_prereq');
return $self->expand(<<TPL);
$text
\t\@echo(+++ Compiling\t\$@)@
\t\@noecho@\@bpm(NQP_RR)@ \@bpm(NQP_FLAGS)@ --target=\@btarget@ --output=\$@ \@bpm(NQP_FLAGS_EXTRA)@ $first_prereq
TPL
}

NQP::Macros->register_macro( 'for_specs', \&_m_for_specs );
NQP::Macros->register_macro( 'for_specmods', \&_m_for_specmods );
NQP::Macros->register_macro( 'source_digest', \&_m_source_digest );
NQP::Macros->register_macro( 'gencat', \&_m_gencat );
NQP::Macros->register_macro( 'comp', \&_m_comp );
NQP::Macros->register_macro( 'comp_rr', \&_m_comp_rr );

1;

Expand Down

0 comments on commit 66e0561

Please sign in to comment.