-
Notifications
You must be signed in to change notification settings - Fork 3
/
nim.nim
98 lines (83 loc) · 2.66 KB
/
nim.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from macros import error
import os
type Compiler = enum gcc = "gcc", clang = "clang"
var cross = block:
const cross {.booldefine.} = false
cross
const strip {.booldefine.} = true
proc setCompiler(s: string, compiler = gcc, cpp = false) {.used.} =
let c = findExe s
let cpp = (if cpp: ".cpp" else: "")
if c.len == 0:
error s & " binary wasn't found in $PATH."
switch $compiler & cpp & ".exe", c
switch $compiler & cpp & ".linkerexe", c
if defined(musl):
setCompiler "x86_64-linux-musl-gcc"
elif defined(x86):
cross = true
setCompiler "i686-pc-linux-gnu-gcc"
switch "cpu", "i386"
switch "passL", "--sysroot=/usr/i686-pc-linux-gnu/"
elif defined(arm):
cross = true
switch "cpu", "arm"
switch "passL", "--sysroot=/usr/arm-linux-gnueabihf/"
elif defined(wasm):
cross = true
let linkerOptions = "-nostdlib -Wl,--no-entry,--allow-undefined,--gc-sections,--strip-all"
switch "o", projectName() & ".wasm"
switch "cpu", "i386"
switch "cc", "clang"
switch "d", "danger"
switch "opt", "size"
switch "stackTrace", "off"
switch "nomain"
switch "d", "nimNoLibc"
switch "d", "noSignalHandler"
switch "passC", "--target=wasm32-unknown-unknown-wasm"
switch "passC", "-mexception-handling"
switch "passC", "-nostdlib"
switch "passL", "--target=wasm32-unknown-unknown-wasm"
switch "clang.options.linker", linkerOptions
switch "clang.cpp.options.linker", linkerOptions
if defined(release) or defined(danger):
if not cross:
switch "passC", "-march=native"
switch "passC", "-floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block"
switch "passC", "-ftree-vectorize"
switch "passC", "-flto=auto"
switch "passL", "-flto=auto"
switch "passL", "-fuse-linker-plugin"
if strip:
switch "passL", "-s"
else:
switch "d", "stacktraceHyperlinks"
if defined(libbacktrace):
switch "stacktrace", "off"
switch "d", "nimStackTraceOverride"
switch "import", "libbacktrace"
if defined(danger):
switch "panics", "on"
if defined(hotcodereloading):
switch "nimcache", "nimcache"
elif defined(danger):
switch "nimcache", getTempDir() / "nim" / projectName() & "_d"
elif defined(release):
switch "nimcache", getTempDir() / "nim" / projectName() & "_r"
else:
switch "nimcache", getTempDir() / "nim" / projectName()
switch "spellsuggest"
switch "hyperlink"
switch "styleCheck", "usages"
switch "hint", "Dependency:on"
switch "hint", "MsgOrigin:off"
switch "processing", "filenames"
switch "passC", "-fdiagnostics-urls=always"
switch "passL", "-fdiagnostics-urls=always"
# Way of Nim
# --experimental:strictEffects
--experimental:unicodeOperators
--define:nimPreviewDotLikeOps
--define:nimPreviewFloatRoundtrip
--define:nimStrictDelete