summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-05-09 00:40:34 +0800
committerruki <[email protected]>2018-05-08 22:03:26 +0800
commitb9b5248e49194343fb1807f865770db8b79d5853 (patch)
treeeb17034b8ab4148ad5fcd09e508d60698f99e5a5
parent87a3262733fb60ab6262893d55ca4b5d0e1b516c (diff)
add build deps for qt.qrc
-rw-r--r--xmake/rules/qt/xmake.lua54
1 files changed, 43 insertions, 11 deletions
diff --git a/xmake/rules/qt/xmake.lua b/xmake/rules/qt/xmake.lua
index fbc147203..5f5b43520 100644
--- a/xmake/rules/qt/xmake.lua
+++ b/xmake/rules/qt/xmake.lua
@@ -221,11 +221,12 @@ rule("qt.qrc")
end)
-- on build file
- on_build_file(function (target, sourcefile_qrc)
+ on_build_file(function (target, sourcefile_qrc, opt)
-- imports
import("core.base.option")
import("core.project.config")
+ import("core.project.depend")
import("core.tool.compiler")
-- get rcc
@@ -234,6 +235,40 @@ rule("qt.qrc")
-- get c++ source file for qrc
local sourcefile_cpp = path.join(config.buildir(), ".qt", "qrc", target:name(), path.basename(sourcefile_qrc) .. ".cpp")
local sourcefile_dir = path.directory(sourcefile_cpp)
+
+ -- get object file
+ local objectfile = target:objectfile(sourcefile_cpp)
+
+ -- load compiler
+ local compinst = compiler.load("cxx", {target = target})
+
+ -- get compile flags
+ local compflags = compinst:compflags({target = target, sourcefile = sourcefile_cpp})
+
+ -- add objectfile
+ table.insert(target:objectfiles(), objectfile)
+
+ -- add clean files
+ target:data_add("qt.cleanfiles", {sourcefile_cpp, objectfile})
+
+ -- 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
+
+ -- trace progress info
+ if option.get("verbose") then
+ cprint("${green}[%02d%%]:${dim} compiling.qt.qrc %s", opt.progress, sourcefile_qrc)
+ else
+ cprint("${green}[%02d%%]:${clear} compiling.qt.qrc %s", opt.progress, sourcefile_qrc)
+ end
+
+ -- ensure the source file directory
if not os.isdir(sourcefile_dir) then
os.mkdir(sourcefile_dir)
end
@@ -241,22 +276,19 @@ rule("qt.qrc")
-- compile qrc
os.vrunv(rcc, {"-name", "qml", sourcefile_qrc, "-o", sourcefile_cpp})
- -- get object file
- local objectfile = target:objectfile(sourcefile_cpp)
-
-- trace
if option.get("verbose") then
- print(compiler.compcmd(sourcefile_cpp, objectfile, {target = target}))
+ print(compinst:compcmd(sourcefile_cpp, objectfile, {compflags = compflags}))
end
-- compile c++ source file for qrc
- compiler.compile(sourcefile_cpp, objectfile, {target = target})
-
- -- add objectfile
- table.insert(target:objectfiles(), objectfile)
+ dependinfo.files = {}
+ compinst:compile(sourcefile_cpp, objectfile, {dependinfo = dependinfo, compflags = compflags})
- -- add clean files
- target:data_add("qt.cleanfiles", {sourcefile_cpp, objectfile})
+ -- update files and values to the dependent file
+ dependinfo.values = depvalues
+ table.insert(dependinfo.files, sourcefile_qrc)
+ depend.save(dependinfo, dependfile)
end)
-- define rule: qt static library