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

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