Skip to content

Commit

Permalink
Moar and JVM backends are building now
Browse files Browse the repository at this point in the history
  • Loading branch information
vrurg committed Apr 1, 2019
1 parent c7b3bd7 commit 2974076
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 291 deletions.
23 changes: 15 additions & 8 deletions tools/lib/NQP/Config.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ sub configure_from_options {
) )
{ {
( my $ckey = $opt ) =~ s/-/_/g; ( my $ckey = $opt ) =~ s/-/_/g;
$self->{config}{$ckey} = $self->{options}->{$opt} || ''; $self->set_key( $ckey, $self->{options}->{$opt}, default => '', );
} }
$self->{config}{stagestats} = '--stagestats' $self->{config}{stagestats} = '--stagestats'
if $self->{options}{'makefile-timing'}; if $self->{options}{'makefile-timing'};
Expand Down Expand Up @@ -1086,6 +1086,17 @@ sub pop_ctx {
return pop @{ $self->{contexts} }; return pop @{ $self->{contexts} };
} }


sub set_key {
my $self = shift;
my ( $key, $val, %params ) = @_;
my $mname = "_ckey_$key";
if ( $self->can($mname) ) {
$val = $self->$mname($val);
}
$val //= $params{default};
return $self->{config}{$key} = $val;
}

