forked from jcosborn/qex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.nims.in
128 lines (115 loc) · 2.75 KB
/
config.nims.in
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# -*- mode: nim -*-
import strUtils
import osPaths
echo "Starting config file: ", thisDir(), "/config.nims"
var envs = newSeq[string](0)
when not declared(qexdir):
var qexdir = "@@QEXDIR"
var qmpdir = "@@QMPDIR"
var qiodir = "@@QIODIR"
var qudadir = "@@QUDADIR"
var cudadir = "@@CUDADIR"
var ccType = "@@CC_TYPE"
var cc = "@@CC"
var cflagsAlways = "@@CFLAGS_ALWAYS"
var cflagsDebug = "@@CFLAGS_DEBUG"
var cflagsSpeed = "@@CFLAGS_SPEED"
var ompflags = "@@OMPFLAGS"
var ld = "@@LD"
var ldflags = "@@LDFLAGS"
var nimcache = thisDir() / "nimcache"
when not declared(verbosity):
var verbosity = -1
if verbosity<0: verbosity = @@VERBOSITY
var simd = "@@SIMD"
var vlen = "@@VLEN"
@@ENVS
#[
DBG += "--hint[XDeclaredButNotUsed]:off"
DBG += "--implicitStatic:on"
#DBG += "--listCmd"
#DBG += "--parallelBuild:4"
#DBG += "--embedsrc"
#DBG += "--genMapping"
#DBG += "--gc:refc"
#DBG += "--gc:markAndSweep"
#refc|v2|markAndSweep|boehm|go|none
]#
var defargs = newSeq[string](0)
# "set(key, val)" sets "key" to "val"
template set(key: string, val: untyped) =
var v = astToStr(val)
when compiles(val.type):
when val.type is string:
v = val
when val.type is int:
v = $val
echo "setting: ", key, " <- \"", v, "\""
when getCommand()=="e":
if v=="":
defargs.add "--" & key
else:
defargs.add "--" & key & ":\"" & v & "\""
else:
if key[0..6]!="warning": # warnings don't seem to work here
switch(key, v)
# "key ~ val" sets "key" to "val"
template `~`(key,val: untyped) =
set(astToStr(key), val)
# "key ! val" sets "ccType.key" to "val"
template `!`(key,val: untyped) =
set(ccType & "." & astToStr(key), val)
path ~ qexdir/"src"
cc ~ ccType
exe ! cc
linkerexe ! ld
options.always ! cflagsAlways
options.debug ! cflagsDebug
options.speed ! cflagsSpeed
options.linker ! ldflags
putenv ~ ("OMPFLAG=" & ompflags)
putenv ~ ("QMPDIR=" & qmpdir)
putenv ~ ("QIODIR=" & qiodir)
putenv ~ ("QUDADIR=" & qudadir)
putenv ~ ("CUDADIR=" & cudadir)
threads ~ on
tlsEmulation ~ off
verbosity ~ verbosity
nimcache ~ nimcache
warning[SmallLshouldNotBeUsed] ~ off
when not declared(debug):
var debug = false
for i in 1..paramCount():
if paramStr(i)=="-d:debug": debug = true
if not debug:
obj_checks ~ off
field_checks ~ off
range_checks ~ off
bound_checks ~ off
overflow_checks ~ off
assertions ~ off
stacktrace ~ off
linetrace ~ off
debugger ~ off
line_dir ~ off
dead_code_elim ~ on
opt ~ speed
else:
echo "debug build"
let ss = simd.split(',')
if ss.len>0:
for s in items(ss):
case s
of "QPX":
d ~ QPX
of "SSE":
d ~ SSE
of "AVX":
d ~ AVX
of "AVX512":
d ~ AVX512
else: discard
putenv ~ ("VLEN=" & vlen)
for e in envs:
putenv ~ e
echo "Finished config file: ", thisDir(), "/config.nims"