Skip to content

Commit

Permalink
Provide a valid NQP-home to the build dir rakudo runner
Browse files Browse the repository at this point in the history
When building a relocatable rakudo, NQP-home is not set to a static value,
but determined dynamically based on the path of the program currently
running. This fails for the build dir runners, as they are not located in
the installation folder. We work around this, by setting the NQP_HOME env
variable to the NQP-home directory in the installation directory.
  • Loading branch information
patrickbkr committed Aug 27, 2020
1 parent c741582 commit eab3e1c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tools/build/create-jvm-runner.pl
Expand Up @@ -118,10 +118,12 @@
}
}
else {
my $nqp_home = File::Spec->catdir(abs_path($prefix), 'share', 'nqp');

$preamble = join("\n",
$preamble_unix,
"$NQP_LIB",
": \${NQP_HOME:=\"$static_nqp_home\"}",
"NQP_HOME=\"$nqp_home\"",
": \${NQP_JARS:=\"$nqpjars\"}",
": \${RAKUDO_HOME:=\"$prefix\"}",
": \${RAKUDO_JARS:=\"$rakudo_jars\"}",
Expand Down
7 changes: 7 additions & 0 deletions tools/lib/NQP/Config/Rakudo.pm
Expand Up @@ -161,6 +161,13 @@ sub configure_refine_vars {
)
);

$config->{nqp_home} = $self->nfp(
File::Spec->rel2abs(
$config->{nqp_home}
|| File::Spec->catdir( $config->{'prefix'}, 'share', 'nqp' )
)
);

$config->{static_rakudo_home} =
$config->{relocatable} eq 'reloc'
? ''
Expand Down
3 changes: 2 additions & 1 deletion tools/templates/moar/Makefile.in
Expand Up @@ -123,7 +123,8 @@ $(R_SETTING_MOAR): @bsm(RAKUDO)@@for_specs( @bsm(SETTING_@ucspec@)@)@ $(R_SETTIN
--set-var=base_dir=@shquot(@nfp(@base_dir@)@)@ \
--set-var=nqp_lib_dir=@shquot(@nfp(@nqp::libdir@)@)@ \
--set-var=exec_name=@shquot(@nfp(@base_dir@/@bpm(RUNNER)@)@)@ \
--set-var=mbc=@bsm(RAKUDO)@
--set-var=mbc=@bsm(RAKUDO)@ \
--set-var=nqp_home=@shquot(@nfp(@nqp_home@)@)@
$(NOECHO)@bpm(CC)@ @moar::ccswitch@ @bpm(CFLAGS)@ @moar::ccout@rakudo-m@moar::obj@ rakudo-m.c
$(NOECHO)@bpm(LD)@ @moar::ldout@$@ @bpm(LDFLAGS)@ @bpm(MINGW_UNICODE)@ rakudo-m@moar::obj@

Expand Down
2 changes: 2 additions & 0 deletions tools/templates/moar/rakudo-m-build.c.in
Expand Up @@ -35,6 +35,8 @@ int main(int argc, char *argv[])

exec_argv[exec_argc - 1] = NULL;

setenv("NQP_HOME", "@c_escape(@nfp(@nqp_home@)@)@", 1);

// Hack: Explicitly set a dummy RAKUDO_HOME, so the autogenerated
// CompUnitRepo folder structure does not end up in the build directories
// parent folder.
Expand Down
2 changes: 2 additions & 0 deletions tools/templates/moar/rakudo-m-build.c.windows
Expand Up @@ -119,6 +119,8 @@ int wmain(int argc, wchar_t *argv[]) {
}
cmd_line[cmd_line_size - 1] = 0;

_wputenv_s(L"NQP_HOME", L"@c_escape(@nfp(@nqp_home@)@)@");

// Hack: Explicitly set a dummy RAKUDO_HOME, so the autogenerated CompUnitRepo
// folder structure does not end up in the build directories parent folder.
_wputenv_s(L"RAKUDO_HOME", L"@c_escape(@nfp(@base_dir@/gen/build_rakudo_home)@)@");
Expand Down

0 comments on commit eab3e1c

Please sign in to comment.