specialpaths.nim 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #[
  2. todo: move findNimStdLibCompileTime, findNimStdLib here
  3. xxx: consider moving this to $nim/compiler/relpaths.nim to get relocatable paths
  4. ## note: $lib vs $nim
  5. note: these can resolve to 3 different paths if running via `nim c --lib:lib foo`,
  6. eg if compiler was installed via nimble (or is in nim path), and nim is external
  7. (ie not in `$lib/../bin/` dir)
  8. import "$lib/../compiler/nimpaths" # <- most robust if you want to favor --lib:lib
  9. import "$nim/compiler/nimpaths"
  10. import compiler/nimpaths
  11. ]#
  12. import os
  13. # Note: all the const paths defined here are known at compile time and valid
  14. # so long Nim repo isn't relocated after compilation.
  15. # This means the binaries they produce will embed hardcoded paths, which
  16. # isn't appropriate for some applications that need to be relocatable.
  17. const
  18. sourcePath = currentSourcePath()
  19. # robust way to derive other paths here
  20. # We don't depend on PATH so this is robust to having multiple nim binaries
  21. nimRootDir* = sourcePath.parentDir.parentDir.parentDir.parentDir ## root of Nim repo
  22. stdlibDir* = nimRootDir / "lib"
  23. systemPath* = stdlibDir / "system.nim"
  24. testsDir* = nimRootDir / "tests"
  25. buildDir* = nimRootDir / "build"
  26. ## refs #10268: all testament generated files should go here to avoid
  27. ## polluting .gitignore
  28. static:
  29. # sanity check
  30. doAssert fileExists(systemPath)