summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-06-03 15:17:19 +0800
committerGitHub <[email protected]>2024-06-03 15:17:19 +0800
commitaf97444bbaf09dc62321ac0c60bde94f6da86a1a (patch)
tree90b6886ba8bd1655fb0b79aff61e3f371aa885ca
parente02cd06baf7993b53d662c6babd2599274ae199e (diff)
parent8138175b772e6b357e76db889d54a86803775959 (diff)
Merge pull request #5173 from xmake-io/cargo
add host dir for cargo #5156
-rw-r--r--xmake/modules/core/tools/rustc.lua5
-rw-r--r--xmake/modules/package/manager/cargo/find_package.lua15
-rw-r--r--xmake/modules/package/manager/cargo/install_package.lua10
3 files changed, 25 insertions, 5 deletions
diff --git a/xmake/modules/core/tools/rustc.lua b/xmake/modules/core/tools/rustc.lua
index 13451aa96..4d38c56f2 100644
--- a/xmake/modules/core/tools/rustc.lua
+++ b/xmake/modules/core/tools/rustc.lua
@@ -80,6 +80,11 @@ function nf_framework(self, framework)
local basename = path.basename(framework)
-- return "mycrate" from libmycrate-f882feaebb8ba0ca.rlib or libmycrate.rlib
local cratename = basename:match("lib(.-)%-.-") or basename:match("lib(.+)")
+ if not cratename and framework:endswith(".dll") then
+ -- @see https://github.com/xmake-io/xmake/issues/5156#issuecomment-2143978086
+ -- mycrate-f882feaebb8ba0ca.dll or mycrate.dll
+ cratename = basename:split("-", {plain = true})[1]
+ end
if cratename then
return {"--extern", cratename .. "=" .. framework}
end
diff --git a/xmake/modules/package/manager/cargo/find_package.lua b/xmake/modules/package/manager/cargo/find_package.lua
index 051bbdc5b..1090f2049 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,7 +146,17 @@ 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|*.dll.lib"))
+ table.join2(libfiles_native_host, os.files(path.join(librarydir_host, "*.dll")))
+ 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]
-- https://github.com/xmake-io/xmake/issues/5156#issuecomment-2143509207
@@ -155,7 +166,7 @@ function main(name, opt)
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
diff --git a/xmake/modules/package/manager/cargo/install_package.lua b/xmake/modules/package/manager/cargo/install_package.lua
index 97fd1a07e..d6e8048a2 100644
--- a/xmake/modules/package/manager/cargo/install_package.lua
+++ b/xmake/modules/package/manager/cargo/install_package.lua
@@ -166,11 +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", 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