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> := IO::Path.new-from-absolute-path(
  18. nqp::execname()
  19. // ($*VM.config<prefix> ~ '/bin/'
  20. ~ ($*VM.config<osname> eq 'MSWin32' ?? 'perl6-m.bat' !! 'perl6-m'))
  21. );
  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;
  48. if %*ENV<HOME> -> $home {
  49. $HOME = $home;
  50. }
  51. elsif Rakudo::Internals.IS-WIN {
  52. $HOME = %*ENV<HOMEDRIVE> ~ %*ENV<HOMEPATH>;
  53. }
  54. PROCESS::<$HOME> = $HOME ?? IO::Path.new($HOME) !! Nil;
  55. }
  56. {
  57. sub fetch($what) {
  58. once if !Rakudo::Internals.IS-WIN && try { qx/id/ } -> $id {
  59. if $id ~~ m/^
  60. [ uid "=" $<uid>=(\d+) ]
  61. [ "(" $<user>=(<-[ ) ]>+) ")" ]
  62. \s+
  63. [ gid "=" $<gid>=(\d+) ]
  64. [ "(" $<group>=(<-[ ) ]>+) ")" ]
  65. / {
  66. PROCESS::<$USER> := IntStr.new(+$<uid>,~$<user>);
  67. PROCESS::<$GROUP> := IntStr.new(+$<gid>,~$<group>);
  68. }
  69. # alas, no support yet
  70. else {
  71. PROCESS::<$USER> := Nil;
  72. PROCESS::<$GROUP> := Nil;
  73. }
  74. }
  75. PROCESS::{$what}
  76. }
  77. Rakudo::Internals.REGISTER-DYNAMIC: '$*USER', { fetch('$USER') };
  78. Rakudo::Internals.REGISTER-DYNAMIC: '$*GROUP', { fetch('$GROUP') };
  79. }