hikyuu2/xmake.lua

233 lines
7.3 KiB
Lua
Raw Normal View History

2023-09-03 18:20:20 +08:00
set_xmakever("2.8.2")
2023-10-01 22:16:04 +08:00
2023-10-02 03:41:45 +08:00
option("hdf5")
set_default(true)
set_showmenu(true)
set_category("hikyuu")
set_description("Enable hdf5 kdata engine.")
option_end()
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()
option("sqlite")
set_default(true)
set_showmenu(true)
set_category("hikyuu")
set_description("Enable sqlite kdata engine.")
option_end()
option("tdx")
set_default(true)
set_showmenu(true)
set_category("hikyuu")
set_description("Enable tdx kdata engine.")
option_end()
2023-10-15 00:30:45 +08:00
option("stacktrace")
2023-10-01 22:16:04 +08:00
set_default(true)
set_showmenu(true)
set_category("hikyuu")
2023-10-15 00:30:45 +08:00
set_description("Enable check/assert with stack trace info.")
add_defines("HKU_ENABLE_STACK_TRACE")
option_end()
option("feedback")
set_default(true)
2023-10-15 00:30:45 +08:00
set_showmenu(true)
set_category("hikyuu")
2023-10-01 22:16:04 +08:00
set_description("Enable send feedback.")
option_end()
-- project
set_project("hikyuu")
2021-11-21 21:39:35 +08:00
add_rules("mode.debug", "mode.release")
2023-08-08 11:30:10 +08:00
if not is_plat("windows") then add_rules("mode.coverage", "mode.asan", "mode.msan", "mode.tsan", "mode.lsan") end
2021-11-21 21:39:35 +08:00
-- version
2023-11-05 20:34:32 +08:00
set_version("1.3.0", {build = "%Y%m%d%H%M"})
2023-06-14 16:37:10 +08:00
set_configvar("LOG_ACTIVE_LEVEL", 0) -- 激活的日志级别
-- if is_mode("debug") then
-- set_configvar("LOG_ACTIVE_LEVEL", 0) -- 激活的日志级别
-- else
-- set_configvar("LOG_ACTIVE_LEVEL", 2) -- 激活的日志级别
-- end
2020-05-19 23:31:19 +08:00
set_configvar("USE_SPDLOG_LOGGER", 1) -- 是否使用spdlog作为日志输出
2020-04-10 01:54:49 +08:00
set_configvar("USE_SPDLOG_ASYNC_LOGGER", 0) -- 使用异步的spdlog
set_configvar("CHECK_ACCESS_BOUND", 1)
2023-06-14 16:37:10 +08:00
if is_plat("macosx") then
2023-10-02 03:41:45 +08:00
set_configvar("SUPPORT_SERIALIZATION", 0)
2020-08-15 15:51:08 +08:00
else
2023-10-02 03:41:45 +08:00
set_configvar("SUPPORT_SERIALIZATION", is_mode("release") and 1 or 0)
2020-08-15 15:51:08 +08:00
end
set_configvar("SUPPORT_TEXT_ARCHIVE", 0)
set_configvar("SUPPORT_XML_ARCHIVE", 1)
set_configvar("SUPPORT_BINARY_ARCHIVE", 1)
2019-12-15 01:25:00 +08:00
set_configvar("HKU_DISABLE_ASSERT", 0)
2023-10-01 22:32:29 +08:00
set_configvar("ENABLE_MSVC_LEAK_DETECT", 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_KDATA", get_config("mysql") 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 warning all as error
2019-09-22 10:57:09 +08:00
if is_plat("windows") then
2023-10-02 03:41:45 +08:00
set_warnings("all", "error")
2019-09-22 16:01:15 +08:00
else
2023-10-02 03:41:45 +08:00
set_warnings("all")
2019-09-22 10:57:09 +08:00
end
-- set language: C99, c++ standard
2023-03-16 00:03:51 +08:00
set_languages("cxx17", "c99")
2023-04-29 01:25:55 +08:00
local boost_version = "1.81.0"
2022-10-18 01:35:53 +08:00
local hdf5_version = "1.12.2"
2023-08-16 02:57:46 +08:00
local fmt_version = "10.0.0"
local flatbuffers_version = "23.5.26"
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
add_repositories("project-repo hikyuu_extern_libs")
if is_plat("windows") then
if get_config("hdf5") then
if is_mode("release") then
add_requires("hdf5 " .. hdf5_version)
else
add_requires("hdf5_D " .. hdf5_version)
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
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
if get_config("hdf5") then
add_requires("brew::hdf5")
end
2023-10-02 03:41:45 +08:00
if get_config("mysql") then
add_requires("brew::mysql-client")
end
end
2023-03-27 02:37:01 +08:00
2023-08-16 02:57:46 +08:00
add_requires("myboost " .. boost_version, {
2023-08-08 11:30:10 +08:00
system = false,
2023-08-16 02:57:46 +08:00
alias = "boost",
2023-09-16 15:12:42 +08:00
debug = is_mode("debug"),
2023-08-08 11:30:10 +08:00
configs = {
shared = is_plat("windows") and true or false,
2023-10-18 19:14:29 +08:00
date_time = true,
2023-08-08 11:30:10 +08:00
filesystem = true,
serialization = true,
2023-08-13 01:59:00 +08:00
system = false,
2023-08-08 11:30:10 +08:00
python = true,
pyver = get_config("pyver"),
},
2023-06-14 16:37:10 +08:00
})
2023-08-16 03:25:48 +08:00
if is_plat("windows") then
add_requireconfs("myboost.python", {override = true, system=false})
end
2023-04-19 00:52:30 +08:00
2023-06-14 16:37:10 +08:00
add_requires("spdlog", {system = false, configs = {header_only = true, fmt_external = true, vs_runtime = "MD"}})
2023-08-16 02:57:46 +08:00
add_requireconfs("spdlog.fmt", {override = true, version = fmt_version, configs = {header_only = true}})
2023-06-14 16:37:10 +08:00
add_requires("sqlite3", {system = false, configs = {shared = true, vs_runtime = "MD", cxflags = "-fPIC"}})
add_requires("flatbuffers v" .. flatbuffers_version, {system = false, configs = {vs_runtime = "MD"}})
2023-06-14 16:37:10 +08:00
add_requires("nng", {system = false, configs = {vs_runtime = "MD", cxflags = "-fPIC"}})
add_requires("nlohmann_json", {system = false})
2023-09-29 03:08:50 +08:00
add_requires("cpp-httplib", {system = false, configs = {zlib = true, ssl = true}})
2023-06-14 16:37:10 +08:00
add_requires("zlib", {system = false})
2020-09-28 17:24:22 +08:00
2023-06-14 16:37:10 +08:00
add_defines("SPDLOG_DISABLE_DEFAULT_LOGGER") -- 禁用 spdlog 默认ogger
set_objectdir("$(buildir)/$(mode)/$(plat)/$(arch)/.objs")
set_targetdir("$(buildir)/$(mode)/$(plat)/$(arch)/lib")
-- modifed to use boost static library, except boost.python, serialization
2023-08-08 11:30:10 +08:00
if is_plat("windows") then add_defines("BOOST_ALL_DYN_LINK") end
-- 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
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")
if is_mode("release") then
add_cxflags("-MD")
elseif is_mode("debug") then
add_cxflags("-Gs", "-RTC1", "/bigobj")
add_cxflags("-MDd")
end
2023-06-14 16:37:10 +08:00
end
2019-09-22 23:02:08 +08:00
if not is_plat("windows") 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")
end
2023-06-14 16:37:10 +08:00
--
-- add_vectorexts("sse", "sse2", "sse3", "ssse3", "mmx", "avx")
2023-08-08 11:30:10 +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")
2023-06-14 16:37:10 +08:00
end
2023-09-03 18:20:20 +08:00
includes("./hikyuu_cpp/hikyuu")
includes("./hikyuu_pywrap")
includes("./hikyuu_cpp/unit_test")
includes("./hikyuu_cpp/demo")
includes("./hikyuu_cpp/hikyuu_server")
2018-09-09 16:43:04 +08:00
before_install("scripts.before_install")
on_install("scripts.on_install")
before_run("scripts.before_run")