Skip to content
Permalink
Browse files

Remove relative elements from NQP_HOME and PERL6_HOME

This in turn results in the repository path specs to not contain any
relative path elements.
  • Loading branch information...
patzim committed Apr 17, 2019
1 parent 298c313 commit 65217aaafc385294eb55fbdff8a31b25e84f3a07
Showing with 18 additions and 14 deletions.
  1. +9 −7 src/main.nqp
  2. +9 −7 src/perl6-debug.nqp
@@ -7,17 +7,19 @@ my $config := nqp::backendconfig();
my $sep := $config<osname> eq 'MSWin32' ?? '\\' !! '/';
#?if jvm
my $execname := nqp::atkey(nqp::jvmgetproperties,'perl6.execname');
my $exec-dir := nqp::substr($execname, 0, nqp::rindex($execname, $sep));
my $install-dir := nqp::substr($execname, 0, nqp::rindex($execname, $sep, nqp::rindex($execname, $sep) - 1));

This comment has been minimized.

Copy link
@usev6

usev6 Apr 26, 2019

Contributor

This didn't work as expected on the JVM backend. The build was successful, but executing a command led to a StringIndexOutOfBoundsException. I've committed a bandaid for the release with 07b4f74

@patzim Maybe you could take a look if my commit makes sense? I don't fully understand how $install-dir should look like when I execute a command like this:

$ ./perl6-j -e 'say 42'

This comment has been minimized.

Copy link
@patzim

patzim Apr 27, 2019

Author Contributor

Another (?) difference is that on moar execname is always an absolute path, while on JVM it's just argv[0]. That's why the $install-dir thing doesn't work here. $install-dir is meant to just be one directory up from where the executable is located. So a cleaner fix would be to make sure execname is always absolute. I think changing that is probably only a very small change in tools/build/create-jvm-runner.pl. I'll have a look at that now.

This comment has been minimized.

Copy link
@patzim

patzim Apr 27, 2019

Author Contributor

@usev6 I implemented the fix I mentioned above in this commit: patzim@0effc37 If you could give that commit a try (possibly also with 07b4f74 reverted) that'd be great.

This comment has been minimized.

Copy link
@usev6

usev6 Apr 27, 2019

Contributor

@patzim Looks good so far. I was able to build and install with your patch (and with 07b4f74 reverted). Thanks for looking into this!

I'd say you could go ahead, revert 07b4f74 and commit your patch. (I have to admit that I don't know why argv[0] was used instead of an absolute path. Probably historical reasons?!)

This comment has been minimized.

Copy link
@patzim

patzim Apr 27, 2019

Author Contributor

Getting the absolute path is non trivial. Code to do it wasn't there until the relocatability refactor. That's why argv[0] was used instead of the absolute path up until now.

#?endif
#?if moar
my $exec-dir := $config<osname> eq 'openbsd'
my $execname := nqp::execname();
my $install-dir := $config<osname> eq 'openbsd'
?? $config<prefix> ~ '/bin/perl6-m'
!! nqp::substr(nqp::execname(), 0, nqp::rindex(nqp::execname(), $sep));
!! nqp::substr($execname, 0, nqp::rindex($execname, $sep, nqp::rindex($execname, $sep) - 1));
#?endif
#?if js
my $exec-dir := $config<osname> eq 'openbsd'
my $execname := nqp::execname();
my $install-dir := $config<osname> eq 'openbsd'
?? $config<prefix> ~ '/bin/perl6-js'
!! nqp::substr(nqp::execname(), 0, nqp::rindex(nqp::execname(), $sep))
!! nqp::substr($execname, 0, nqp::rindex($execname, $sep, nqp::rindex($execname, $sep) - 1));
#?endif


@@ -29,14 +31,14 @@ my $comp := Perl6::Compiler.new();

my $perl6-home := $comp.config<static_perl6_home>
// nqp::getenvhash()<PERL6_HOME>
// $exec-dir ~ '/../share/perl6';
// $install-dir ~ '/share/perl6';
if nqp::substr($perl6-home, nqp::chars($perl6-home) - 1) eq $sep {
$perl6-home := nqp::substr($perl6-home, 0, nqp::chars($perl6-home) - 1);
}

my $nqp-home := $comp.config<static_nqp_home>
// nqp::getenvhash()<NQP_HOME>
// $exec-dir ~ '/../share/nqp';
// $install-dir ~ '/share/nqp';
if nqp::substr($nqp-home, nqp::chars($nqp-home) - 1) eq $sep {
$nqp-home := nqp::substr($nqp-home, 0, nqp::chars($nqp-home) - 1);
}
@@ -461,28 +461,30 @@ sub MAIN(*@ARGS) {
my $sep := $config<osname> eq 'MSWin32' ?? '\\' !! '/';
#?if jvm
my $execname := nqp::atkey(nqp::jvmgetproperties,'perl6.execname');
my $exec-dir := nqp::substr($execname, 0, nqp::rindex($execname, $sep));
my $install-dir := nqp::substr($execname, 0, nqp::rindex($execname, $sep, nqp::rindex($execname, $sep) - 1));
#?endif
#?if moar
my $exec-dir := $config<osname> eq 'openbsd'
my $execname := nqp::execname();
my $install-dir := $config<osname> eq 'openbsd'
?? $config<prefix> ~ '/bin/perl6-m'
!! nqp::substr(nqp::execname(), 0, nqp::rindex(nqp::execname(), $sep));
!! nqp::substr($execname, 0, nqp::rindex($execname, $sep, nqp::rindex($execname, $sep) - 1));
#?endif
#?if js
my $exec-dir := $config<osname> eq 'openbsd'
my $execname := nqp::execname();
my $install-dir := $config<osname> eq 'openbsd'
?? $config<prefix> ~ '/bin/perl6-js'
!! nqp::substr(nqp::execname(), 0, nqp::rindex(nqp::execname(), $sep));
!! nqp::substr($execname, 0, nqp::rindex($execname, $sep, nqp::rindex($execname, $sep) - 1));
#?endif
my $perl6-home := $comp.config<static_perl6_home>
// nqp::getenvhash()<PERL6_HOME>
// $exec-dir ~ '/../share/perl6';
// $install-dir ~ '/share/perl6';
if nqp::substr($perl6-home, nqp::chars($perl6-home) - 1) eq $sep {
$perl6-home := nqp::substr($perl6-home, 0, nqp::chars($perl6-home) - 1);
}

my $nqp-home := $comp.config<static_nqp_home>
// nqp::getenvhash()<NQP_HOME>
// $exec-dir ~ '/../share/nqp';
// $install-dir ~ '/share/nqp';
if nqp::substr($nqp-home, nqp::chars($nqp-home) - 1) eq $sep {
$nqp-home := nqp::substr($nqp-home, 0, nqp::chars($nqp-home) - 1);
}

0 comments on commit 65217aa

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