summaryrefslogtreecommitdiff
path: root/xmake/rules/utils
diff options
context:
space:
mode:
authorIMXEren <[email protected]>2025-07-06 02:43:56 +0530
committerIMXEren <[email protected]>2025-07-06 05:00:32 +0530
commit8d08f0cc65c7d998265e247660ebf19bc1ba0caa (patch)
tree94d6f04dfd653abea1cf1bdf1d7f97fd611336d3 /xmake/rules/utils
parent5929eeebf059979fd4a8952b74696a2c4ea33750 (diff)
fix: rust static and shared library failing to find extern crate in windows-msvc
1. rustc requires lib*.rlib, *.dll but produces *.rlib, *.dll. 2. shared library are `foo.dll`, `foo.dll.lib` and it links for `foo.dll`.
Diffstat (limited to 'xmake/rules/utils')
-rw-r--r--xmake/rules/utils/inherit_links/inherit_links.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/xmake/rules/utils/inherit_links/inherit_links.lua b/xmake/rules/utils/inherit_links/inherit_links.lua
index 8a61a2874..cdac9ace6 100644
--- a/xmake/rules/utils/inherit_links/inherit_links.lua
+++ b/xmake/rules/utils/inherit_links/inherit_links.lua
@@ -91,6 +91,16 @@ function main(target)
-- we need to add includedirs to support import modules for golang
_add_export_value(target, "includedirs", path.directory(targetfile))
end
+
+ if target:rule("rust") then
+ local cratetype = target:values("rust.cratetype")
+ -- only bin, lib, rlib, dylib can make use of --extern CRATE[=PATH]
+ if cratetype ~= "staticlib" and cratetype ~= "cdylib" then
+ local cratename = target:values("rust.cratename") or target:name()
+ local extern_crate_opt = string.format('--extern %s=%s', cratename, target:targetfile())
+ _add_export_value(target, "rcldflags", extern_crate_opt)
+ end
+ end
end
-- we export all links and linkdirs in self/packages/options to the parent target by default