summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-06-01 22:46:57 +0800
committerruki <[email protected]>2024-06-01 22:46:57 +0800
commitabe38b04e998519831853b993ddb14bb6d725b02 (patch)
tree66642d6ee2a2b697a0b4b863ce3efc73b10d0458
parent20e1f9bddf7199350f44130c6b0bb4a51e0a8223 (diff)
add host deps for cargo
-rw-r--r--xmake/modules/package/manager/cargo/find_package.lua18
-rw-r--r--xmake/modules/package/manager/cargo/install_package.lua11
2 files changed, 19 insertions, 10 deletions
diff --git a/xmake/modules/package/manager/cargo/find_package.lua b/xmake/modules/package/manager/cargo/find_package.lua
index a589a8d92..87f46bb8a 100644
--- a/xmake/modules/package/manager/cargo/find_package.lua
+++ b/xmake/modules/package/manager/cargo/find_package.lua
@@ -133,6 +133,7 @@ function main(name, opt)
local frameworkdirs
local frameworks
local librarydir = path.join(opt.installdir, "lib")
+ local librarydir_host = path.join(opt.installdir, "lib", "host")
local libfiles = os.files(path.join(librarydir, "*.rlib"))
-- @see https://github.com/xmake-io/xmake/issues/4228
@@ -145,13 +146,22 @@ function main(name, opt)
else
libfiles_native = os.files(path.join(librarydir, "*.so"))
end
- for _, libraryfile in ipairs(table.join(libfiles, libfiles_native)) do
+ -- @see https://github.com/xmake-io/xmake/issues/5156
+ local libfiles_native_host
+ if is_host("macosx") then
+ libfiles_native_host = os.files(path.join(librarydir_host, "*.dylib"))
+ elseif is_host("windows") then
+ libfiles_native_host = os.files(path.join(librarydir_host, "*.lib"))
+ else
+ libfiles_native_host = os.files(path.join(librarydir_host, "*.so"))
+ end
+ for _, libraryfile in ipairs(table.join(libfiles or {}, libfiles_native or {}, libfiles_native_host)) do
local filename = path.filename(libraryfile)
local libraryname = filename:split('-', {plain = true})[1]
if names:has(libraryname) then
frameworkdirs = frameworkdirs or {}
frameworks = frameworks or {}
- table.insert(frameworkdirs, librarydir)
+ table.insert(frameworkdirs, path.directory(libraryfile))
table.insert(frameworks, libraryfile)
end
end
@@ -161,10 +171,6 @@ function main(name, opt)
result.libfiles = libfiles
result.frameworkdirs = frameworkdirs and table.unique(frameworkdirs) or nil
result.frameworks = frameworks
- local hostlibdir = path.join(librarydir, "host")
- if os.isdir(hostlibdir) then
- result.linkdirs = hostlibdir
- end
result.version = opt.require_version
end
return result
diff --git a/xmake/modules/package/manager/cargo/install_package.lua b/xmake/modules/package/manager/cargo/install_package.lua
index 61bd6257c..d6e8048a2 100644
--- a/xmake/modules/package/manager/cargo/install_package.lua
+++ b/xmake/modules/package/manager/cargo/install_package.lua
@@ -166,12 +166,15 @@ target = "%s"
-- do install
local installdir = opt.installdir
- os.tryrm(path.join(installdir, "lib"))
+ local librarydir = path.join(installdir, "lib")
+ local librarydir_host = path.join(installdir, "lib", "host")
+ os.tryrm(librarydir)
if target then
- os.vcp(path.join(sourcedir, "target", target, opt.mode == "debug" and "debug" or "release", "deps"), path.join(installdir, "lib"))
- os.vcp(path.join(sourcedir, "target", opt.mode == "debug" and "debug" or "release", "deps"), path.join(installdir, "lib", "host"))
+ os.vcp(path.join(sourcedir, "target", target, opt.mode == "debug" and "debug" or "release", "deps"), librarydir)
+ -- @see https://github.com/xmake-io/xmake/issues/5156#issuecomment-2142566862
+ os.vcp(path.join(sourcedir, "target", opt.mode == "debug" and "debug" or "release", "deps"), librarydir_host)
else
- os.vcp(path.join(sourcedir, "target", opt.mode == "debug" and "debug" or "release", "deps"), path.join(installdir, "lib"))
+ os.vcp(path.join(sourcedir, "target", opt.mode == "debug" and "debug" or "release", "deps"), librarydir)
end
-- install metadata