-
Notifications
You must be signed in to change notification settings - Fork 19
/
AMBuildScript
160 lines (142 loc) · 4 KB
/
AMBuildScript
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
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
import os
import sys
class KEConfig(object):
def __init__(self):
pass
def configure(self):
cxx = builder.DetectCxx()
builder.cxx = cxx
builder.dist_folder = builder.AddFolder('dist')
if cxx.like('gcc'):
if cxx.target.platform != 'windows':
if cxx.version >= 'gcc-8.0' or cxx.version >= 'clang-5.0':
cxx.cxxflags += ['-std=c++17']
else:
cxx.cxxflags += ['-std=c++14']
cxx.defines += [
'stricmp=strcasecmp',
'_stricmp=strcasecmp',
'_snprintf=snprintf',
'_vsnprintf=vsnprintf',
]
cxx.linkflags += ['-lpthread']
if cxx.target.platform != 'mac':
cxx.linkflags += ['-lrt']
else:
cxx.cxxflags += [
'-std=c++14',
'-fms-compatibility-version=19',
]
cxx.cflags += [
'-pipe',
'-Wall',
'-Werror',
]
cxx.cflags += ['-fvisibility=hidden']
cxx.cxxflags += ['-fvisibility-inlines-hidden']
# -Wunused-function breaks test_flags.cpp
cxx.cxxflags += ['-Wno-unused-function']
if cxx.like('clang'):
cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch']
elif cxx.like('gcc'):
cxx.cxxflags += ['-Wformat-truncation=0']
cxx.cxxflags += [
'-fno-exceptions',
'-fno-threadsafe-statics',
]
cxx.cflags += ['-mfpmath=sse']
elif cxx.like('msvc'):
if builder.options.debug == '1':
cxx.cflags += ['/MTd']
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
else:
cxx.cflags += ['/MT']
cxx.defines += [
'_CRT_SECURE_NO_DEPRECATE',
'_CRT_SECURE_NO_WARNINGS',
'_CRT_NONSTDC_NO_DEPRECATE',
'_ITERATOR_DEBUG_LEVEL=0',
]
cxx.cflags += [
'/W3',
]
cxx.cxxflags += [
'/EHsc',
'/GR-',
'/TP',
]
cxx.linkflags += [
'/MACHINE:X86',
'kernel32.lib',
'user32.lib',
'gdi32.lib',
'winspool.lib',
'comdlg32.lib',
'advapi32.lib',
'shell32.lib',
'ole32.lib',
'oleaut32.lib',
'uuid.lib',
'odbc32.lib',
'odbccp32.lib',
]
# Optimization
if builder.options.opt == '1':
cxx.defines += ['NDEBUG']
if cxx.like('gcc'):
cxx.cflags += ['-O3']
elif cxx.like('msvc'):
cxx.cflags += ['/Ox']
cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
# Debugging
if builder.options.debug == '1':
cxx.defines += ['DEBUG', '_DEBUG']
if cxx.like('msvc'):
cxx.cflags += ['/Od', '/RTC1']
if cxx.version >= 1600:
cxx.cflags += ['/d2Zi+']
# This needs to be after our optimization flags which could otherwise disable it.
if cxx.like('msvc'):
# Don't omit the frame pointer.
cxx.cflags += ['/Oy-']
# Platform-specifics
if cxx.target.platform == 'linux':
cxx.defines += ['_LINUX', 'POSIX']
if cxx.like('gcc'):
cxx.linkflags += ['-static-libgcc']
elif cxx.like('clang'):
cxx.linkflags += ['-lgcc_eh']
elif cxx.target.platform == 'mac':
cxx.defines += ['OSX', '_OSX', 'POSIX']
cxx.cflags += ['-mmacosx-version-min=10.7']
cxx.linkflags += [
'-mmacosx-version-min=10.7',
'-lstdc++',
'-stdlib=libc++',
]
cxx.cxxflags += ['-stdlib=libc++']
elif cxx.target.platform == 'windows':
cxx.defines += ['WIN32', '_WINDOWS']
def Program(self, context, name):
compiler = context.cxx.clone()
binary = compiler.Program(name)
return binary
def StaticLibrary(self, context, name):
compiler = context.cxx.clone()
binary = compiler.StaticLibrary(name)
return binary
KE = KEConfig()
KE.configure()
KE.libamtl = builder.Build('amtl/AMBuilder', {
'Configure': lambda builder, name: KE.StaticLibrary(builder, name),
})
KE.libamtl = KE.libamtl.binary
builder.Build(
[
'tests/AMBuild.tests',
],
{
'KE': KE,
}
)