# Searches for a config variable in contexts (from latest pushed upwards) and # Searches for a config variable in contexts (from latest pushed upwards) and
# then in the main config. If context contains more than one config hash in # then in the main config. If context contains more than one config hash in
# configs key then they're searched forward, from the first to the last. # configs key then they're searched forward, from the first to the last.
Expand Down Expand Up @@ -1127,8 +1138,8 @@ sub prop {


# $config->in_ctx(prop_name => "prop value") # $config->in_ctx(prop_name => "prop value")
sub in_ctx { sub in_ctx {
my $self = shift; my $self = shift;
my ($prop, $val) = @_; my ( $prop, $val ) = @_;
my %params = @_; my %params = @_;


for my $ctx ( $self->contexts ) { for my $ctx ( $self->contexts ) {
Expand Down Expand Up @@ -1282,11 +1293,7 @@ sub FETCH {
sub STORE { sub STORE {
my $self = shift; my $self = shift;
my ( $key, $val ) = @_; my ( $key, $val ) = @_;
my $mname = "_ckey_$key"; return $self->set_key( $key, $val );
if ( $self->can($mname) ) {
$val = $self->$mname($val);
}
return $self->{config}{$key} = $val;
} }


sub DELETE { sub DELETE {
Expand Down
92 changes: 58 additions & 34 deletions tools/lib/NQP/Configure/Macros.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require NQP::Config;
my %preexpand = map { $_ => 1 } qw< my %preexpand = map { $_ => 1 } qw<
include include_capture include include_capture
insert insert_capture insert_filelist insert insert_capture insert_filelist
expand template script expand template ctx_template script ctx_script
sp_escape nl_escape fixup uc lc nfp sp_escape nl_escape fixup uc lc nfp
>; >;
Expand Down Expand Up @@ -47,12 +47,12 @@ sub fail {
} }


sub execute { sub execute {
my $self = shift; my $self = shift;
my $macro = shift; my $macro = shift;
my $param = shift; my $param = shift;
my $orig_param = $param; my $orig_param = $param;
my %params = @_; my %params = @_;
my $cfg = $self->{config_obj}; my $cfg = $self->{config_obj};


$self->fail("Macro name is missing in call to method execute()") $self->fail("Macro name is missing in call to method execute()")
unless $macro; unless $macro;
Expand Down Expand Up @@ -229,8 +229,9 @@ sub not_in_context {
my ( $ctx_name, $ctx_prop ) = @_; my ( $ctx_name, $ctx_prop ) = @_;
if ( $cfg->prop($ctx_prop) ) { if ( $cfg->prop($ctx_prop) ) {
my $tip = ""; my $tip = "";
if ( $cfg->in_ctx(current_macro => 'include') ) { if ( $cfg->in_ctx( current_macro => 'include' ) ) {
$tip = " Perhaps you should use ctx_include macro instead of include?"; $tip =
" Perhaps you should use ctx_include macro instead of include?";
} }
$self->fail("Re-entering $ctx_name context is not allowed.$tip"); $self->fail("Re-entering $ctx_name context is not allowed.$tip");
} }
Expand Down Expand Up @@ -281,13 +282,36 @@ sub backends_iterate {
); );
my $be_ctx = { my $be_ctx = {
backend => $be, backend => $be,
configs => [ \%config ], configs => [ $cfg->{impls}{$be}{config}, \%config ],
}; };
my $s = $cfg->push_ctx($be_ctx); my $s = $cfg->push_ctx($be_ctx);
$cb->(@_); $cb->(@_);
} }
} }


sub find_filepath {
my $self = shift;
my $filenames = shift;
my %params = @_;
my @filenames = shellwords($filenames);
my $cfg = $self->{config_obj};
my @out;

my $where = $params{where} // 'template';
delete $params{where};

for my $src (@filenames) {
if ( $where eq 'build' ) {
push @out, $cfg->build_file_path( $src, required => 1, %params );
}
else {
push @out, $cfg->template_file_path( $src, required => 1, %params );
}
}

return join " ", @out;
}

# include(file1 file2) # include(file1 file2)
# Include a file. Parameter is expanded first, then the result is used a the # Include a file. Parameter is expanded first, then the result is used a the
# file name. File content is been expanded. # file name. File content is been expanded.
Expand Down Expand Up @@ -315,9 +339,9 @@ sub _m_ctx_insert {
shift->include( shift, as_is => 1, subdirs_only => 1 ); shift->include( shift, as_is => 1, subdirs_only => 1 );
} }


# backends_ctx(text) # for_backends(text)
# Iterates over active backends and expands text in the context of each backend. # Iterates over active backends and expands text in the context of each backend.
sub _m_backends_ctx { sub _m_for_backends {
my $self = shift; my $self = shift;
my $text = shift; my $text = shift;


Expand All @@ -332,9 +356,9 @@ sub _m_backends_ctx {
return $out; return $out;
} }


# backends_ctx(text) # for_specs(text)
# Iterates over active backends and expands text in the context of each backend. # Iterates over active backends and expands text in the context of each backend.
sub _m_specs_ctx { sub _m_for_specs {
my $self = shift; my $self = shift;
my $text = shift; my $text = shift;


Expand Down Expand Up @@ -367,34 +391,34 @@ sub _m_expand {
# Finds corresponding template file for file names in parameter. Templates are # Finds corresponding template file for file names in parameter. Templates are
# been searched in templates_dir and possibly ctx_subdir if under a context. # been searched in templates_dir and possibly ctx_subdir if under a context.
sub _m_template { sub _m_template {
my $self = shift; my $self = shift;
my $filenames = shift; return $self->find_filepath( shift, where => 'template', );
my @filenames = shellwords($filenames); }
my $cfg = $self->{config_obj};
my @out;

for my $src (@filenames) {
push @out, $cfg->template_file_path( $src, required => 1 );
}


return join " ", @out; # ctx_template(file1 file2)
# Similar to template but looks only in the current context subdir
sub _m_ctx_template {
my $self = shift;
return $self->find_filepath(
shift,
where => 'template',
subdirs_only => 1,
);
} }


# script(file1 file2) # script(file1 file2)
# Similar to the template above but looks in tools/build directory for files # Similar to the template above but looks in tools/build directory for files
# with extensions .pl, .nqp, .p6. # with extensions .pl, .nqp, .p6.
sub _m_script { sub _m_script {
my $self = shift; my $self = shift;
my $filenames = shift; return $self->find_filepath( shift, where => 'build', );
my @filenames = shellwords($filenames); }
my $cfg = $self->{config_obj};
my @out;

for my $src (@filenames) {
push @out, $cfg->build_file_path( $src, required => 1 );
}


return join( " ", @out ); # ctx_script(file1 file2)
# Similar to script but looks only in the current context subdir
sub _m_ctx_script {
my $self = shift;
return $self->find_filepath( shift, where => 'build', subdirs_only => 1, );
} }


# include_capture(command line) # include_capture(command line)
Expand Down Expand Up @@ -483,7 +507,7 @@ sub _m_nfp {
if ($file) { # If text starts with spaces $file will be empty if ($file) { # If text starts with spaces $file will be empty
$file = NQP::Config::nfp($file); $file = NQP::Config::nfp($file);
} }
$out .= $file . ($ws // ""); $out .= $file . ( $ws // "" );
} }
return $out; return $out;
} }
Expand Down
20 changes: 9 additions & 11 deletions tools/templates/Makefile.in
Original file line number Original file line Diff line number Diff line change
@@ -1,27 +1,25 @@
# Template Makefile # Template Makefile


@backends_ctx( @backend@-include)@

@include(Makefile-common-macros)@ @include(Makefile-common-macros)@


LAUNCHER = @default_prefix@-runner-default LAUNCHER = @default_prefix@-runner-default


all: @backends_ctx(@backend_prefix@-all)@ $(LAUNCHER) all:@for_backends( @backend_prefix@-all)@ $(LAUNCHER)


install: @backends_ctx(@backend_prefix@-install )@ $(LAUNCHER)-install install: @for_backends(@backend_prefix@-install )@ $(LAUNCHER)-install


clean: @backends_ctx(@backend_prefix@-clean )@ $(LAUNCHER)-clean clean: @for_backends(@backend_prefix@-clean )@
$(RM_F) perl6@runner_suffix@ $(RM_F) perl6@runner_suffix@


test: @backends_ctx(@backend_prefix@-test$(HARNESS_TYPE))@ test: @for_backends(@backend_prefix@-test$(HARNESS_TYPE))@
spectest: @backends_ctx(@backend_prefix@-spectest$(HARNESS_TYPE))@ spectest: @for_backends(@backend_prefix@-spectest$(HARNESS_TYPE))@
coretest: @backends_ctx(@backend_prefix@-coretest$(HARNESS_TYPE))@ coretest: @for_backends(@backend_prefix@-coretest$(HARNESS_TYPE))@
localtest: @backends_ctx(@backend_prefix@-localtest$(HARNESS_TYPE))@ localtest: @for_backends(@backend_prefix@-localtest$(HARNESS_TYPE))@
stresstest: @backends_ctx(@backend_prefix@-stresstest$(HARNESS_TYPE))@ stresstest: @for_backends(@backend_prefix@-stresstest$(HARNESS_TYPE))@


@include(Makefile-common-rules)@ @include(Makefile-common-rules)@


@backends_ctx(@ctx_include(Makefile)@)@ @for_backends(@ctx_include(Makefile)@)@


t/*/*.t t/*.t t/*/*/*.t: all t/*/*.t t/*.t t/*/*/*.t: all
$(@uc(@default_prefix@)@_HARNESS5_WITH_FUDGE) --verbosity=1 $@ $(@uc(@default_prefix@)@_HARNESS5_WITH_FUDGE) --verbosity=1 $@
2 changes: 1 addition & 1 deletion tools/templates/PERL6_SPECS
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
# version [suffix] # version [suffix]
c c
d PREVIEW # TODO: It's about time to drop PREVIEW d PREVIEW # TODO: It's about time to drop PREVIEW
e PREVIEW #e PREVIEW
Loading

0 comments on commit 2974076

Please sign in to comment.