Skip to content

Commit

Permalink
compile on Macosx
Browse files Browse the repository at this point in the history
  • Loading branch information
linjinhai committed Jan 30, 2021
1 parent 94d7019 commit 3ce6bc5
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 16 deletions.
89 changes: 89 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,95 @@
#ifndef HIKYUU_CONFIG_H_
#define HIKYUU_CONFIG_H_

#ifdef __APPLE__
#include <TargetConditionals.h>
#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
Expand Down
2 changes: 1 addition & 1 deletion hikyuu_cpp/hikyuu/utilities/ConnectPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion hikyuu_cpp/hikyuu/utilities/Null.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef NULL_H_
#define NULL_H_

#include "../config.h"
#include <cstddef>
#include <limits>
#include <type_traits>
Expand Down Expand Up @@ -69,7 +70,7 @@ class Null<long long> {
}
};

#if !defined(_MSC_VER)
#if !defined(_MSC_VER) && !HKU_OS_OSX
/**
* int64_t Null值
*/
Expand Down
5 changes: 5 additions & 0 deletions hikyuu_cpp/unit_test/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
31 changes: 17 additions & 14 deletions hikyuu_pywrap/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3ce6bc5

Please sign in to comment.