diff options
| author | ruki <[email protected]> | 2020-11-14 17:10:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-11-14 17:10:32 +0800 |
| commit | 76dc49d6ea92fa8d22f24725de7e661f55bce3ca (patch) | |
| tree | 07f553884a5a5d9eaa5746f4ab33403c213aa2c6 /xmake/modules | |
| parent | 5643311ff8d29840261853b4b21c653d169b0b8f (diff) | |
fix dry-run build
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/core/project/depend.lua | 12 | ||||
| -rw-r--r-- | xmake/modules/private/action/build/object.lua | 21 |
2 files changed, 22 insertions, 11 deletions
diff --git a/xmake/modules/core/project/depend.lua b/xmake/modules/core/project/depend.lua index 05065e0b0..f55e0bdfc 100644 --- a/xmake/modules/core/project/depend.lua +++ b/xmake/modules/core/project/depend.lua @@ -150,12 +150,20 @@ end -- -- end, {dependfile = "/xx/xx", -- values = {compinst:program(), compflags}, --- files = {sourcefile, ...}}) +-- files = {sourcefile, ...}, +-- always_changed = false}) -- function on_changed(callback, opt) - -- get files + -- init option opt = opt or {} + + -- always changed? we only do callback directly + if opt.always_changed then + return callback() + end + + -- get files assert(opt.files, "depend.on_changed(): please set files list!") -- get dependfile diff --git a/xmake/modules/private/action/build/object.lua b/xmake/modules/private/action/build/object.lua index 357c58aea..9164ee08c 100644 --- a/xmake/modules/private/action/build/object.lua +++ b/xmake/modules/private/action/build/object.lua @@ -44,11 +44,14 @@ function _do_build_file(target, sourcefile, opt) -- load dependent info local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {}) + -- dry run? + local dryrun = option.get("dry-run") + -- need build this object? -- @note we use mtime(dependfile) instead of mtime(objectfile) to ensure the object file is is fully compiled. -- @see https://github.com/xmake-io/xmake/issues/748 local depvalues = {compinst:program(), compflags} - if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile), values = depvalues}) then + if not dryrun and not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile), values = depvalues}) then return end @@ -68,17 +71,17 @@ function _do_build_file(target, sourcefile, opt) -- show the full link command with raw arguments, it will expand @xxx.args for msvc/link on windows print(compinst:compcmd(sourcefile, objectfile, {compflags = compflags, rawargs = true})) end + if not dryrun then - -- compile it - dependinfo.files = {} - if not option.get("dry-run") then + -- do compile + dependinfo.files = {} assert(compinst:compile(sourcefile, objectfile, {dependinfo = dependinfo, compflags = compflags})) - end - -- update files and values to the dependent file - dependinfo.values = depvalues - table.join2(dependinfo.files, sourcefile, target:pcoutputfile("cxx") or {}, target:pcoutputfile("c")) - depend.save(dependinfo, dependfile) + -- update files and values to the dependent file + dependinfo.values = depvalues + table.join2(dependinfo.files, sourcefile, target:pcoutputfile("cxx") or {}, target:pcoutputfile("c")) + depend.save(dependinfo, dependfile) + end end -- build object |
