-
Notifications
You must be signed in to change notification settings - Fork 742
Expand file tree
/
Copy pathxmake.lua
More file actions
275 lines (236 loc) · 9.99 KB
/
xmake.lua
File metadata and controls
275 lines (236 loc) · 9.99 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
set_xmakever("3.0.0")
-- project
set_project("hikyuu")
add_rules("mode.debug", "mode.release", "mode.coverage")
-- version
set_version("2.7.7", {build = "%Y%m%d%H%M"})
set_warnings("all")
-- set language: C99, c++ standard
set_languages("c++20")
option("mysql")
set_default(true)
set_showmenu(true)
set_category("hikyuu")
set_description("Enable mysql kdata engine.")
if is_plat("windows") then
add_defines("NOMINMAX")
end
option_end()
option("hdf5", {description = "Enable hdf5 kdata engine.", default = true})
option("sqlite", {description = "Enable sqlite kdata engine.", default = true})
option("tdx", {description = "Enable tdx kdata engine.", default = true})
option("sql_trace", {description = "trace print sql", default = false})
-- 注意:stacktrace 在 windows 下会严重影响性能
option("stacktrace", {description = "Enable check/assert with stack trace info.", default = false})
option("spend_time", {description = "Enable spend time.", default = true})
option("feedback", {description = "Enable send feedback.", default = true})
option("low_precision", {description = "Enable low precision.", default = false})
option("log_level", {description = "set log level.", default = 2, values = {1, 2, 3, 4, 5, 6}})
option("async_log", {description = "Use async log.", default = false})
option("leak_check", {description = "Enable leak check for test", default = false})
-- openmp 默认关闭,omp容易在数据不是全部在内存中时容易CPU占满空等,建议调测时使用
option("omp", {description = "Enable openmp support.", default = false})
-- 不再直接包含 arrow, 此处保留仅作编译兼容,实际不再使用
option("arrow", {description = "Enable arrow support.(Obsolete, kept only for compatibility)", default = false})
-- 使用 serialize 时,建议使用静态库方式编译,boost serializasion 对 dll 的方式支持不好
-- windows下如果使用 serialize 且希望使用动态库,需要设置 runtimes 参数为 "MD"
-- "MT" 方式下,serialize 会挂
option("serialize", {description = "Enable support serialize object and pickle in python", default = true})
-- option("http_client", {description = "use http client", default = true})
option("http_client_ssl", {description = "enable https support for http client", default = false})
option("http_client_zip", {description = "enable http support gzip", default = false})
-- option("node", {description = "enable node reqrep server/client", default = true})
option("ta_lib")
add_deps("low_precision")
set_default(true)
set_showmenu(true)
set_category("hikyuu")
set_description("Enable ta-lib support.")
-- low_precision 时,需禁用,ta-lib不支持输出为 float
after_check(function (option)
if option:dep("low_precision"):enabled() then
cprint('${red}[warning] "low_precision" is enabled, ta-lib will be disabled')
option:enable(false)
end
end)
option_end()
-- SPDLOG_ACTIVE_LEVEL 需要单独加
local log_level = get_config("log_level")
if log_level == nil then
log_level = 2
else
log_level = log_level + 0
end
add_defines("SPDLOG_ACTIVE_LEVEL=" .. log_level)
if is_mode("debug") then
set_configvar("HKU_DEBUG_MODE", 1)
else
set_configvar("HKU_DEBUG_MODE", 0)
end
set_configvar("CHECK_ACCESS_BOUND", 1)
set_configvar("SUPPORT_SERIALIZATION", get_config("serialize") and 1 or 0)
set_configvar("SUPPORT_TEXT_ARCHIVE", 1)
set_configvar("SUPPORT_XML_ARCHIVE", 1)
set_configvar("SUPPORT_BINARY_ARCHIVE", 1)
set_configvar("ENABLE_MSVC_LEAK_DETECT", 0)
set_configvar("HKU_ENABLE_LEAK_DETECT", get_config("leak_check") and 1 or 0)
set_configvar("HKU_ENABLE_SEND_FEEDBACK", get_config("feedback") and 1 or 0)
set_configvar("HKU_ENABLE_HDF5_KDATA", get_config("hdf5") and 1 or 0)
set_configvar("HKU_ENABLE_MYSQL", get_config("mysql") and 1 or 0)
set_configvar("HKU_ENABLE_MYSQL_KDATA", get_config("mysql") and 1 or 0)
set_configvar("HKU_ENABLE_SQLITE", (get_config("sqlite") or get_config("hdf5")) and 1 or 0)
set_configvar("HKU_ENABLE_SQLITE_KDATA", get_config("sqlite") and 1 or 0)
set_configvar("HKU_ENABLE_TDX_KDATA", get_config("tdx") and 1 or 0)
set_configvar("HKU_USE_LOW_PRECISION", get_config("low_precision") and 1 or 0)
set_configvar("HKU_ENABLE_TA_LIB", get_config("ta_lib") and 1 or 0)
set_configvar("HKU_ENABLE_MIMALLOC", is_plat("windows", "linux", "cross") and 1 or 0)
set_configvar("HKU_SUPPORT_DATETIME", 1)
set_configvar("HKU_ENABLE_SQLCIPHER", 0)
set_configvar("HKU_SQL_TRACE", get_config("sql_trace"))
set_configvar("HKU_ENABLE_INI_PARSER", 1)
set_configvar("HKU_ENABLE_STACK_TRACE", get_config("stacktrace") and 1 or 0)
set_configvar("HKU_CLOSE_SPEND_TIME", get_config("spend_time") and 0 or 1)
set_configvar("HKU_USE_SPDLOG_ASYNC_LOGGER", get_config("async_log") and 1 or 0)
set_configvar("HKU_LOG_ACTIVE_LEVEL", log_level)
set_configvar("HKU_ENABLE_HTTP_CLIENT", 1)
set_configvar("HKU_ENABLE_HTTP_CLIENT_SSL", get_config("http_client_ssl") and 1 or 0)
set_configvar("HKU_ENABLE_HTTP_CLIENT_ZIP", get_config("http_client_zip") and 1 or 0)
set_configvar("HKU_ENABLE_NODE", 1)
local hdf5_version = "1.12.2"
if is_plat("windows") then
hdf5_version = "1.13.3"
end
local flatbuffers_version = "25.2.10"
local mysql_version = "8.0.31"
if is_plat("windows") or (is_plat("linux", "cross") and is_arch("aarch64", "arm64.*")) then
mysql_version = "8.0.21"
elseif is_plat("macosx") then
mysql_version = "8.0.40"
end
add_repositories("hikyuu-repo https://github.com/fasiondog/hikyuu_extern_libs.git")
-- add_repositories("hikyuu-repo https://gitee.com/fasiondog/hikyuu_extern_libs.git")
if get_config("hdf5") then
add_requires("hdf5 " .. hdf5_version, { system = false })
end
if get_config("mysql") then
add_requires("mysql " .. mysql_version, { system = false })
end
local boost_config
if is_plat("windows") then
boost_config = {
system = false,
debug = is_mode("debug"),
configs = {
shared = true,
runtimes = get_config("runtimes"),
multi = true,
date_time = true,
filesystem = false,
serialization = get_config("serialize"),
system = true,
python = false,
asio = true,
cmake = false,
}}
else
boost_config = {
system = false,
configs = {
shared = true, -- is_plat("windows"),
runtimes = get_config("runtimes"),
multi = true,
date_time = true,
filesystem = false,
serialization = true, --get_config("serialize"),
system = true,
python = false,
-- 以下为兼容 arrow 等其他组件
thread = true, -- parquet need
chrono = true, -- parquet need
charconv = true, -- parquet need
atomic = true,
container = true,
math = true,
locale = true,
icu = true,
regex = true,
random = true,
thread = true,
asio = true,
cmake = true,
}}
end
add_requires("boost", boost_config)
add_requires("fmt", {system = false, configs = {header_only = true}})
add_requires("spdlog", {system = false, configs = {header_only = true, fmt_external = true}})
add_requireconfs("spdlog.fmt", {override = true, system = false, configs = {header_only = true}})
add_requires("sqlite3", {system = false, configs = {shared = true, safe_mode="2", cxflags = "-fPIC"}})
add_requires("flatbuffers v" .. flatbuffers_version, {system = false, configs = {runtimes = get_config("runtimes")}})
add_requires("nng", {system = false, configs = {NNG_ENABLE_TLS = has_config("http_client_ssl"), cxflags = "-fPIC"}})
add_requires("nlohmann_json", {system = false})
add_requires("eigen", {system = false})
add_requires("xxhash", {system = false})
add_requires("utf8proc 2.11.0", {system = false})
if is_plat("windows", "linux", "cross") then
add_requires("mimalloc", {system = false, configs ={shared = true}})
end
if has_config("omp") then
add_requires("openmp", {system = false})
if is_plat("macosx") then
add_requires("libomp", {system = false})
end
end
if has_config("http_client_zip") then
add_requires("gzip-hpp", {system = false})
end
if has_config("ta_lib") then
add_requires("ta-lib", {system = false})
end
add_defines("SPDLOG_DISABLE_DEFAULT_LOGGER") -- 禁用 spdlog 默认ogger
set_objectdir("$(builddir)/$(mode)/$(plat)/$(arch)/.objs")
set_targetdir("$(builddir)/$(mode)/$(plat)/$(arch)/lib")
-- on windows dll, must use runtimes MD
if is_plat("windows") and get_config("kind") == "shared" then
set_config("runtimes", "MD")
set_runtimes("MD")
end
-- is release now
if is_mode("release") then
if is_plat("windows") then
-- Unix-like systems hidden symbols will cause the link dynamic libraries to failed!
set_symbols("hidden")
end
end
-- for the windows platform (msvc)
if is_plat("windows") then
-- add some defines only for windows
add_defines("NOCRYPT", "NOGDI")
add_cxflags("-EHsc", "/Zc:__cplusplus", "/utf-8")
add_cxflags("-wd4819") -- template dll export warning
add_defines("WIN32_LEAN_AND_MEAN")
if is_mode("debug") then
add_cxflags("-Gs", "-RTC1", "/bigobj")
end
end
if is_plat("linux", "cross", "macosx") then
-- disable some compiler errors
add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
add_cxflags("-ftemplate-depth=1023", "-pthread")
add_shflags("-pthread")
add_ldflags("-pthread")
end
if is_plat("macosx") then
add_cxflags("-Wno-deprecated-declarations")
end
-- if not is_plat("cross") and (os.host() == "linux" and is_arch("x86_64", "x64")) then
-- -- fedora或者ubuntu,并且不是交叉编译
-- add_vectorexts("sse", "sse2", "ssse3", "avx", "avx2")
-- -- add_defines("HKU_ENABLE_SSE2", "HKU_ENABLE_SSE3", "HKU_ENABLE_SSE41", "HKU_ENABLE_AVX", "HKU_ENABLE_AVX2")
-- end
includes("./copy_dependents.lua")
includes("./hikyuu_cpp/hikyuu")
includes("./hikyuu_cpp/demo")
if not is_plat("cross") then
includes("./hikyuu_pywrap")
includes("./hikyuu_cpp/unit_test")
end