compilesettings.nim 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #
  2. #
  3. # The Nim Compiler
  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.
  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. MultipleValueSetting* {.pure.} = enum ## \
  33. ## settings resulting in a seq of string values
  34. nimblePaths, ## the nimble path(s)
  35. searchPaths, ## the search path for modules
  36. lazyPaths, ## experimental: even more paths
  37. commandArgs, ## the arguments passed to the Nim compiler
  38. cincludes, ## the #include paths passed to the C/C++ compiler
  39. clibs ## libraries passed to the C/C++ compiler
  40. proc querySetting*(setting: SingleValueSetting): string {.
  41. compileTime, noSideEffect.} =
  42. ## Can be used to get a string compile-time option.
  43. ##
  44. ## See also:
  45. ## * `compileOption <system.html#compileOption,string>`_ for `on|off` options
  46. ## * `compileOption <system.html#compileOption,string,string>`_ for enum options
  47. ##
  48. runnableExamples:
  49. const nimcache = querySetting(SingleValueSetting.nimcacheDir)
  50. proc querySettingSeq*(setting: MultipleValueSetting): seq[string] {.
  51. compileTime, noSideEffect.} =
  52. ## Can be used to get a multi-string compile-time option.
  53. ##
  54. ## See also:
  55. ## * `compileOption <system.html#compileOption,string>`_ for `on|off` options
  56. ## * `compileOption <system.html#compileOption,string,string>`_ for enum options
  57. runnableExamples:
  58. const nimblePaths = querySettingSeq(MultipleValueSetting.nimblePaths)