Skip to content

Commit

Permalink
依据ruki的建议优化xmake.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
fasiondog committed Apr 7, 2020
1 parent e3a3522 commit 3cee4c6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 28 deletions.
12 changes: 6 additions & 6 deletions hikyuu_cpp/demo/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ option("with-demo")
option_end()

target("demo")
if has_config("with-demo") then
set_kind("binary")
else
set_kind("phony")
set_kind("binary")
if is_mode("debug") then
set_default(false)
end

add_packages("spdlog", "fmt")
add_includedirs("..")

if is_plat("windows") then
add_cxflags("-wd4267")
end
if is_plat("windows") then

if is_plat("windows") and is_mode("release") then
add_defines("HKU_API=__declspec(dllimport)")
add_defines("SQLITE_API=__declspec(dllimport)")
end
Expand Down
14 changes: 6 additions & 8 deletions hikyuu_cpp/unit_test/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ option_end()
add_requires("doctest")

target("unit-test")
if get_config("test") == "all" then
set_kind("binary")
else
set_kind("phony")
set_kind("binary")
if get_config("test") == "small" then
set_default(false)
end

add_packages("fmt", "spdlog", "doctest")
Expand Down Expand Up @@ -50,10 +49,9 @@ target("unit-test")
target_end()

target("small-test")
if get_config("test") == "small" then
set_kind("binary")
else
set_kind("phony")
set_kind("binary")
if get_config("test") == "all" then
set_default(false)
end
add_packages("fmt", "spdlog", "doctest")
add_includedirs("..")
Expand Down
31 changes: 25 additions & 6 deletions hikyuu_pywrap/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ end
on_load("xmake_on_load")

target("_hikyuu")
set_kind(ifelse(is_mode("release"), "shared", "phony"))
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
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
Expand All @@ -37,7 +41,10 @@ target("_hikyuu")
add_files("./*.cpp")

target("_indicator")
set_kind(ifelse(is_mode("release"), "shared", "phony"))
set_kind("shared")
if is_mode("debug") then
set_default(false)
end
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
Expand All @@ -48,7 +55,10 @@ target("_indicator")
add_files("./indicator/*.cpp")

target("_trade_manage")
set_kind(ifelse(is_mode("release"), "shared", "phony"))
set_kind("shared")
if is_mode("debug") then
set_default(false)
end
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
Expand All @@ -59,7 +69,10 @@ target("_trade_manage")
add_files("./trade_manage/*.cpp")

target("_trade_sys")
set_kind(ifelse(is_mode("release"), "shared", "phony"))
set_kind("shared")
if is_mode("debug") then
set_default(false)
end
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
Expand All @@ -70,7 +83,10 @@ target("_trade_sys")
add_files("./trade_sys/*.cpp")

target("_trade_instance")
set_kind(ifelse(is_mode("release"), "shared", "phony"))
set_kind("shared")
if is_mode("debug") then
set_default(false)
end
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
Expand All @@ -81,7 +97,10 @@ target("_trade_instance")
add_files("./trade_instance/*.cpp")

target("_data_driver")
set_kind(ifelse(is_mode("release"), "shared", "phony"))
set_kind("shared")
if is_mode("debug") then
set_default(false)
end
add_packages("fmt", "spdlog")
add_deps("hikyuu")
if is_plat("windows") then
Expand Down
22 changes: 14 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ def start_build(verbose=False, mode='release'):
#如果 python版本或者编译模式发生变化,则编译依赖的 boost 库(boost.python)
history_compile_info = get_history_compile_info()
if py_version != history_compile_info['py_version'] or history_compile_info['mode'] != mode:
if py_version != history_compile_info[
'py_version'] or history_compile_info['mode'] != mode:
clear_with_python_changed(mode)
print('\ncompile boost ...')
build_boost(mode)
Expand All @@ -197,12 +198,16 @@ def start_build(verbose=False, mode='release'):
os.system("xmake f -y -m {}".format(mode))
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 ""))
if mode == "release":
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 ""))
# 保存当前的编译信息
save_current_compile_info(current_compile_info)
Expand Down Expand Up @@ -308,7 +313,8 @@ def install():
else:
usr_dir = os.path.expanduser('~')
install_dir = '{}/.local/lib/python{:>.1f}/site-packages/hikyuu'.format(
usr_dir, get_python_version() * 0.1)
usr_dir,
get_python_version() * 0.1)
try:
shutil.rmtree(install_dir)
except:
Expand Down

0 comments on commit 3cee4c6

Please sign in to comment.