summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/projects/rust/static_library/test.lua7
-rw-r--r--xmake/rules/rust/build/target.lua21
2 files changed, 26 insertions, 2 deletions
diff --git a/tests/projects/rust/static_library/test.lua b/tests/projects/rust/static_library/test.lua
index 060aa6ca5..5f1a5d5be 100644
--- a/tests/projects/rust/static_library/test.lua
+++ b/tests/projects/rust/static_library/test.lua
@@ -1,6 +1,13 @@
function main(t)
if is_host("macosx") and os.arch() ~= "arm64" then
t:build()
+ local targetfile = os.files("build/**/release/test")[1]
+ assert(targetfile and os.isfile(targetfile), "target file not found!")
+ local mtime = os.mtime(targetfile)
+ os.sleep(1000)
+ os.touch("src/foo.rs", {mtime = os.time()})
+ t:build()
+ assert(os.mtime(targetfile) > mtime, "target file should be rebuilt after rust dependency changes!")
else
return t:skip("wrong host platform")
end
diff --git a/xmake/rules/rust/build/target.lua b/xmake/rules/rust/build/target.lua
index 6eb5001ff..d7f4d9e26 100644
--- a/xmake/rules/rust/build/target.lua
+++ b/xmake/rules/rust/build/target.lua
@@ -25,6 +25,22 @@ import("core.tool.compiler")
import("core.project.depend")
import("utils.progress")
+-- get dependent target files
+function _get_target_depfiles(target)
+ local depfiles = {}
+ for _, dep in ipairs(target:orderdeps()) do
+ if dep:is_static() or dep:is_shared() then
+ table.insert(depfiles, dep:targetfile())
+ end
+ end
+ local linkdepfiles = target:data("linkdepfiles")
+ if linkdepfiles then
+ table.join2(depfiles, linkdepfiles)
+ end
+ table.sort(depfiles)
+ return depfiles
+end
+
-- build the source files
function build_sourcefiles(target, sourcebatch, opt)
@@ -49,7 +65,8 @@ function build_sourcefiles(target, sourcebatch, opt)
-- need build this object?
local depvalues = {compinst:program(), compflags}
- if not depend.is_changed(dependinfo, {lastmtime = os.mtime(targetfile), values = depvalues}) then
+ local depfiles = table.join(table.clone(sourcefiles), _get_target_depfiles(target))
+ if not depend.is_changed(dependinfo, {lastmtime = os.mtime(targetfile), values = depvalues, files = depfiles}) then
return
end
@@ -68,7 +85,7 @@ function build_sourcefiles(target, sourcebatch, opt)
-- update files and values to the dependent file
dependinfo.values = depvalues
- table.join2(dependinfo.files, sourcefiles)
+ table.join2(dependinfo.files, depfiles)
depend.save(dependinfo, dependfile)
end