summaryrefslogtreecommitdiff
path: root/xmake/rules
diff options
context:
space:
mode:
authorruki <[email protected]>2018-05-08 22:52:49 +0800
committerruki <[email protected]>2018-05-08 11:16:55 +0800
commitb5333b27b79f7cabbdc8d75356b2de118f9ea744 (patch)
treef4cb719e259ae64b6a48ab35a425eb0db76cd3ab /xmake/rules
parentc61545b0275b64c8b0294ce69e635e30475a2239 (diff)
improve build deps
Diffstat (limited to 'xmake/rules')
-rw-r--r--xmake/rules/qt/xmake.lua33
1 files changed, 28 insertions, 5 deletions
diff --git a/xmake/rules/qt/xmake.lua b/xmake/rules/qt/xmake.lua
index abd4e9667..b8e7ec3c5 100644
--- a/xmake/rules/qt/xmake.lua
+++ b/xmake/rules/qt/xmake.lua
@@ -123,29 +123,52 @@ rule("qt.moc")
import("core.base.option")
import("core.project.config")
import("core.tool.compiler")
+ import("core.project.depend")
-- get c++ source file for moc
local sourcefile_moc = path.join(config.buildir(), ".qt", "moc", target:name(), "moc_" .. path.basename(headerfile_moc) .. ".cpp")
- -- generate c++ source file for moc
- moc.generate(target, headerfile_moc, sourcefile_moc)
-
-- get object file
local objectfile = target:objectfile(sourcefile_moc)
+ -- load compiler
+ local compinst = compiler.load("cxx", {target = target})
+
+ -- get compile flags
+ local compflags = compinst:compflags({target = target, sourcefile = sourcefile_moc})
+
+ -- load dependent info
+ local dependfile = target:dependfile(objectfile)
+ local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+
+ -- need build this object?
+ local depvalues = {compinst:program(), compflags}
+ if not depend.is_changed(dependinfo, {lastmtime = os.mtime(objectfile), values = depvalues}) then
+ return
+ end
+
+ -- generate c++ source file for moc
+ moc.generate(target, headerfile_moc, sourcefile_moc)
+
-- trace
if option.get("verbose") then
- print(compiler.compcmd(sourcefile_moc, objectfile, {target = target}))
+ print(compinst:compcmd(sourcefile_moc, objectfile, {compflags = compflags}))
end
-- compile c++ source file for moc
- compiler.compile(sourcefile_moc, objectfile, {target = target})
+ dependinfo.files = {}
+ compinst:compile(sourcefile_moc, objectfile, {dependinfo = dependinfo, compflags = compflags})
-- add objectfile
table.insert(target:objectfiles(), objectfile)
-- add clean files
target:data_add("qt.cleanfiles", {sourcefile_moc, objectfile})
+
+ -- update files and values to the dependent file
+ dependinfo.values = depvalues
+ table.insert(dependinfo.files, headerfile_moc)
+ depend.save(dependinfo, dependfile)
end)
-- define rule: *.qrc