Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcpkg dynamic triplet #5023

Merged
merged 8 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions xmake/core/project/target.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2850,6 +2850,11 @@ function target.linkname(filename, opt)
if count == 0 and opt.plat == "mingw" then
linkname, count = filename:gsub(target.filename("__pattern__", "static", {plat = "windows"}):gsub("%.", "%%."):gsub("__pattern__", "(.+)") .. "$", "%1")
end
-- for custom shared libraries name, xxx.so, xxx.dylib
if filename:endswith(".so") or filename:endswith(".dylib") then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是这么改的,这里原本就会对 .so/.dylib 处理,不需要加这个硬编码

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ xmake l core.project.target.linkname libfoo.dylib shared
"foo"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前面几个 case 其实也看过了,这里如果库名不为 libxxx.so,比如没有前缀 lib, 那么 xxx.so 将无法被识别为 xxx。
我把这个部分的放到所有判断分支的最后,是希望能兼容这种不是很讲规矩的命名。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那应该先得判断 之前的 linkname 没被匹配到,而不是直接覆盖。。另外,不要直接 return ,也不要加 ;

统一走 linkname 返回,并且这种不规范的也得严格检测。。if not filename:startswith("lib")

return filename;
end

return count > 0 and linkname or nil
end

Expand Down
8 changes: 8 additions & 0 deletions xmake/modules/package/manager/vcpkg/configurations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ function triplet(configs, plat, arch)
if configs.runtimes and configs.runtimes:startswith("MD") then
triplet = triplet .. "-md"
end
elseif plat == "linux" then
if (arch == "x64" or arch == "x86") and configs.shared == true then
triplet = triplet .. "-dynamic"
end
elseif plat == "macosx" then
if arch == "x64" and configs.shared == true then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接 if configs.shared then 就行了,不用加 == true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哦哦,随手写的可能没太注意

triplet = triplet .. "-dynamic"
end
elseif plat == "mingw" then
triplet = triplet .. (configs.shared ~= true and "-static" or "-dynamic")
end
Expand Down