Skip to content

Commit

Permalink
Add Compiler.flavor
Browse files Browse the repository at this point in the history
f253d68b85 added support
for #RAKUDO_FLAVOR# in source code that is being handled by the
tools/build/gen-cat.nqp script.

This commit slightly tweaks that, by just returning the actual
string found in %*ENV<RAKUDO_FLAVOR> without a space prefixed.
Adapt Compiler.nqp accordingly and add method "flavor" so that
any code can introspect which flavor of Rakudo is being run.

This could e.g. be used to assume (non-)availability of installed
modules depending on the flavor, or just simply add the flavor to
certain (error) messages.
  • Loading branch information
lizmat committed May 6, 2024
1 parent f253d68 commit 69a3356
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Perl6/Compiler.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ class Perl6::Compiler is HLL::Compiler {
$raku := "Raku®";
$rakudo := "Rakudo™";
}
my $flavor := #RAKUDO_FLAVOR#;
$flavor := " $flavor" if $flavor;

"Welcome to "
~ $rakudo
~ #RAKUDO_FLAVOR#
~ $flavor
~ " v"
~ $config-version
~ ".\nImplementing the "
Expand Down
1 change: 1 addition & 0 deletions src/core.c/Compiler.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Compiler does Systemic {
}

method backend() { $name }
method flavor() { #RAKUDO_FLAVOR# }

proto method id(|) {*}
multi method id(Compiler:U:) { $compilation-id }
Expand Down
1 change: 0 additions & 1 deletion tools/build/gen-cat.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ sub MAIN(*@ARGS) {
nqp::atkey(nqp::getenvhash, 'RAKUDO_FLAVOR'),
""
);
$flavor := " $flavor" if $flavor;
print(
nqp::join("'$flavor'", nqp::split('#RAKUDO_FLAVOR#', $_))
);
Expand Down

0 comments on commit 69a3356

Please sign in to comment.