summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-02-21 10:57:06 +0800
committerruki <[email protected]>2021-02-21 10:57:06 +0800
commitd1896a73b973a550bf733b4e157b4bf5f9e292c3 (patch)
treee90622253e746aecc68ebee8221b1313b9021a37
parentb3ea3f909db803d7477a22cb914d9e20b4851b6e (diff)
improve qrc rule
-rw-r--r--xmake/rules/qt/qrc/xmake.lua62
1 files changed, 11 insertions, 51 deletions
diff --git a/xmake/rules/qt/qrc/xmake.lua b/xmake/rules/qt/qrc/xmake.lua
index 67d20bfa6..fa5d85743 100644
--- a/xmake/rules/qt/qrc/xmake.lua
+++ b/xmake/rules/qt/qrc/xmake.lua
@@ -39,15 +39,7 @@ rule("qt.qrc")
end)
-- on build file
- on_build_file(function (target, sourcefile_qrc, opt)
-
- -- imports
- import("core.base.option")
- import("core.theme.theme")
- import("core.project.config")
- import("core.project.depend")
- import("core.tool.compiler")
- import("private.utils.progress")
+ on_buildcmd_file(function (target, batchcmds, sourcefile_qrc, opt)
-- get rcc
local rcc = target:data("qt.rcc")
@@ -56,51 +48,19 @@ rule("qt.qrc")
local sourcefile_cpp = path.join(target:autogendir(), "rules", "qt", "qrc", 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
+ local objectfile = target:objectfile(sourcefile_cpp)
table.insert(target:objectfiles(), 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
- progress.show(opt.progress, "${color.build.object}compiling.qt.qrc %s", sourcefile_qrc)
-
- -- ensure the source file directory
- if not os.isdir(sourcefile_dir) then
- os.mkdir(sourcefile_dir)
- end
-
- -- compile qrc
- os.vrunv(rcc, {"-name", path.basename(sourcefile_qrc), sourcefile_qrc, "-o", sourcefile_cpp})
-
- -- trace
- if option.get("verbose") then
- print(compinst:compcmd(sourcefile_cpp, objectfile, {compflags = compflags}))
- end
-
- -- compile c++ source file for qrc
- dependinfo.files = {}
- assert(compinst:compile(sourcefile_cpp, objectfile, {dependinfo = dependinfo, compflags = compflags}))
+ -- add commands
+ batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.qrc %s", sourcefile_qrc)
+ batchcmds:mkdir(sourcefile_dir)
+ batchcmds:vrunv(rcc, {"-name", path.basename(sourcefile_qrc), sourcefile_qrc, "-o", sourcefile_cpp})
+ batchcmds:compile(sourcefile_cpp, objectfile)
- -- update files and values to the dependent file
- dependinfo.values = depvalues
- table.insert(dependinfo.files, sourcefile_qrc)
- depend.save(dependinfo, dependfile)
+ -- add deps
+ batchcmds:add_depfiles(sourcefile_qrc)
+ batchcmds:set_depmtime(os.mtime(objectfile))
+ batchcmds:set_depcache(target:dependfile(objectfile))
end)