1. Rakudo::Internals.REGISTER-DYNAMIC: '$*RAKUDO_MODULE_DEBUG', {
  2. PROCESS::<$RAKUDO_MODULE_DEBUG> := ?%*ENV<RAKUDO_MODULE_DEBUG>
  3. ?? -> *@str --> Nil {
  4. state $level = %*ENV<RAKUDO_MODULE_DEBUG>++;
  5. my $indent = (($level - 1) * 4) + 1;
  6. my $str = @str>>.indent(7 + $indent).join("\n").substr(7 + $indent);
  7. note sprintf "%2d%sRMD: $str", $level, " " x $indent;
  8. }
  9. !! False
  10. }
  11. Rakudo::Internals.REGISTER-DYNAMIC: '$*EXECUTABLE', {
  12. PROCESS::<$EXECUTABLE> := (
  13. nqp::execname()
  14. || ($*VM.config<prefix> ~ '/bin/'
  15. ~ ($*VM.config<osname> eq 'MSWin32' ?? 'perl6-m.bat' !! 'perl6-m'))
  16. ).IO;
  17. }
  18. Rakudo::Internals.REGISTER-DYNAMIC: '$*EXECUTABLE-NAME', {
  19. PROCESS::<$EXECUTABLE-NAME> := $*EXECUTABLE.basename;
  20. }
  21. Rakudo::Internals.REGISTER-DYNAMIC: '$*PROGRAM-NAME', {
  22. PROCESS::<$PROGRAM-NAME> := nqp::getcomp('perl6').user-progname;
  23. }
  24. Rakudo::Internals.REGISTER-DYNAMIC: '$*PROGRAM', {
  25. PROCESS::<$PROGRAM> := IO::Path.new($*PROGRAM-NAME);
  26. }
  27. Rakudo::Internals.REGISTER-DYNAMIC: '$*TMPDIR', {
  28. PROCESS::<$TMPDIR> = $*SPEC.tmpdir;
  29. }
  30. Rakudo::Internals.REGISTER-DYNAMIC: '$*TOLERANCE', {
  31. PROCESS::<$TOLERANCE> := item 1e-15;
  32. }
  33. Rakudo::Internals.REGISTER-DYNAMIC: '$*REPO', {
  34. my $repo := PROCESS::<$REPO> := CompUnit::RepositoryRegistry.setup-repositories;
  35. my $world := $*W;
  36. $world.suspend_recording_precompilation_dependencies if $world;
  37. CompUnit::RepositoryRegistry.resolve-unknown-repos($repo);
  38. $world.resume_recording_precompilation_dependencies if $world;
  39. PROCESS::<$REPO>
  40. }
  41. Rakudo::Internals.REGISTER-DYNAMIC: '$*HOME', {
  42. my $HOME is default(Nil);
  43. if %*ENV<HOME> -> $home {
  44. $HOME = $home;
  45. }
  46. elsif Rakudo::Internals.IS-WIN {
  47. my $env := %*ENV;
  48. $env<HOMEDRIVE> && $env<HOMEPATH> && ($HOME
  49. = nqp::concat($env<HOMEDRIVE>, $env<HOMEPATH>));
  50. }
  51. $HOME = IO::Path.new($HOME) if $HOME;
  52. PROCESS::<$HOME> := $HOME # bind container so Nil default is kept
  53. }
  54. {
  55. sub fetch($what) {
  56. once if !Rakudo::Internals.IS-WIN && try { qx/id/ } -> $id {
  57. if $id ~~ m/^
  58. [ uid "=" $<uid>=(\d+) ]
  59. [ "(" $<user>=(<-[ ) ]>+) ")" ]
  60. \s+
  61. [ gid "=" $<gid>=(\d+) ]
  62. [ "(" $<group>=(<-[ ) ]>+) ")" ]
  63. / {
  64. PROCESS::<$USER> := IntStr.new(+$<uid>,~$<user>);
  65. PROCESS::<$GROUP> := IntStr.new(+$<gid>,~$<group>);
  66. }
  67. # alas, no support yet
  68. else {
  69. PROCESS::<$USER> := Nil;
  70. PROCESS::<$GROUP> := Nil;
  71. }
  72. }
  73. PROCESS::{$what}
  74. }
  75. Rakudo::Internals.REGISTER-DYNAMIC: '$*USER', { fetch('$USER') };
  76. Rakudo::Internals.REGISTER-DYNAMIC: '$*GROUP', { fetch('$GROUP') };
  77. }