From 3cee4c615a091ee5bb5279e231446282ad7066a2 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Wed, 8 Apr 2020 00:24:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9D=E6=8D=AEruki=E7=9A=84=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE=E4=BC=98=E5=8C=96xmake.lua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu_cpp/demo/xmake.lua | 12 ++++++------ hikyuu_cpp/unit_test/xmake.lua | 14 ++++++-------- hikyuu_pywrap/xmake.lua | 31 +++++++++++++++++++++++++------ setup.py | 22 ++++++++++++++-------- 4 files changed, 51 insertions(+), 28 deletions(-) diff --git a/hikyuu_cpp/demo/xmake.lua b/hikyuu_cpp/demo/xmake.lua index 5e9878736..212971c37 100644 --- a/hikyuu_cpp/demo/xmake.lua +++ b/hikyuu_cpp/demo/xmake.lua @@ -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 diff --git a/hikyuu_cpp/unit_test/xmake.lua b/hikyuu_cpp/unit_test/xmake.lua index b7c38fd66..b835dde2c 100644 --- a/hikyuu_cpp/unit_test/xmake.lua +++ b/hikyuu_cpp/unit_test/xmake.lua @@ -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") @@ -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("..") diff --git a/hikyuu_pywrap/xmake.lua b/hikyuu_pywrap/xmake.lua index 80b21b41b..a8a9f1462 100644 --- a/hikyuu_pywrap/xmake.lua +++ b/hikyuu_pywrap/xmake.lua @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/setup.py b/setup.py index c8e5b9599..85a760eb0 100644 --- a/setup.py +++ b/setup.py @@ -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) @@ -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) @@ -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: