Skip to content

Commit

Permalink
恢复 macosx 下使用静态链接
Browse files Browse the repository at this point in the history
  • Loading branch information
fasiondog committed Feb 6, 2025
1 parent 3640d20 commit cb8a011
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,15 @@ def start_build(verbose=False, mode='release', feedback=True, worker_num=2, low_
if py_version != history_compile_info[
'py_version'] or history_compile_info['mode'] != mode:
clear_with_python_changed(mode)
kind = "shared" if mode == 'release' else "static"
kind = "shared" if mode == 'release' and sys.platform != 'darwin' else "static"
cmd = "xmake f {} -c -y -m {} --feedback={} -k {} --low_precision={} --log_level={}".format(
"-v -D" if verbose else "", mode, feedback, kind, low_precision,
2 if mode == 'release' else 0)

# macosx 下动态库不支持 serialize, 静态库太大不适合打包(hub中使用C++需要使用)
if sys.platform == 'darwin':
cmd += " --serialize=n"
# 静态库在 macosx 下支持 hub,也很麻烦,暂时搁置
# if sys.platform == 'darwin':
# cmd += " --serialize=n"
print(cmd)
os.system(cmd)

Expand Down
15 changes: 1 addition & 14 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,7 @@ option("leak_check", {description = "Enable leak check for test", default = fals
-- 使用 serialize 时,建议使用静态库方式编译,boost serializasion 对 dll 的方式支持不好
-- windows下如果使用 serialize 且希望使用动态库,需要设置 runtimes 参数为 "MD"
-- "MT" 方式下,serialize 会挂
-- option("serialize", {description = "Enable support serialize object and pickle in python", default = true})
option("serialize")
set_default(true)
set_showmenu(true)
set_category("hikyuu")
set_description("Enable support serialize object and pickle in python")
after_check(function (option)
-- macosx 下,serialize 不支持动态库
if is_plat("macosx") and get_config("kind") == "shared" then
cprint('${red}[warning] "serialize" will be disable on Macosx with shared kind!')
option:enable(false)
end
end)
option_end()
option("serialize", {description = "Enable support serialize object and pickle in python", default = true})

-- 和 hku_utils 编译选项保持一致,以便互相替换
option("mo", {description = "International language support", default = false})
Expand Down

0 comments on commit cb8a011

Please sign in to comment.