-
-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathconfig.nims
More file actions
162 lines (133 loc) · 4.27 KB
/
config.nims
File metadata and controls
162 lines (133 loc) · 4.27 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#=======================================================
# Arturo
# Programming Language + Bytecode VM compiler
# (c) 2019-2026 Yanis Zafirópulos
#
# @file: config.nims
#=======================================================
#=======================================
# Libraries
#=======================================
import os, strutils
#=======================================
# Helpers
#=======================================
proc configMimalloc() =
let
mimallocPath = projectDir() / "extras" / "mimalloc"
mimallocStatic = "mimallocStatic=\"" & (mimallocPath / "src" / "static.c") & '"'
mimallocIncludePath = "mimallocIncludePath=\"" & (mimallocPath / "include") & '"'
--define:useMalloc
switch "define", mimallocStatic
switch "define", mimallocIncludePath
if get("cc") in @["gcc", "clang", "icc", "icl"]:
--passC:"-ftls-model=initial-exec -fno-builtin-malloc"
"stdlib".patchFile("malloc"):
"src"/"extras"/"mimalloc"
proc configPCRE() =
if defined(windows):
--dynlibOverride:pcre64
else:
--dynlibOverride:pcre
proc configWebkit() =
if not (defined(linux) or defined(freebsd)):
return
const webkitVersions = ["4.1", "4.0"]
proc getWebkitVersion(): string =
let testPkg = gorgeEx("which pkg-config")
if testPkg.exitCode != 0:
# pkg-config not found
# probably because we are not on Ubuntu
if defined(freebsd):
return "41"
else:
return "4.1"
for version in webkitVersions:
let ret = gorgeEx("pkg-config --exists webkit2gtk-" & version)
if ret.exitCode == 0:
if version == "4.0" or version == "40":
--define:"LEGACYUNIX"
return version
if defined(freebsd):
return "41"
else:
return "4.1" # fallback if none found
switch "define", "webkitVersion=" & getWebkitVersion()
proc configSSL() =
if not defined(ssl):
return
if defined(windows):
--define:"noOpenSSLHacks"
--define:"sslVersion:("
--dynlibOverride:"ssl-"
--dynlibOverride:"crypto-"
else:
--dynlibOverride:ssl
--dynlibOverride:crypto
proc configPlatform() =
if hostOS == "macosx":
# Headers
--passC:"-I/opt/homebrew/include" # ARM64 Homebrew
--passC:"-I/usr/local/include" # Intel Homebrew
--passC:"-I/opt/local/include" # MacPorts
# Library paths
--passL:"-L/opt/homebrew/lib" # ARM64 Homebrew
--passL:"-L/usr/local/lib" # Intel Homebrew
--passL:"-L/opt/local/lib" # MacPorts
# Runtime search paths
--passL:"-Wl,-rpath,/opt/homebrew/opt/mpfr/lib"
--passL:"-Wl,-rpath,/opt/homebrew/opt/gmp/lib"
--passL:"-Wl,-rpath,/usr/local/opt/mpfr/lib"
--passL:"-Wl,-rpath,/usr/local/opt/gmp/lib"
--passL:"-Wl,-rpath,/opt/local/lib"
--passL:"-Wl,-headerpad_max_install_names"
elif defined(windows):
--passL:"-static-libstdc++ -static-libgcc -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic"
--gcc.linkerexe:"g++"
else:
--passL:"-lm"
--passL:"-pthread"
#=======================================
# Main
#=======================================
proc main() =
#--------------------------
# paths
#--------------------------
--path:src
--cincludes:extras
--nimcache:".cache"
#--------------------------
# compiler flags
#--------------------------
--skipUserCfg:on
--define:danger
--checks:off
--panics:off
--opt:speed
--mm:orc
--threads:off
#--------------------------
# logging
#--------------------------
--hints:on
--colors:off
--verbosity:1
hint "ProcessingStmt":off
hint "XCannotRaiseY":off
hint "ConvFromXtoItselfNotNeeded":off
warning "GcUnsafe":off
warning "CastSizes":off
warning "ProveInit":off
warning "ProveField":off
warning "Uninit":off
warning "BareExcept":off
#--------------------------
# extra configuration
#--------------------------
configMimalloc()
configWebkit()
configPCRE()
configSSL()
configPlatform()
main()