diff --git a/config.h.in b/config.h.in index 233649c61..1c5c004a1 100644 --- a/config.h.in +++ b/config.h.in @@ -2,6 +2,95 @@ #ifndef HIKYUU_CONFIG_H_ #define HIKYUU_CONFIG_H_ +#ifdef __APPLE__ +#include +#endif + +/* + * CPU 架构宏定义 + */ +#if defined(__arm__) +#define HKU_ARCH_ARM 1 +#define HKU_ARCH_ARM64 0 +#define HKU_ARCH_X86 0 +#define HKU_ARCH_X64 0 +#elif defined(__aarch64__) +#define HKU_ARCH_ARM 0 +#define HKU_ARCH_ARM64 1 +#define HKU_ARCH_X86 0 +#define HKU_ARCH_X64 0 +#elif defined(__x86_64__) || defined(_WIN64) +#define HKU_ARCH_ARM 0 +#define HKU_ARCH_ARM64 0 +#define HKU_ARCH_X86 0 +#define HKU_ARCH_X64 1 +#elif defined(__i386__) || defined(_WIN32) +#define HKU_ARCH_ARM 0 +#define HKU_ARCH_ARM64 0 +#define HKU_ARCH_X86 1 +#define HKU_ARCH_X64 0 +#else +#define HKU_ARCH_ARM 0 +#define HKU_ARCH_ARM64 0 +#define HKU_ARCH_X86 0 +#define HKU_ARCH_X64 0 +#endif + +/* + * 操作系统宏定义 + */ +#if defined(_WIN32) || defined(_WIN64) +#define HKU_OS_WINOWS 1 +#define HKU_OS_LINUX 0 +#define HKU_OS_ANDROID 0 +#define HKU_OS_OSX 0 +#define HKU_OS_IOS 0 +#elif defined(__ANDROID__) +#define HKU_OS_WINOWS 0 +#define HKU_OS_LINUX 0 +#define HKU_OS_ANDROID 1 +#define HKU_OS_OSX 0 +#define HKU_OS_IOS 0 +#elif defined(__linux__) +#define HKU_OS_WINOWS 0 +#define HKU_OS_LINUX 1 +#define HKU_OS_ANDROID 0 +#define HKU_OS_OSX 0 +#define HKU_OS_IOS 0 +#elif TARGET_OS_OSX +#define HKU_OS_WINOWS 0 +#define HKU_OS_LINUX 0 +#define HKU_OS_ANDROID 0 +#define HKU_OS_OSX 1 +#define HKU_OS_IOS 0 +#elif TARGET_OS_IOS || TARGET_OS_IPHONE +#define HKU_OS_WINOWS 0 +#define HKU_OS_LINUX 0 +#define HKU_OS_ANDROID 0 +#define HKU_OS_OSX 0 +#define HKU_OS_IOS 1 +#else +#define HKU_OS_WINOWS 0 +#define HKU_OS_LINUX 0 +#define HKU_OS_ANDROID 0 +#define HKU_OS_OSX 0 +#define HKU_OS_IOS 0 +#endif + +// IOS 模拟器 +#if HKU_OS_IOS && TARGET_OS_SIMULATOR +#define HKU_OS_IOS_SIMULATOR 1 +#else +#define HKU_OS_IOS_SIMULATOR 0 +#endif + +// ARM NEON 优化 +#if HKU_OS_ANDROID && HKU_ARCH_ARM64 +#define HKU_ENBALE_NEON 0 +#else +#define HKU_ENBALE_NEON 0 +#endif + // clang-format off // support serialization diff --git a/hikyuu_cpp/hikyuu/utilities/ConnectPool.h b/hikyuu_cpp/hikyuu/utilities/ConnectPool.h index fd8a142de..d258c5d9b 100644 --- a/hikyuu_cpp/hikyuu/utilities/ConnectPool.h +++ b/hikyuu_cpp/hikyuu/utilities/ConnectPool.h @@ -88,7 +88,7 @@ class ConnectPool { std::this_thread::sleep_for(std::chrono::milliseconds(sleep)); result = getConnect(); if (timeout > 0) { - YH_CHECK(count++ < max_count, "Can't get connect, timeout!"); + HKU_CHECK(count++ < max_count, "Can't get connect, timeout!"); } } return result; diff --git a/hikyuu_cpp/hikyuu/utilities/Null.h b/hikyuu_cpp/hikyuu/utilities/Null.h index 7b63d8596..fb823659a 100644 --- a/hikyuu_cpp/hikyuu/utilities/Null.h +++ b/hikyuu_cpp/hikyuu/utilities/Null.h @@ -9,6 +9,7 @@ #ifndef NULL_H_ #define NULL_H_ +#include "../config.h" #include #include #include @@ -69,7 +70,7 @@ class Null { } }; -#if !defined(_MSC_VER) +#if !defined(_MSC_VER) && !HKU_OS_OSX /** * int64_t Null值 */ diff --git a/hikyuu_cpp/unit_test/xmake.lua b/hikyuu_cpp/unit_test/xmake.lua index dc7bacceb..7ebbe15d4 100644 --- a/hikyuu_cpp/unit_test/xmake.lua +++ b/hikyuu_cpp/unit_test/xmake.lua @@ -43,6 +43,11 @@ target("unit-test") add_shflags("-Wl,-rpath=$ORIGIN", "-Wl,-rpath=$ORIGIN/../lib") end + if is_plat("macosx") then + add_includedirs("/usr/local/opt/mysql-client/include") + add_linkdirs("/usr/local/opt/mysql-client/lib") + end + -- add files add_files("**.cpp") diff --git a/hikyuu_pywrap/xmake.lua b/hikyuu_pywrap/xmake.lua index f613dbe71..7b1bc0803 100644 --- a/hikyuu_pywrap/xmake.lua +++ b/hikyuu_pywrap/xmake.lua @@ -64,8 +64,11 @@ target("core") target:add("linkdirs", libdir) 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)) - local python_lib = format("python%s.%s", string.sub(ver,8,8), string.sub(ver,10,10)) + local python_lib = format("python%s.%sm", string.sub(ver,8,8), string.sub(ver,10,10)) + local pyver = tonumber(format("%s.%s", string.sub(ver,8,8), string.sub(ver,10,10))) + if pyver >= 3.8 then + python_lib = format("python%s.%s", string.sub(ver,8,8), string.sub(ver,10,10)) + end target:add("links", python_lib) end @@ -97,9 +100,9 @@ target("core") local ver = (out .. err):trim() local boost_python_lib = format("libboost_python%s%s.dylib", string.sub(ver,8,8), string.sub(ver,10,10)) os.run(format("install_name_tool -change @rpath/libhikyuu.dylib @loader_path/libhikyuu.dylib %s/%s", target:targetdir(), "core.so")) - --os.run(format("install_name_tool -change @rpath/libboost_date_time.dylib @loader_path/libboost_date_time.dylib %s/%s", target:targetdir(), "core.so")) - --os.run(format("install_name_tool -change @rpath/libboost_filesystem.dylib @loader_path/libboost_filesystem.dylib %s/%s", target:targetdir(), "core.so")) - --os.run(format("install_name_tool -change @rpath/libboost_system.dylib @loader_path/libboost_system.dylib %s/%s", target:targetdir(), "core.so")) + os.run(format("install_name_tool -change @rpath/libboost_date_time.dylib @loader_path/libboost_date_time.dylib %s/%s", target:targetdir(), "core.so")) + os.run(format("install_name_tool -change @rpath/libboost_filesystem.dylib @loader_path/libboost_filesystem.dylib %s/%s", target:targetdir(), "core.so")) + os.run(format("install_name_tool -change @rpath/libboost_system.dylib @loader_path/libboost_system.dylib %s/%s", target:targetdir(), "core.so")) os.run(format("install_name_tool -change @rpath/libboost_serialization.dylib @loader_path/libboost_serialization.dylib %s/%s", target:targetdir(), "core.so")) os.run(format("install_name_tool -change @rpath/%s @loader_path/%s %s/%s", boost_python_lib, boost_python_lib, target:targetdir(), "core.so")) end @@ -117,21 +120,21 @@ target("core") os.cp(target:targetdir() .. '/libhikyuu.so', dst_dir) end - --os.cp("$(env BOOST_LIB)/boost_date_time*.dll", dst_dir) - --os.cp("$(env BOOST_LIB)/boost_filesystem*.dll", dst_dir) + os.cp("$(env BOOST_LIB)/boost_date_time*.dll", dst_dir) + os.cp("$(env BOOST_LIB)/boost_filesystem*.dll", dst_dir) os.cp("$(env BOOST_LIB)/boost_python3*.dll", dst_dir) os.cp("$(env BOOST_LIB)/boost_serialization*.dll", dst_dir) - --os.cp("$(env BOOST_LIB)/boost_system*.dll", dst_dir) - --os.cp("$(env BOOST_LIB)/libboost_date_time*.so.*", dst_dir) - --os.cp("$(env BOOST_LIB)/libboost_filesystem*.so.*", dst_dir) + os.cp("$(env BOOST_LIB)/boost_system*.dll", dst_dir) + os.cp("$(env BOOST_LIB)/libboost_date_time*.so.*", dst_dir) + os.cp("$(env BOOST_LIB)/libboost_filesystem*.so.*", dst_dir) os.cp("$(env BOOST_LIB)/libboost_python3*.so.*", dst_dir) os.cp("$(env BOOST_LIB)/libboost_serialization*.so.*", dst_dir) - --os.cp("$(env BOOST_LIB)/libboost_system*.so.*", dst_dir) - --os.cp("$(env BOOST_LIB)/libboost_date_time*.dylib", dst_dir) - --os.cp("$(env BOOST_LIB)/libboost_filesystem*.dylib", dst_dir) + os.cp("$(env BOOST_LIB)/libboost_system*.so.*", dst_dir) + os.cp("$(env BOOST_LIB)/libboost_date_time*.dylib", dst_dir) + os.cp("$(env BOOST_LIB)/libboost_filesystem*.dylib", dst_dir) os.cp("$(env BOOST_LIB)/libboost_python3*.dylib", dst_dir) os.cp("$(env BOOST_LIB)/libboost_serialization*.dylib", dst_dir) - --os.cp("$(env BOOST_LIB)/libboost_system*.dylib", dst_dir) + os.cp("$(env BOOST_LIB)/libboost_system*.dylib", dst_dir) if is_plat("windows") then if is_mode("release") then