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 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. from macros import error
  2. type Compiler = enum gcc = "gcc", clang = "clang"
  3. var cross = block:
  4. const cross {.booldefine.} = false
  5. cross
  6. proc setCompiler(s: string, compiler = gcc, cpp = false) {.used.} =
  7. let c = findExe s
  8. let cpp = (if cpp: ".cpp" else: "")
  9. if c.len == 0:
  10. error s & " binary wasn't found in $PATH."
  11. switch $compiler & cpp & ".exe", c
  12. switch $compiler & cpp & ".linkerexe", c
  13. if defined(musl):
  14. setCompiler "x86_64-linux-musl-gcc"
  15. elif defined(x86):
  16. cross = true
  17. setCompiler "i686-pc-linux-gnu-gcc"
  18. switch "cpu", "i386"
  19. switch "passL", "--sysroot=/usr/i686-pc-linux-gnu/"
  20. elif defined(arm):
  21. cross = true
  22. switch "cpu", "arm"
  23. switch "passL", "--sysroot=/usr/arm-linux-gnueabihf/"
  24. elif defined(wasm):
  25. cross = true
  26. let linkerOptions = "-nostdlib -Wl,--no-entry,--allow-undefined,--gc-sections,--strip-all"
  27. switch "o", projectName() & ".wasm"
  28. switch "cpu", "i386"
  29. switch "cc", "clang"
  30. switch "d", "danger"
  31. switch "opt", "size"
  32. switch "stackTrace", "off"
  33. switch "nomain"
  34. switch "d", "nimNoLibc"
  35. switch "d", "noSignalHandler"
  36. switch "passC", "--target=wasm32-unknown-unknown-wasm"
  37. switch "passC", "-mexception-handling"
  38. switch "passC", "-nostdlib"
  39. switch "passL", "--target=wasm32-unknown-unknown-wasm"
  40. switch "clang.options.linker", linkerOptions
  41. switch "clang.cpp.options.linker", linkerOptions
  42. if defined(release) or defined(danger):
  43. switch "excessiveStackTrace", "off"
  44. if not cross:
  45. switch "passC", "-march=native"
  46. switch "passC", "-floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block"
  47. switch "passC", "-ftree-vectorize"
  48. switch "passC", "-flto"
  49. switch "passL", "-flto"
  50. switch "passL", "-fuse-linker-plugin"
  51. switch "passL", "-s"
  52. if defined(danger):
  53. switch "panics", "on"
  54. if defined(hotcodereloading):
  55. switch "nimcache", "nimcache"
  56. elif defined(danger):
  57. switch "nimcache", "/tmp/nim/" & projectName() & "_d"
  58. elif defined(release):
  59. switch "nimcache", "/tmp/nim/" & projectName() & "_r"
  60. else:
  61. switch "nimcache", "/tmp/nim/" & projectName()
  62. switch "styleCheck", "hint"
  63. switch "hint", "Dependency:on"