1、使用xmake repo支持fmt、spdlog;

2、分离单元测试程序为all和small,避免测试代码编译耗时过长
This commit is contained in:
fasiondog 2019-09-09 02:11:26 +08:00
parent 22a2de9565
commit 1d4bdddfc8
9 changed files with 92 additions and 28 deletions

View File

@ -37,8 +37,8 @@ script:
- export BOOST_ROOT=./boost_1_67_0
- export BOOST_LIB=./boost_1_67_0/stage/lib
- ls .
- xmake f --with-unit-test=y --cxx=$CXX
- xmake f --cxx=$CXX --confirm=y --test=small
- xmake -b hikyuu
- if [ "$CXX_FOR_BUILD" = "clang++" ]; then xmake -b unit-test; fi
- if [ "$CXX_FOR_BUILD" = "clang++" ]; then xmake r unit-test; fi
- if [ "$CXX_FOR_BUILD" = "clang++" ]; then xmake -b small-test; fi
- if [ "$CXX_FOR_BUILD" = "clang++" ]; then xmake r small-test; fi

View File

@ -1,6 +1,8 @@
target("hikyuu")
set_kind("shared")
add_packages("fmt", "spdlog")
add_includedirs("..")
-- set version for release

View File

@ -1,17 +1,20 @@
option("with-unit-test")
set_default(false)
option("test")
set_default("small")
set_values("small", "all")
set_showmenu(true)
set_category("hikyuu")
set_description("Complie with unit-test")
option_end()
target("unit-test")
if has_config("with-unit-test") then
if get_config("test") == "all" then
set_kind("binary")
else
set_kind("phony")
end
add_packages("fmt", "spdlog")
add_includedirs("..")
if is_plat("windows") then
@ -43,3 +46,44 @@ target("unit-test")
add_files("**.cpp")
target_end()
target("small-test")
if get_config("test") == "small" then
set_kind("binary")
else
set_kind("phony")
end
add_packages("fmt", "spdlog")
add_includedirs("..")
if is_plat("windows") then
add_cxflags("-wd4267")
add_cxflags("-wd4251")
add_cxflags("-wd4244")
add_cxflags("-wd4805")
else
add_cxflags("-Wno-unused-variable", "-Wno-missing-braces")
add_cxflags("-Wno-sign-compare")
end
if is_plat("windows") then
add_defines("HKU_API=__declspec(dllimport)")
end
add_defines("PY_VERSION_HEX=0x03000000")
add_defines("TEST_ALL_IN_ONE")
add_deps("hikyuu")
if is_plat("linux") or is_plat("macosx") then
add_links("boost_unit_test_framework")
--add_links("boost_system")
add_shflags("-Wl,-rpath=$ORIGIN", "-Wl,-rpath=$ORIGIN/../lib")
end
-- add files
add_files("./libs/hikyuu/hikyuu/**.cpp")
add_files("./libs/hikyuu/config.cpp")
add_files("./test_all.cpp")
target_end()

@ -1 +1 @@
Subproject commit a19e498cf192ba74d8a3e9dc74c517a66627e4c8
Subproject commit bcd596f26f783dbd3afd7bfbcb0e2da922c8c56d

View File

@ -24,6 +24,7 @@ on_load("xmake_on_load")
target("_hikyuu")
set_kind("shared")
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
set_filename("_hikyuu.pyd")
@ -34,6 +35,7 @@ target("_hikyuu")
target("_indicator")
set_kind("shared")
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
set_filename("_indicator.pyd")
@ -44,6 +46,7 @@ target("_indicator")
target("_trade_manage")
set_kind("shared")
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
set_filename("_trade_manage.pyd")
@ -54,6 +57,7 @@ target("_trade_manage")
target("_trade_sys")
set_kind("shared")
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
set_filename("_trade_sys.pyd")
@ -64,6 +68,7 @@ target("_trade_sys")
target("_trade_instance")
set_kind("shared")
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
set_filename("_trade_instance.pyd")
@ -74,6 +79,7 @@ target("_trade_instance")
target("_data_driver")
set_kind("shared")
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
set_filename("_data_driver.pyd")

View File

@ -2,7 +2,7 @@ import("core.project.config")
function main(target)
local targetname = target:name()
if targetname ~= "demo" and targetname ~= "unit-test" then
if targetname ~= "demo" and targetname ~= "unit-test" and targetname ~= "small-test" then
return
end
@ -13,15 +13,10 @@ function main(target)
end
end
if "unit-test" == targetname then
local with_test = config.get("with-unit-test")
if with_test then
print("copying test_data ...")
os.rm("$(buildir)/$(mode)/$(plat)/$(arch)/lib/test_data")
os.cp("$(projectdir)/test_data", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
else
raise("You need to config first: xmake f --with-unit-test=y")
end
if "unit-test" == targetname or "small-test" == targetname then
print("copying test_data ...")
os.rm("$(buildir)/$(mode)/$(plat)/$(arch)/lib/test_data")
os.cp("$(projectdir)/test_data", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
end
if is_plat("windows") then

View File

@ -7,7 +7,7 @@ function main(target)
end
local targetname = target:name()
if "demo" == targetname or "unit-test" == targetname then
if "demo" == targetname or "unit-test" == targetname or "small-test" == targetname then
return
end

View File

@ -139,12 +139,16 @@ def start_build(verbose=False ):
build_boost()
if py_version_changed:
os.system("xmake f -c")
os.system("xmake f --with-unit-test=y")
os.system("xmake f -c -y")
else:
if not os.path.lexists('.xmake'):
os.system("xmake f --with-unit-test=y")
os.system("xmake -v -D" if verbose else "xmake")
os.system("xmake f -y")
os.system("xmake -b hikyuu {}".format("-v -D" if verbose else ""))
os.system("xmake -b _hikyuu {}".format("-v -D" if verbose else ""))
os.system("xmake -b _indicator {}".format("-v -D" if verbose else ""))
os.system("xmake -b _trade_manage {}".format("-v -D" if verbose else ""))
os.system("xmake -b _trade_sys {}".format("-v -D" if verbose else ""))
os.system("xmake -b _trade_instance {}".format("-v -D" if verbose else ""))
os.system("xmake -b _data_driver {}".format("-v -D" if verbose else ""))
#------------------------------------------------------------------------------
@ -164,12 +168,23 @@ def build(verbose):
@click.command()
@click.option("--compile", default=False, type=click.BOOL, help='false')
def test(compile):
@click.option('-f', "--f", default='small',
type=click.Choice(['small', 'all']),
help="测试范围small all全部")
@click.option("-compile", "--compile", default=False, type=click.BOOL, help='false')
@click.option('-v', '--verbose', is_flag=True, help='')
def test(f, compile, verbose):
""" 执行单元测试 """
if compile:
start_build()
os.system("xmake r unit-test")
start_build(verbose)
if f == 'all':
os.system("xmake f --test=all")
os.system("xmake -b unit-test")
os.system("xmake r unit-test")
else:
os.system("xmake f --test=small")
os.system("xmake -b small-test")
os.system("xmake r small-test")
@click.command()
@ -219,7 +234,7 @@ def install():
start_build()
py_version, py_version_changed = get_python_version()
if py_version_changed:
os.system("xmake f -c")
os.system("xmake f -c -y")
if sys.platform == 'win32':
install_dir = sys.base_prefix + "\\Lib\\site-packages\\Hikyuu"
else:

View File

@ -22,6 +22,8 @@ set_languages("C99", "cxx11")
add_plugindirs("./xmake_plugins")
add_requires("fmt", "spdlog")
-- use fmt, spdlog
add_defines("FMT_HEADER_ONLY=1")