compilesettings.nim 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2020 Nim Contributors
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. ## This module allows querying the compiler about
  10. ## diverse configuration settings. See also `compileOption`.
  11. # Note: Only add new enum values at the end to ensure binary compatibility with
  12. # other Nim compiler versions!
  13. type
  14. SingleValueSetting* {.pure.} = enum ## \
  15. ## settings resulting in a single string value
  16. arguments, ## experimental: the arguments passed after '-r'
  17. outFile, ## experimental: the output file
  18. outDir, ## the output directory
  19. nimcacheDir, ## the location of the 'nimcache' directory
  20. projectName, ## the project's name that is being compiled
  21. projectPath, ## experimental: some path to the project that is being compiled
  22. projectFull, ## the full path to the project that is being compiled
  23. command, ## experimental: the command (e.g. 'c', 'cpp', 'doc') passed to
  24. ## the Nim compiler
  25. commandLine, ## experimental: the command line passed to Nim
  26. linkOptions, ## additional options passed to the linker
  27. compileOptions, ## additional options passed to the C/C++ compiler
  28. ccompilerPath ## the path to the C/C++ compiler
  29. backend ## the backend (eg: c|cpp|objc|js); both `nim doc --backend:js`
  30. ## and `nim js` would imply backend=js
  31. libPath ## the absolute path to the stdlib library, i.e. nim's `--lib`, since 1.5.1
  32. gc {.deprecated.} ## gc selected
  33. mm ## memory management selected
  34. MultipleValueSetting* {.pure.} = enum ## \
  35. ## settings resulting in a seq of string values
  36. nimblePaths, ## the nimble path(s)
  37. searchPaths, ## the search path for modules
  38. lazyPaths, ## experimental: even more paths
  39. commandArgs, ## the arguments passed to the Nim compiler
  40. cincludes, ## the #include paths passed to the C/C++ compiler
  41. clibs ## libraries passed to the C/C++ compiler
  42. proc querySetting*(setting: SingleValueSetting): string {.
  43. compileTime, noSideEffect.} =
  44. ## Can be used to get a string compile-time option.
  45. ##
  46. ## See also:
  47. ## * `compileOption <system.html#compileOption,string>`_ for `on|off` options
  48. ## * `compileOption <system.html#compileOption,string,string>`_ for enum options
  49. ##
  50. runnableExamples:
  51. const nimcache = querySetting(SingleValueSetting.nimcacheDir)
  52. proc querySettingSeq*(setting: MultipleValueSetting): seq[string] {.
  53. compileTime, noSideEffect.} =
  54. ## Can be used to get a multi-string compile-time option.
  55. ##
  56. ## See also:
  57. ## * `compileOption <system.html#compileOption,string>`_ for `on|off` options
  58. ## * `compileOption <system.html#compileOption,string,string>`_ for enum options
  59. runnableExamples:
  60. const nimblePaths = querySettingSeq(MultipleValueSetting.nimblePaths)