summaryrefslogtreecommitdiff
path: root/xmake/rules
diff options
context:
space:
mode:
authorIMXEren <[email protected]>2025-07-06 23:14:48 +0530
committerIMXEren <[email protected]>2025-07-06 23:14:48 +0530
commitfe3a4b2a9fa7e75a5ba760401e19b312028d27ee (patch)
tree3a415306885e1fdcd4cc0b6470acb04b81d477f8 /xmake/rules
parent77ac26ceefd28ce8091a65e3f6ff19d51bed8bab (diff)
refactor: simplify rust shared lib template and use rule to add libstd in env
Diffstat (limited to 'xmake/rules')
-rw-r--r--xmake/rules/rust/xmake.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/xmake/rules/rust/xmake.lua b/xmake/rules/rust/xmake.lua
index 56d54fb38..8f62392b9 100644
--- a/xmake/rules/rust/xmake.lua
+++ b/xmake/rules/rust/xmake.lua
@@ -97,6 +97,18 @@ rule("rust.build")
end)
on_build("build.target")
+ before_run(function (target)
+ import("lib.detect.find_tool")
+
+ -- Make sure libstd shared library is available
+ local rc = find_tool("rustc")
+ assert(rc, "rustc not found. Failed to add libstd in env")
+ local outdata, errdata = os.iorunv(rc.program, {"--print=sysroot"})
+ assert(not errdata or errdata == "", "failed to find rust sysroot:\n" .. errdata)
+ local libstd = path.join(outdata:trim(), "bin")
+ os.addenvs({PATH = libstd, LD_LIBRARY_PATH = libstd, DYLD_LIBRARY_PATH = libstd})
+ end)
+
rule("rust")
add_deps("rust.build")
add_deps("utils.inherit.links")