Skip to content

Commit

Permalink
Compiler.nqp: Add $rakudo-flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOks committed May 5, 2024
1 parent ca4bd66 commit 6e55b11
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions src/Perl6/Compiler.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,18 @@ class Perl6::Compiler is HLL::Compiler {
method lvs() { LanguageVersionServices }

method version_string(:$shorten-versions, :$no-unicode) {
my $config-version := self.config()<version>;
my $backend-version := nqp::getattr(self,HLL::Compiler,'$!backend').version_string;
my $config-version := self.config()<version>;
my $backend-version := nqp::getattr(self,HLL::Compiler,'$!backend').version_string;
my $execname := nqp::execname;
my $path-sep := nqp::backendconfig<osname> eq 'MSWin32' ?? '\\' !! '/';
my $install-dir := nqp::substr($execname, 0, nqp::rindex($execname, $path-sep, nqp::rindex($execname, $path-sep) - 1));
my $flavor-file := $install-dir ~ $path-sep ~ "etc" ~ $path-sep ~ "FLAVOR";
my $rakudo-core-flavor := " v";

my $raku;
my $rakudo;
my $rakudo-flavor;

if $shorten-versions {
my $index := nqp::index($config-version,"-");
$config-version := nqp::substr($config-version,0,$index)
Expand All @@ -166,9 +173,23 @@ class Perl6::Compiler is HLL::Compiler {
$rakudo := "Rakudo™";
}

# Support different flavors of Rakudo, i.e. Star.
# Rakudo flavor can be either set by an environment variable 'RAKUDO_FLAVOR'
# or by the special file '$RAKUDO_PREFIX/etc/FLAVOR'
if nqp::existskey(nqp::getenvhash(), 'RAKUDO_FLAVOR') {
$rakudo-flavor := " " ~ (nqp::getenvhash<RAKUDO_FLAVOR>) ~ $rakudo-core-flavor;
}
elsif nqp::stat($flavor-file, nqp::const::STAT_EXISTS) {
my $data := open($flavor-file, :r);
$rakudo-flavor := " " ~ ($data.get) ~ $rakudo-core-flavor;
}
else {
$rakudo-flavor := $rakudo-core-flavor;
}

"Welcome to "
~ $rakudo
~ " v"
~ $rakudo-flavor
~ $config-version
~ ".\nImplementing the "
~ $raku
Expand Down Expand Up @@ -355,10 +376,12 @@ Note that only boolean single-letter options may be bundled.
The following environment variables are respected:
RAKULIB Modify the module search path
PERL6LIB Modify the module search path (DEPRECATED)
RAKUDO_HOME Override the path of the Rakudo runtime files
NQP_HOME Override the path of the NQP runtime files
RAKULIB Modify the module search path
PERL6LIB Modify the module search path (DEPRECATED)
NQP_HOME Override the path of the NQP runtime files
RAKUDO_HOME Override the path of the Rakudo runtime files
RAKUDO_FLAVOR Set derived Rakudo compiler, i.e. "Star"
); # end of usage statement

Expand Down

0 comments on commit 6e55b11

Please sign in to comment.