hikyuu2/hikyuu_pywrap/xmake_on_load.lua

44 lines
1.5 KiB
Lua
Raw Normal View History

2018-09-15 02:52:35 +08:00
function main(target)
if is_plat("windows") then
local pydir = os.iorun("python -c \"import sys; print(sys.executable)\"")
pydir = path.directory(pydir)
target:add("includedirs", pydir .. "/include")
target:add("linkdirs", pydir .. "/libs")
2018-09-19 02:45:50 +08:00
return
end
2018-09-21 01:08:43 +08:00
target:add("rpathdirs", "$ORIGIN", "$ORIGIN/lib", "$ORIGIN/../lib")
2018-09-19 02:45:50 +08:00
if is_plat("macosx") then
2018-09-20 23:12:30 +08:00
local libdir = os.iorun("python3-config --prefix"):trim() .. "/lib"
2018-09-20 02:43:03 +08:00
target:add("linkdirs", libdir)
2018-09-20 23:12:30 +08:00
local out, err = os.iorun("python3 --version")
local ver = (out .. err):trim()
local python_lib = format("python%s.%sm", string.sub(ver,8,8), string.sub(ver,10,10))
target:add("links", python_lib)
2018-09-19 02:45:50 +08:00
end
2018-09-20 02:43:03 +08:00
2018-09-19 02:45:50 +08:00
-- get python include directory.
2018-09-20 23:12:30 +08:00
local pydir = os.iorun("python3-config --includes"):trim()
--local lcPos = string.find(pydir,"\n")
--pydir = (string.sub(pydir,1,lcPos-1))
2018-09-19 02:45:50 +08:00
target:add("cxflags", pydir)
2018-09-15 02:52:35 +08:00
2018-09-19 02:45:50 +08:00
-- get suffix configure for link libboost_pythonX.so
2018-09-20 02:43:03 +08:00
local suffix = get_config("boost-python-suffix")
2018-09-19 02:45:50 +08:00
if suffix == nil then
2018-09-20 02:43:03 +08:00
raise("You need to config --boost-python-suffix specify libboost_python suffix")
2018-09-19 02:45:50 +08:00
end
2018-09-15 02:52:35 +08:00
2018-09-19 02:45:50 +08:00
suffix = string.upper(suffix)
if suffix == "3X" then
2018-09-20 23:12:30 +08:00
local out, err = os.iorun("python3 --version")
local ver = (out .. err):trim()
local boost_python_lib = "boost_python"..string.sub(ver,8,8)..string.sub(ver,10,10)
2018-09-19 02:45:50 +08:00
target:add("links", boost_python_lib)
else
target:add("links", "boost_python"..suffix)
2018-09-15 02:52:35 +08:00
end
end