hikyuu2/hikyuu_pywrap/xmake.lua

77 lines
3.0 KiB
Lua
Raw Normal View History

2019-06-04 23:13:32 +08:00
add_requires("pybind11", {system = false, alias = "pybind11"})
2023-12-26 18:25:50 +08:00
2020-06-25 15:59:37 +08:00
target("core")
2020-04-08 00:24:12 +08:00
set_kind("shared")
if is_mode("debug") then
set_default(false) --会默认禁用这个target的编译除非显示指定xmake build _hikyuu才会去编译但是target还存在里面的files会保留到vcproj
--set_enable(false) --set_enable(false)会彻底禁用这个target连target的meta也不会被加载vcproj不会保留它
end
2023-03-29 02:10:34 +08:00
2023-10-15 00:30:45 +08:00
add_options("stackstrace")
2018-09-09 16:43:04 +08:00
add_deps("hikyuu")
2023-12-27 18:46:32 +08:00
add_packages("boost", "fmt", "spdlog", "flatbuffers", "pybind11", "cpp-httplib")
if is_plat("windows") then
2020-06-25 15:59:37 +08:00
set_filename("core.pyd")
2020-08-01 18:52:56 +08:00
add_cxflags("-wd4251")
2018-09-21 01:08:43 +08:00
else
2020-06-25 15:59:37 +08:00
set_filename("core.so")
end
2023-03-29 02:10:34 +08:00
2023-09-16 15:12:42 +08:00
if is_plat("windows") and is_mode("release") then
2023-03-29 02:10:34 +08:00
add_defines("HKU_API=__declspec(dllimport)")
add_cxflags("-wd4566")
end
local cc = get_config("cc")
local cxx = get_config("cxx")
if (cc and string.find(cc, "clang")) or (cxx and string.find(cxx, "clang")) then
add_cxflags("-Wno-error=parentheses-equality -Wno-error=missing-braces")
end
add_includedirs("../hikyuu_cpp")
2023-12-27 22:48:41 +08:00
add_files("./**.cpp")
2018-09-09 16:43:04 +08:00
2020-06-25 15:59:37 +08:00
add_rpathdirs("$ORIGIN", "$ORIGIN/lib", "$ORIGIN/../lib")
2024-01-09 16:58:03 +08:00
on_load("windows", "linux", "macosx", function(target)
import("lib.detect.find_tool")
2024-01-09 18:40:30 +08:00
if is_plat("windows") then
-- detect installed python3
local python = assert(find_tool("python", {version = true}), "python not found, please install it first! note: python version must > 3.0")
assert(python.version > "3", python.version .. " python version must > 3.0, please use python3.0 or later!")
-- find python include and libs directory
local pydir = os.iorun("python -c \"import sys; print(sys.executable)\"")
pydir = path.directory(pydir)
package:add("includedirs", pydir .. "/include")
package:add("linkdirs", pydir .. "/libs")
return
2024-01-09 16:58:03 +08:00
end
2024-01-09 18:40:30 +08:00
-- get python include directory.
local pydir = try { function () return os.iorun("python3-config --includes"):trim() end }
assert(pydir, "python3-config not found!")
package:add("cxflags", pydir)
2024-01-09 16:58:03 +08:00
end)
2020-06-25 15:59:37 +08:00
after_build(function(target)
2020-08-15 00:24:35 +08:00
if is_plat("macosx") then
os.run(format("install_name_tool -change @rpath/libhikyuu.dylib @loader_path/libhikyuu.dylib %s/%s", target:targetdir(), "core.so"))
end
2020-06-25 15:59:37 +08:00
local dst_dir = "$(projectdir)/hikyuu/cpp/"
2020-09-14 00:18:57 +08:00
if is_plat("windows") then
os.cp(target:targetdir() .. '/core.pyd', dst_dir)
os.cp(target:targetdir() .. '/*.dll', dst_dir)
2020-09-14 00:18:57 +08:00
elseif is_plat("macosx") then
os.cp(target:targetdir() .. '/core.so', dst_dir)
2020-09-30 21:57:15 +08:00
os.cp(target:targetdir() .. '/libhikyuu.dylib', dst_dir)
2020-09-14 00:18:57 +08:00
else
os.trycp(target:targetdir() .. '/*.so', dst_dir)
os.trycp(target:targetdir() .. '/*.so.*', dst_dir)
2020-09-14 00:18:57 +08:00
end
2020-06-25 15:59:37 +08:00
end)
2018-09-09 16:43:04 +08:00