2023-09-03 18:20:20 +08:00
|
|
|
|
set_xmakever("2.8.2")
|
2023-10-01 22:16:04 +08:00
|
|
|
|
|
2024-08-02 18:15:43 +08:00
|
|
|
|
-- project
|
|
|
|
|
set_project("hikyuu")
|
|
|
|
|
|
|
|
|
|
add_rules("mode.debug", "mode.release")
|
|
|
|
|
|
|
|
|
|
-- version
|
2024-08-27 22:44:39 +08:00
|
|
|
|
set_version("2.1.3", {build = "%Y%m%d%H%M"})
|
2024-08-02 18:15:43 +08:00
|
|
|
|
|
|
|
|
|
set_warnings("all")
|
|
|
|
|
|
|
|
|
|
-- set language: C99, c++ standard
|
|
|
|
|
set_languages("cxx17", "c99")
|
|
|
|
|
|
2023-10-02 03:41:45 +08:00
|
|
|
|
|
|
|
|
|
option("mysql")
|
|
|
|
|
set_default(true)
|
|
|
|
|
set_showmenu(true)
|
|
|
|
|
set_category("hikyuu")
|
|
|
|
|
set_description("Enable mysql kdata engine.")
|
|
|
|
|
if is_plat("macosx") then
|
|
|
|
|
if os.exists("/usr/local/opt/mysql-client/lib") then
|
|
|
|
|
add_includedirs("/usr/local/opt/mysql-client/include/mysql")
|
|
|
|
|
add_includedirs("/usr/local/opt/mysql-client/include")
|
|
|
|
|
add_linkdirs("/usr/local/opt/mysql-client/lib")
|
|
|
|
|
add_rpathdirs("/usr/local/opt/mysql-client/lib")
|
|
|
|
|
end
|
|
|
|
|
if os.exists("/usr/local/mysql/lib") then
|
|
|
|
|
add_linkdirs("/usr/local/mysql/lib")
|
|
|
|
|
add_rpathdirs("/usr/local/mysql/lib")
|
|
|
|
|
end
|
|
|
|
|
if not os.exists("/usr/local/include/mysql") then
|
|
|
|
|
if os.exists("/usr/local/mysql/include") then
|
|
|
|
|
os.run("ln -s /usr/local/mysql/include /usr/local/include/mysql")
|
|
|
|
|
else
|
|
|
|
|
print("Not Found MySQL include dir!")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
add_links("mysqlclient")
|
|
|
|
|
elseif is_plat("windows") then
|
|
|
|
|
add_defines("NOMINMAX")
|
|
|
|
|
end
|
|
|
|
|
option_end()
|
|
|
|
|
|
2024-08-02 18:15:43 +08:00
|
|
|
|
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})
|
2023-10-02 03:41:45 +08:00
|
|
|
|
|
2024-03-25 00:55:35 +08:00
|
|
|
|
-- 注意:stacktrace 在 windows 下会严重影响性能
|
2024-08-02 18:15:43 +08:00
|
|
|
|
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})
|
2024-03-11 19:40:40 +08:00
|
|
|
|
|
2024-08-08 16:23:27 +08:00
|
|
|
|
-- 使用 serialize 时,建议使用静态库方式编译,boost serializasion 对 dll 的方式支持不好
|
|
|
|
|
-- windows下如果使用 serialize 且希望使用动态库,需要设置 runtimes 参数为 "MD"
|
|
|
|
|
-- "MT" 方式下,serialize 会挂
|
|
|
|
|
option("serialize", {description = "Enable support serialize object and pickle in python", default = true})
|
2024-03-11 19:40:40 +08:00
|
|
|
|
|
2024-05-30 15:03:51 +08:00
|
|
|
|
if get_config("leak_check") then
|
2024-06-12 03:03:25 +08:00
|
|
|
|
-- 需要 export LD_PRELOAD=libasan.so
|
2024-05-30 15:03:51 +08:00
|
|
|
|
set_policy("build.sanitizer.address", true)
|
|
|
|
|
set_policy("build.sanitizer.leak", true)
|
|
|
|
|
-- set_policy("build.sanitizer.memory", true)
|
|
|
|
|
-- set_policy("build.sanitizer.thread", true)
|
|
|
|
|
end
|
|
|
|
|
|
2024-08-02 18:15:43 +08:00
|
|
|
|
-- SPDLOG_ACTIVE_LEVEL 需要单独加
|
|
|
|
|
local log_level = get_config("log_level")
|
|
|
|
|
if log_level == nil then
|
|
|
|
|
log_level = 2
|
2024-03-11 19:40:40 +08:00
|
|
|
|
end
|
2024-08-02 18:15:43 +08:00
|
|
|
|
add_defines("SPDLOG_ACTIVE_LEVEL=" .. log_level)
|
2024-03-11 19:40:40 +08:00
|
|
|
|
|
2024-03-24 14:50:14 +08:00
|
|
|
|
if is_mode("debug") then
|
|
|
|
|
set_configvar("HKU_DEBUG_MODE", 1)
|
|
|
|
|
else
|
|
|
|
|
set_configvar("HKU_DEBUG_MODE", 0)
|
|
|
|
|
end
|
2019-06-16 20:49:20 +08:00
|
|
|
|
set_configvar("CHECK_ACCESS_BOUND", 1)
|
2024-08-08 16:23:27 +08:00
|
|
|
|
set_configvar("SUPPORT_SERIALIZATION", get_config("serialize") and 1 or 0)
|
2019-06-16 20:49:20 +08:00
|
|
|
|
set_configvar("SUPPORT_TEXT_ARCHIVE", 0)
|
|
|
|
|
set_configvar("SUPPORT_XML_ARCHIVE", 1)
|
|
|
|
|
set_configvar("SUPPORT_BINARY_ARCHIVE", 1)
|
2023-10-01 22:32:29 +08:00
|
|
|
|
set_configvar("ENABLE_MSVC_LEAK_DETECT", 0)
|
2024-06-01 14:41:32 +08:00
|
|
|
|
set_configvar("HKU_ENABLE_LEAK_DETECT", get_config("leak_check") and 1 or 0)
|
2023-10-03 01:34:03 +08:00
|
|
|
|
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)
|
2024-07-17 14:19:25 +08:00
|
|
|
|
set_configvar("HKU_ENABLE_MYSQL", get_config("mysql") and 1 or 0)
|
2023-10-03 01:34:03 +08:00
|
|
|
|
set_configvar("HKU_ENABLE_MYSQL_KDATA", get_config("mysql") and 1 or 0)
|
2024-07-17 14:19:25 +08:00
|
|
|
|
set_configvar("HKU_ENABLE_SQLITE", (get_config("sqlite") or get_config("hdf5")) and 1 or 0)
|
2023-10-03 01:34:03 +08:00
|
|
|
|
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)
|
2018-08-19 16:51:10 +08:00
|
|
|
|
|
2024-02-27 16:38:12 +08:00
|
|
|
|
set_configvar("HKU_USE_LOW_PRECISION", get_config("low_precision") and 1 or 0)
|
|
|
|
|
|
2024-07-17 14:19:25 +08:00
|
|
|
|
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)
|
2024-07-17 11:08:04 +08:00
|
|
|
|
set_configvar("HKU_CLOSE_SPEND_TIME", get_config("spend_time") and 0 or 1)
|
2024-08-02 18:15:43 +08:00
|
|
|
|
set_configvar("HKU_USE_SPDLOG_ASYNC_LOGGER", get_config("async_log") and 1 or 0)
|
|
|
|
|
set_configvar("HKU_LOG_ACTIVE_LEVEL", get_config("log_level"))
|
|
|
|
|
set_configvar("HKU_ENABLE_MO", 0)
|
|
|
|
|
set_configvar("HKU_ENABLE_HTTP_CLIENT", 1)
|
|
|
|
|
set_configvar("HKU_ENABLE_HTTP_CLIENT_SSL", 0)
|
|
|
|
|
set_configvar("HKU_ENABLE_HTTP_CLIENT_ZIP", 0)
|
2024-08-27 00:37:36 +08:00
|
|
|
|
set_configvar("HKU_ENABLE_NODE", 1)
|
2024-01-24 13:41:56 +08:00
|
|
|
|
|
2024-06-11 09:50:55 +08:00
|
|
|
|
local boost_version = "1.85.0"
|
2024-08-09 02:34:52 +08:00
|
|
|
|
local hdf5_version = "1.12.2"
|
2024-01-11 19:53:31 +08:00
|
|
|
|
local fmt_version = "10.2.1"
|
2024-06-10 10:06:12 +08:00
|
|
|
|
local flatbuffers_version = "24.3.25"
|
2024-06-11 10:22:08 +08:00
|
|
|
|
local nng_version = "1.8.0"
|
2024-06-11 09:50:55 +08:00
|
|
|
|
local sqlite_version = "3.46.0+0"
|
2023-10-02 03:41:45 +08:00
|
|
|
|
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"
|
|
|
|
|
end
|
2022-11-09 01:11:07 +08:00
|
|
|
|
|
2024-05-27 17:25:21 +08:00
|
|
|
|
add_repositories("hikyuu-repo https://github.com/fasiondog/hikyuu_extern_libs.git")
|
|
|
|
|
-- add_repositories("hikyuu-repo https://gitee.com/fasiondog/hikyuu_extern_libs.git")
|
2022-01-06 00:41:15 +08:00
|
|
|
|
if is_plat("windows") then
|
2023-10-03 01:34:03 +08:00
|
|
|
|
if get_config("hdf5") then
|
|
|
|
|
if is_mode("release") then
|
|
|
|
|
add_requires("hdf5 " .. hdf5_version)
|
|
|
|
|
else
|
2024-06-11 00:03:38 +08:00
|
|
|
|
add_requires("hdf5_d " .. hdf5_version)
|
2023-10-03 01:34:03 +08:00
|
|
|
|
end
|
2023-10-02 03:41:45 +08:00
|
|
|
|
end
|
|
|
|
|
if get_config("mysql") then
|
|
|
|
|
add_requires("mysql " .. mysql_version)
|
|
|
|
|
end
|
|
|
|
|
|
2023-03-25 23:59:56 +08:00
|
|
|
|
elseif is_plat("linux", "cross") then
|
2023-10-03 01:34:03 +08:00
|
|
|
|
if get_config("hdf5") then
|
|
|
|
|
add_requires("hdf5 " .. hdf5_version, { system = false })
|
|
|
|
|
end
|
2023-10-02 03:41:45 +08:00
|
|
|
|
if get_config("mysql") then
|
|
|
|
|
add_requires("mysql " .. mysql_version, { system = false })
|
|
|
|
|
end
|
|
|
|
|
|
2022-11-15 00:42:08 +08:00
|
|
|
|
elseif is_plat("macosx") then
|
2023-10-03 01:34:03 +08:00
|
|
|
|
if get_config("hdf5") then
|
2024-08-02 18:15:43 +08:00
|
|
|
|
add_requires("brew::hdf5", {alias = "hdf5"})
|
2023-10-03 01:34:03 +08:00
|
|
|
|
end
|
2023-10-02 03:41:45 +08:00
|
|
|
|
if get_config("mysql") then
|
2024-08-02 18:15:43 +08:00
|
|
|
|
add_requires("brew::mysql-client", {alias = "mysql"})
|
2023-10-02 03:41:45 +08:00
|
|
|
|
end
|
2022-01-06 00:41:15 +08:00
|
|
|
|
end
|
2023-03-27 02:37:01 +08:00
|
|
|
|
|
2024-01-11 19:53:31 +08:00
|
|
|
|
add_requires("boost " .. boost_version, {
|
2023-09-16 15:12:42 +08:00
|
|
|
|
debug = is_mode("debug"),
|
2023-08-08 11:30:10 +08:00
|
|
|
|
configs = {
|
2024-01-29 17:00:29 +08:00
|
|
|
|
shared = is_plat("windows"),
|
2024-07-12 12:21:08 +08:00
|
|
|
|
runtimes = get_config("runtimes"),
|
2024-01-24 11:55:32 +08:00
|
|
|
|
multi = true,
|
2023-10-18 19:14:29 +08:00
|
|
|
|
date_time = true,
|
2024-06-12 18:13:35 +08:00
|
|
|
|
filesystem = false,
|
2023-08-08 11:30:10 +08:00
|
|
|
|
serialization = true,
|
2023-08-13 01:59:00 +08:00
|
|
|
|
system = false,
|
2024-01-09 16:58:03 +08:00
|
|
|
|
python = false,
|
2023-08-08 11:30:10 +08:00
|
|
|
|
},
|
2023-06-14 16:37:10 +08:00
|
|
|
|
})
|
2023-12-26 18:25:50 +08:00
|
|
|
|
|
2024-08-08 18:35:56 +08:00
|
|
|
|
add_requires("fmt", {configs = {header_only = true}})
|
|
|
|
|
add_requires("spdlog", {configs = {header_only = true, fmt_external = true}})
|
|
|
|
|
add_requireconfs("spdlog.fmt", {override = true, configs = {header_only = true}})
|
2024-08-11 14:55:32 +08:00
|
|
|
|
add_requires("sqlite3 " .. sqlite_version, {configs = {shared = true, safe_mode="2", cxflags = "-fPIC"}})
|
2024-07-12 12:21:08 +08:00
|
|
|
|
add_requires("flatbuffers v" .. flatbuffers_version, {system = false, configs= {runtimes = get_config("runtimes")}})
|
2024-08-08 18:35:56 +08:00
|
|
|
|
add_requires("nng " .. nng_version, {configs = {cxflags = "-fPIC"}})
|
|
|
|
|
add_requires("nlohmann_json")
|
2024-02-24 23:34:50 +08:00
|
|
|
|
|
2024-03-11 21:15:58 +08:00
|
|
|
|
add_defines("SPDLOG_DISABLE_DEFAULT_LOGGER") -- 禁用 spdlog 默认ogger
|
2019-08-03 21:53:24 +08:00
|
|
|
|
|
2018-08-19 16:51:10 +08:00
|
|
|
|
set_objectdir("$(buildir)/$(mode)/$(plat)/$(arch)/.objs")
|
|
|
|
|
set_targetdir("$(buildir)/$(mode)/$(plat)/$(arch)/lib")
|
|
|
|
|
|
2024-08-09 02:28:14 +08:00
|
|
|
|
-- on windows dll, must use runtimes MD
|
2024-01-28 23:38:03 +08:00
|
|
|
|
if is_plat("windows") and get_config("kind") == "shared" then
|
2024-08-09 02:28:14 +08:00
|
|
|
|
set_config("runtimes", "MD")
|
|
|
|
|
set_runtimes("MD")
|
2024-01-28 23:38:03 +08:00
|
|
|
|
end
|
2018-08-19 16:51:10 +08:00
|
|
|
|
|
|
|
|
|
-- is release now
|
|
|
|
|
if is_mode("release") then
|
2023-08-08 11:30:10 +08:00
|
|
|
|
if is_plat("windows") then
|
|
|
|
|
-- Unix-like systems hidden symbols will cause the link dynamic libraries to failed!
|
|
|
|
|
set_symbols("hidden")
|
|
|
|
|
end
|
2018-08-19 16:51:10 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- for the windows platform (msvc)
|
2023-06-14 16:37:10 +08:00
|
|
|
|
if is_plat("windows") then
|
2023-08-08 11:30:10 +08:00
|
|
|
|
-- 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")
|
2024-01-24 13:41:56 +08:00
|
|
|
|
if is_mode("debug") then
|
2023-08-08 11:30:10 +08:00
|
|
|
|
add_cxflags("-Gs", "-RTC1", "/bigobj")
|
|
|
|
|
end
|
2023-06-14 16:37:10 +08:00
|
|
|
|
end
|
2019-09-22 23:02:08 +08:00
|
|
|
|
|
2024-08-21 15:08:22 +08:00
|
|
|
|
if is_plat("linux", "cross", "macosx") then
|
2023-08-08 11:30:10 +08:00
|
|
|
|
-- 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")
|
2018-08-19 16:51:10 +08:00
|
|
|
|
end
|
2024-02-23 22:50:01 +08:00
|
|
|
|
|
2024-02-25 14:10:55 +08:00
|
|
|
|
-- 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
|
2018-08-19 16:51:10 +08:00
|
|
|
|
|
2024-07-11 12:41:23 +08:00
|
|
|
|
includes("./copy_dependents.lua")
|
2023-09-03 18:20:20 +08:00
|
|
|
|
includes("./hikyuu_cpp/hikyuu")
|
|
|
|
|
includes("./hikyuu_pywrap")
|
|
|
|
|
includes("./hikyuu_cpp/unit_test")
|
2024-01-30 10:54:34 +08:00
|
|
|
|
includes("./hikyuu_cpp/demo")
|