Skip to content
Permalink
Browse files

Moar and JVM backends are building now

  • Loading branch information...
vrurg committed Apr 1, 2019
1 parent c7b3bd7 commit 2974076be557d5b96cb1c5a1157a61fc5834b638
@@ -619,7 +619,7 @@ sub configure_from_options {
)
{
( my $ckey = $opt ) =~ s/-/_/g;
$self->{config}{$ckey} = $self->{options}->{$opt} || '';
$self->set_key( $ckey, $self->{options}->{$opt}, default => '', );
}
$self->{config}{stagestats} = '--stagestats'
if $self->{options}{'makefile-timing'};
@@ -1086,6 +1086,17 @@ sub pop_ctx {
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
# 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.
@@ -1127,8 +1138,8 @@ sub prop {

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

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

sub DELETE {
@@ -11,7 +11,7 @@ require NQP::Config;
my %preexpand = map { $_ => 1 } qw<
include include_capture
insert insert_capture insert_filelist
expand template script
expand template ctx_template script ctx_script
sp_escape nl_escape fixup uc lc nfp
>;
@@ -47,12 +47,12 @@ sub fail {
}

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

$self->fail("Macro name is missing in call to method execute()")
unless $macro;
@@ -229,8 +229,9 @@ sub not_in_context {
my ( $ctx_name, $ctx_prop ) = @_;
if ( $cfg->prop($ctx_prop) ) {
my $tip = "";
if ( $cfg->in_ctx(current_macro => 'include') ) {
$tip = " Perhaps you should use ctx_include macro instead of include?";
if ( $cfg->in_ctx( current_macro => 'include' ) ) {
$tip =
" Perhaps you should use ctx_include macro instead of include?";
}
$self->fail("Re-entering $ctx_name context is not allowed.$tip");
}
@@ -281,13 +282,36 @@ sub backends_iterate {
);
my $be_ctx = {
backend => $be,
configs => [ \%config ],
configs => [ $cfg->{impls}{$be}{config}, \%config ],
};
my $s = $cfg->push_ctx($be_ctx);
$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 a file. Parameter is expanded first, then the result is used a the
# file name. File content is been expanded.
@@ -315,9 +339,9 @@ sub _m_ctx_insert {
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.
sub _m_backends_ctx {
sub _m_for_backends {
my $self = shift;
my $text = shift;

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

# backends_ctx(text)
# for_specs(text)
# 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 $text = shift;

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

for my $src (@filenames) {
push @out, $cfg->template_file_path( $src, required => 1 );
}
my $self = shift;
return $self->find_filepath( shift, where => 'template', );
}

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)
# Similar to the template above but looks in tools/build directory for files
# with extensions .pl, .nqp, .p6.
sub _m_script {
my $self = shift;
my $filenames = shift;
my @filenames = shellwords($filenames);
my $cfg = $self->{config_obj};
my @out;

for my $src (@filenames) {
push @out, $cfg->build_file_path( $src, required => 1 );
}
my $self = shift;
return $self->find_filepath( shift, where => 'build', );
}

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)
@@ -483,7 +507,7 @@ sub _m_nfp {
if ($file) { # If text starts with spaces $file will be empty
$file = NQP::Config::nfp($file);
}
$out .= $file . ($ws // "");
$out .= $file . ( $ws // "" );
}
return $out;
}
@@ -1,27 +1,25 @@
# Template Makefile

@backends_ctx( @backend@-include)@

@include(Makefile-common-macros)@

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@

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

@include(Makefile-common-rules)@

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

t/*/*.t t/*.t t/*/*/*.t: all
$(@uc(@default_prefix@)@_HARNESS5_WITH_FUDGE) --verbosity=1 $@
@@ -1,4 +1,4 @@
# version [suffix]
c
d PREVIEW # TODO: It's about time to drop PREVIEW
e PREVIEW
#e PREVIEW

0 comments on commit 2974076

Please sign in to comment.
You can’t perform that action at this time.