You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nim.nim 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from macros import error
  2. type Compiler = enum gcc = "gcc", clang = "clang"
  3. proc setCompiler(s: string, compiler = gcc, cpp = false) =
  4. let c = findExe s
  5. let cpp = (if cpp: ".cpp" else: "")
  6. if c.len == 0:
  7. error s & " binary wasn't found in $PATH."
  8. switch $compiler & cpp & ".exe", c
  9. switch $compiler & cpp & ".linkerexe", c
  10. when defined(wasm):
  11. let linkerOptions = "-nostdlib -Wl,--no-entry,--allow-undefined,--gc-sections,--strip-all"
  12. switch "o", projectName() & ".wasm"
  13. switch "cpu", "i386"
  14. switch "cc", "clang"
  15. switch "d", "release"
  16. switch "opt", "size"
  17. switch "stackTrace", "off"
  18. switch "nomain"
  19. switch "d", "nimNoLibc"
  20. switch "d", "noSignalHandler"
  21. switch "passC", "--target=wasm32-unknown-unknown-wasm"
  22. switch "passC", "-mexception-handling"
  23. switch "passC", "-nostdlib"
  24. switch "passL", "--target=wasm32-unknown-unknown-wasm"
  25. switch "clang.options.linker", linkerOptions
  26. switch "clang.cpp.options.linker", linkerOptions
  27. when defined(musl):
  28. setCompiler "x86_64-linux-musl-gcc"
  29. switch "passL", "-static"
  30. when defined(release) or defined(danger):
  31. switch "excessiveStackTrace", "off"
  32. switch "passC", "-flto"
  33. switch "passL", "-s"
  34. when defined(release):
  35. switch "nimcache", "/tmp/nim/" & projectName() & "_r"
  36. when defined(danger):
  37. switch "nimcache", "/tmp/nim/" & projectName() & "_d"
  38. else:
  39. switch "nimcache", "/tmp/nim/" & projectName()
  40. when defined(hotcodereloading):
  41. switch "nimcache", "nimcache"
  42. switch "styleCheck", "hint"