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