Skip to content

Commit

Permalink
Merge pull request #3793 from patrickbkr/fix-profile-with-reloc-build
Browse files Browse the repository at this point in the history
Refactor rakudo-home and nqp-home handling
  • Loading branch information
patrickbkr committed Jul 16, 2020
2 parents 85320f4 + e4f020c commit 37d5831
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 73 deletions.
28 changes: 28 additions & 0 deletions src/Perl6/Compiler.nqp
Expand Up @@ -7,6 +7,7 @@ class Perl6::Compiler is HLL::Compiler {
has $!language_modifier; # Active language modifier; PREVIEW mostly.
has $!language_revisions; # Hash of language revision letters. See gen/<vm>/main-version.nqp
has $!can_language_versions; # List of valid language version
has $!rakudo-home;

method compilation-id() {
my class IDHolder { }
Expand Down Expand Up @@ -98,6 +99,33 @@ class Perl6::Compiler is HLL::Compiler {
$p6repl.repl-loop(:interactive(1), |%adverbs)
}

method rakudo-home() {
if !$!rakudo-home {
# Determine Perl6 and NQP dirs.
#?if jvm
my $sep := nqp::atkey(nqp::jvmgetproperties,'os.name') eq 'MSWin32' ?? '\\' !! '/';
my $execname := nqp::atkey(nqp::jvmgetproperties,'perl6.execname') // '';
#?endif
#?if !jvm
my $config := nqp::backendconfig();
my $sep := $config<osname> eq 'MSWin32' ?? '\\' !! '/';
my $execname := nqp::execname();
#?endif
my $install-dir := $execname eq ''
?? self.config<prefix>
!! nqp::substr($execname, 0, nqp::rindex($execname, $sep, nqp::rindex($execname, $sep) - 1));

$!rakudo-home := self.config<static-rakudo-home>
|| nqp::getenvhash()<RAKUDO_HOME>
// nqp::getenvhash()<PERL6_HOME>
// $install-dir ~ '/share/perl6';
if nqp::substr($!rakudo-home, nqp::chars($!rakudo-home) - 1) eq $sep {
$!rakudo-home := nqp::substr($!rakudo-home, 0, nqp::chars($!rakudo-home) - 1);
}
}
$!rakudo-home;
}

method usage($name?, :$use-stderr = False) {
my $print-func := $use-stderr ?? &note !! &say;
my $compiler := nqp::getcomp("Raku").backend.name;
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/CompUnit/RepositoryRegistry.pm6
Expand Up @@ -128,7 +128,7 @@ class CompUnit::RepositoryRegistry {
# set up and normalize $prefix if needed
my str $prefix = nqp::ifnull(
nqp::atkey($ENV,'RAKUDO_PREFIX'),
nqp::getcurhllsym('$RAKUDO_HOME')
nqp::getcomp('Raku').rakudo-home()
);
$prefix = $prefix.subst(:g, '/', $sep) if Rakudo::Internals.IS-WIN;

Expand Down
34 changes: 0 additions & 34 deletions src/main.nqp
Expand Up @@ -17,40 +17,6 @@ $comp.addstage('optimize', :after<ast>);
hll-config($comp.config);
nqp::bindhllsym('Raku', '$COMPILER_CONFIG', $comp.config);


# Determine Perl6 and NQP dirs.
#?if jvm
my $sep := nqp::atkey(nqp::jvmgetproperties,'os.name') eq 'MSWin32' ?? '\\' !! '/';
my $execname := nqp::atkey(nqp::jvmgetproperties,'perl6.execname');
#?endif
#?if !jvm
my $config := nqp::backendconfig();
my $sep := $config<osname> eq 'MSWin32' ?? '\\' !! '/';
my $execname := nqp::execname();
#?endif
my $install-dir := $execname eq ''
?? $comp.config<prefix>
!! nqp::substr($execname, 0, nqp::rindex($execname, $sep, nqp::rindex($execname, $sep) - 1));

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

my $nqp-home := $comp.config<static-nqp-home>
|| nqp::getenvhash()<NQP_HOME>
// $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);
}

nqp::bindhllsym('Raku', '$RAKUDO_HOME', $rakudo-home);
nqp::bindhllsym('Raku', '$NQP_HOME', $nqp-home);


# Add extra command line options.
my @clo := $comp.commandline_options();
@clo.push('parsetrace');
Expand Down
34 changes: 0 additions & 34 deletions src/rakudo-debug.nqp
Expand Up @@ -465,40 +465,6 @@ sub MAIN(*@ARGS) {
my $COMPILER_CONFIG := $comp.config;
nqp::bindhllsym('Raku', '$COMPILER_CONFIG', $comp.config);


# Determine Raku and NQP dirs.
#?if jvm
my $sep := nqp::atkey(nqp::jvmgetproperties,'os.name') eq 'MSWin32' ?? '\\' !! '/';
my $execname := nqp::atkey(nqp::jvmgetproperties,'perl6.execname');
#?endif
#?if !jvm
my $config := nqp::backendconfig();
my $sep := $config<osname> eq 'MSWin32' ?? '\\' !! '/';
my $execname := nqp::execname();
#?endif
my $install-dir := $execname eq ''
?? $comp.config<prefix>
!! nqp::substr($execname, 0, nqp::rindex($execname, $sep, nqp::rindex($execname, $sep) - 1));

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

my $nqp-home := $comp.config<static-nqp-home>
// nqp::getenvhash()<NQP_HOME>
// $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);
}

nqp::bindhllsym('Raku', '$RAKUDO_HOME', $rakudo-home);
nqp::bindhllsym('Raku', '$NQP_HOME', $nqp-home);


# Add extra command line options.
my @clo := $comp.commandline_options();
@clo.push('setting=s');
Expand Down
4 changes: 2 additions & 2 deletions src/vm/moar/ModuleLoaderVMConfig.nqp
@@ -1,9 +1,9 @@
role Perl6::ModuleLoaderVMConfig {
method vm_search_paths() {
my @search_paths;
@search_paths.push(nqp::getcurhllsym('$RAKUDO_HOME') ~ '/lib');
@search_paths.push(nqp::getcomp('Raku').rakudo-home() ~ '/lib');
# XXX CHEAT: Goes away when we implement :from<nqp>.
@search_paths.push(nqp::getcurhllsym('$NQP_HOME') ~ '/lib');
@search_paths.push(nqp::getcomp('Raku').nqp-home() ~ '/lib');
@search_paths
}

Expand Down
2 changes: 1 addition & 1 deletion tools/build/binary-release/build-linux.sh
Expand Up @@ -3,7 +3,7 @@
# This script should be allowed to run sudo in a CentOS 6 installation (a
# container will do just fine).
# For some strange reason the environment variables are lost when running this
# script with `sudo` in azure pipelines. So we just do sudo our selves for the
# script with `sudo` in azure pipelines. So we just do sudo ourselves for the
# dependency install part.

set -o errexit
Expand Down
2 changes: 1 addition & 1 deletion tools/templates/NQP_REVISION
@@ -1 +1 @@
2020.06-9-gdb0c1088f
2020.06-15-g3e5403f16

0 comments on commit 37d5831

Please sign in to comment.