summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-01 09:40:50 +0800
committerGitHub <[email protected]>2023-09-01 09:40:50 +0800
commit2df911b8d9f35d293d6215a52dd77522078016af (patch)
tree8230bc3f1b7c156f4b7c9a0f6baaf5448862f873
parent515dbd9e94793b0bd126a19ecc8f482752897ed9 (diff)
parentdcc5abf105e7df9d47e37e18191bef2503edb085 (diff)
Merge pull request #4159 from xmake-io/rebuild
improve to rebuild target #4154
-rw-r--r--xmake/actions/build/build.lua22
-rw-r--r--xmake/actions/build/kinds/binary.lua11
-rw-r--r--xmake/actions/build/kinds/object.lua4
-rw-r--r--xmake/actions/build/kinds/shared.lua11
-rw-r--r--xmake/actions/build/kinds/static.lua11
-rw-r--r--xmake/actions/build/xmake.lua1
-rw-r--r--xmake/actions/config/configfiles.lua2
-rw-r--r--xmake/core/project/target.lua5
-rw-r--r--xmake/modules/core/project/depend.lua10
-rw-r--r--xmake/modules/private/action/build/object.lua2
-rw-r--r--xmake/modules/private/utils/batchcmds.lua42
-rw-r--r--xmake/rules/c++/modules/modules_support/clang.lua11
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc.lua10
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc.lua10
-rw-r--r--xmake/rules/c++/unity_build/unity_build.lua2
-rw-r--r--xmake/rules/c51/xmake.lua2
-rw-r--r--xmake/rules/cuda/devlink/devlink.lua5
-rw-r--r--xmake/rules/platform/linux/driver/driver_modules.lua2
-rw-r--r--xmake/rules/protobuf/module_parser.lua2
-rw-r--r--xmake/rules/protobuf/proto.lua6
-rw-r--r--xmake/rules/qt/deploy/android.lua2
-rw-r--r--xmake/rules/qt/deploy/macosx.lua2
-rw-r--r--xmake/rules/utils/merge_archive/xmake.lua2
-rw-r--r--xmake/rules/utils/merge_object/xmake.lua2
-rw-r--r--xmake/rules/utils/symbols/export_all/export_all.lua4
-rw-r--r--xmake/rules/utils/symbols/extract/xmake.lua2
-rw-r--r--xmake/rules/verilator/verilator.lua1
-rw-r--r--xmake/rules/wdk/inf/xmake.lua2
-rw-r--r--xmake/rules/wdk/man/xmake.lua2
-rw-r--r--xmake/rules/wdk/mc/xmake.lua2
-rw-r--r--xmake/rules/wdk/mof/xmake.lua2
-rw-r--r--xmake/rules/wdk/sign/xmake.lua2
-rw-r--r--xmake/rules/wdk/tracewpp/xmake.lua2
-rw-r--r--xmake/rules/xcode/application/build.lua2
-rw-r--r--xmake/rules/xcode/bundle/xmake.lua2
-rw-r--r--xmake/rules/xcode/framework/xmake.lua2
-rw-r--r--xmake/rules/xcode/info_plist/xmake.lua2
-rw-r--r--xmake/rules/xcode/storyboard/xmake.lua2
-rw-r--r--xmake/rules/xcode/xcassets/xmake.lua2
39 files changed, 120 insertions, 90 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua
index 69b1de5da..4e095a27d 100644
--- a/xmake/actions/build/build.lua
+++ b/xmake/actions/build/build.lua
@@ -58,7 +58,7 @@ function _add_batchjobs_builtin(batchjobs, rootjob, target)
job = batchjobs:addjob("rule/" .. r:name() .. "/build", function (index, total)
local batchcmds_ = batchcmds.new({target = target})
buildcmd(target, batchcmds_, {progress = (index * 100) / total})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end, {rootjob = job or rootjob})
end
end
@@ -135,7 +135,7 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target)
if after_buildcmd then
local batchcmds_ = batchcmds.new({target = target})
after_buildcmd(target, batchcmds_, {progress = progress})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end
end
end
@@ -178,7 +178,7 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target)
end
-- clean target if rebuild
- if option.get("rebuild") and not option.get("dry-run") then
+ if target:is_rebuilt() and not option.get("dry-run") then
_clean_target(target)
end
@@ -198,7 +198,7 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target)
if before_buildcmd then
local batchcmds_ = batchcmds.new({target = target})
before_buildcmd(target, batchcmds_, {progress = progress})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end
end
end
@@ -234,7 +234,16 @@ function get_batchjobs(targetname, group_pattern)
-- get root targets
local targets_root = {}
if targetname then
- table.insert(targets_root, project.target(targetname))
+ local target = project.target(targetname)
+ table.insert(targets_root, target)
+ if option.get("rebuild") then
+ target:data_set("rebuilt", true)
+ if not option.get("shallow") then
+ for _, dep in ipairs(target:orderdeps()) do
+ dep:data_set("rebuilt", true)
+ end
+ end
+ end
else
local depset = hashset.new()
local targets = {}
@@ -253,6 +262,9 @@ function get_batchjobs(targetname, group_pattern)
if not depset:has(target:name()) then
table.insert(targets_root, target)
end
+ if option.get("rebuild") then
+ target:data_set("rebuilt", true)
+ end
end
end
diff --git a/xmake/actions/build/kinds/binary.lua b/xmake/actions/build/kinds/binary.lua
index 55454f262..dd14d5c95 100644
--- a/xmake/actions/build/kinds/binary.lua
+++ b/xmake/actions/build/kinds/binary.lua
@@ -74,7 +74,10 @@ function _do_link_target(target, opt)
assert(linkinst:link(objectfiles, targetfile, {linkflags = linkflags}))
end
- end, {dependfile = target:dependfile(), lastmtime = os.mtime(target:targetfile()), values = depvalues, files = depfiles, always_changed = dryrun})
+ end, {dependfile = target:dependfile(),
+ lastmtime = os.mtime(target:targetfile()),
+ changed = target:is_rebuilt(),
+ values = depvalues, files = depfiles, dryrun = dryrun})
end
-- on link the given target
@@ -92,7 +95,7 @@ function _on_link_target(target, opt)
if on_linkcmd then
local batchcmds_ = batchcmds.new({target = target})
on_linkcmd(target, batchcmds_, {progress = opt.progress})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
done = true
end
end
@@ -121,7 +124,7 @@ function _link_target(target, opt)
if before_linkcmd then
local batchcmds_ = batchcmds.new({target = target})
before_linkcmd(target, batchcmds_, {progress = opt.progress})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end
end
@@ -144,7 +147,7 @@ function _link_target(target, opt)
if after_linkcmd then
local batchcmds_ = batchcmds.new({target = target})
after_linkcmd(target, batchcmds_, {progress = opt.progress})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end
end
end
diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua
index 35ae830b2..569e8a7aa 100644
--- a/xmake/actions/build/kinds/object.lua
+++ b/xmake/actions/build/kinds/object.lua
@@ -129,7 +129,7 @@ function _add_batchjobs_for_rule(batchjobs, rootjob, target, sourcebatch, suffix
local batchcmds_ = batchcmds.new({target = target})
local distcc = ruleinst:extraconf(scriptname, "distcc")
script(target, batchcmds_, sourcebatch, {progress = (index * 100) / total, distcc = distcc})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end, {rootjob = rootjob})
end
end
@@ -144,7 +144,7 @@ function _add_batchjobs_for_rule(batchjobs, rootjob, target, sourcebatch, suffix
batchjobs:addjob(sourcefile, function (index, total)
local batchcmds_ = batchcmds.new({target = target})
script(target, batchcmds_, sourcefile, {sourcekind = sourcekind, progress = (index * 100) / total})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end, {rootjob = rootjob, distcc = ruleinst:extraconf(scriptname, "distcc")})
end
end
diff --git a/xmake/actions/build/kinds/shared.lua b/xmake/actions/build/kinds/shared.lua
index 4363d1901..f4763c608 100644
--- a/xmake/actions/build/kinds/shared.lua
+++ b/xmake/actions/build/kinds/shared.lua
@@ -74,7 +74,10 @@ function _do_link_target(target, opt)
assert(linkinst:link(objectfiles, targetfile, {linkflags = linkflags}))
end
- end, {dependfile = target:dependfile(), lastmtime = os.mtime(target:targetfile()), values = depvalues, files = depfiles, always_changed = dryrun})
+ end, {dependfile = target:dependfile(),
+ lastmtime = os.mtime(target:targetfile()),
+ changed = target:is_rebuilt(),
+ values = depvalues, files = depfiles, dryrun = dryrun})
end
-- on link the given target
@@ -92,7 +95,7 @@ function _on_link_target(target, opt)
if on_linkcmd then
local batchcmds_ = batchcmds.new({target = target})
on_linkcmd(target, batchcmds_, {progress = opt.progress})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
done = true
end
end
@@ -121,7 +124,7 @@ function _link_target(target, opt)
if before_linkcmd then
local batchcmds_ = batchcmds.new({target = target})
before_linkcmd(target, batchcmds_, {progress = opt.progress})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end
end
@@ -144,7 +147,7 @@ function _link_target(target, opt)
if after_linkcmd then
local batchcmds_ = batchcmds.new({target = target})
after_linkcmd(target, batchcmds_, {progress = opt.progress})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end
end
end
diff --git a/xmake/actions/build/kinds/static.lua b/xmake/actions/build/kinds/static.lua
index 9d9ffdaf9..0d75b58c6 100644
--- a/xmake/actions/build/kinds/static.lua
+++ b/xmake/actions/build/kinds/static.lua
@@ -74,7 +74,10 @@ function _do_link_target(target, opt)
assert(linkinst:link(objectfiles, targetfile, {linkflags = linkflags}))
end
- end, {dependfile = target:dependfile(), lastmtime = os.mtime(target:targetfile()), values = depvalues, files = depfiles, always_changed = dryrun})
+ end, {dependfile = target:dependfile(),
+ lastmtime = os.mtime(target:targetfile()),
+ changed = target:is_rebuilt(),
+ values = depvalues, files = depfiles, dryrun = dryrun})
end
-- on link the given target
@@ -92,7 +95,7 @@ function _on_link_target(target, opt)
if on_linkcmd then
local batchcmds_ = batchcmds.new({target = target})
on_linkcmd(target, batchcmds_, {progress = opt.progress})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
done = true
end
end
@@ -121,7 +124,7 @@ function _link_target(target, opt)
if before_linkcmd then
local batchcmds_ = batchcmds.new({target = target})
before_linkcmd(target, batchcmds_, {progress = opt.progress})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end
end
@@ -144,7 +147,7 @@ function _link_target(target, opt)
if after_linkcmd then
local batchcmds_ = batchcmds.new({target = target})
after_linkcmd(target, batchcmds_, {progress = opt.progress})
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end
end
end
diff --git a/xmake/actions/build/xmake.lua b/xmake/actions/build/xmake.lua
index 8c039bdca..6f54fb69e 100644
--- a/xmake/actions/build/xmake.lua
+++ b/xmake/actions/build/xmake.lua
@@ -30,6 +30,7 @@ task("build")
{'b', "build", "k", nil , "Build target. This is default building mode and optional." }
, {'r', "rebuild", "k", nil , "Rebuild the target." }
, {'a', "all", "k", nil , "Build all targets." }
+ , {nil, "shallow", "k", nil , "Only re-build the given targets without dependencies." }
, {'g', "group", "kv", nil , "Build all targets of the given group. It support path pattern matching.",
"e.g.",
" xmake -g test",
diff --git a/xmake/actions/config/configfiles.lua b/xmake/actions/config/configfiles.lua
index 1cf49881a..2b30f53af 100644
--- a/xmake/actions/config/configfiles.lua
+++ b/xmake/actions/config/configfiles.lua
@@ -328,7 +328,7 @@ function main(opt)
end, {files = srcinfo.srcfile,
lastmtime = os.mtime(dstfile),
dependfile = srcinfo.dependfile,
- always_changed = opt.force})
+ changed = opt.force})
end
-- leave project directory
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index a537b5986..491c00729 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -878,6 +878,11 @@ function _instance:is_enabled()
return self:get("enabled") ~= false
end
+-- is rebuilt?
+function _instance:is_rebuilt()
+ return self:data("rebuilt")
+end
+
-- get the enabled option
function _instance:opt(name)
return self:opts()[name]
diff --git a/xmake/modules/core/project/depend.lua b/xmake/modules/core/project/depend.lua
index 9f386c8f1..c66830521 100644
--- a/xmake/modules/core/project/depend.lua
+++ b/xmake/modules/core/project/depend.lua
@@ -157,16 +157,15 @@ end
--
-- end, {dependfile = "/xx/xx",
-- values = {compinst:program(), compflags},
--- files = {sourcefile, ...},
--- always_changed = false})
+-- files = {sourcefile, ...}})
--
function on_changed(callback, opt)
-- init option
opt = opt or {}
- -- always changed? we only do callback directly
- if opt.always_changed then
+ -- dry run? we only do callback directly and do not change any status
+ if opt.dryrun then
return callback()
end
@@ -180,9 +179,8 @@ function on_changed(callback, opt)
end
-- load dependent info
- local dependinfo = option.get("rebuild") and {} or (load(dependfile) or {})
+ local dependinfo = opt.changed and {} or (load(dependfile) or {})
- -- 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
if not is_changed(dependinfo, {lastmtime = opt.lastmtime or os.mtime(dependfile), values = opt.values, files = opt.files}) then
diff --git a/xmake/modules/private/action/build/object.lua b/xmake/modules/private/action/build/object.lua
index 6668d9695..5b8188d49 100644
--- a/xmake/modules/private/action/build/object.lua
+++ b/xmake/modules/private/action/build/object.lua
@@ -43,7 +43,7 @@ function _do_build_file(target, sourcefile, opt)
local compflags = compinst:compflags({target = target, sourcefile = sourcefile, configs = opt.configs})
-- load dependent info
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
-- dry run?
local dryrun = option.get("dry-run")
diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua
index 48d169b22..6edd1d8f3 100644
--- a/xmake/modules/private/utils/batchcmds.lua
+++ b/xmake/modules/private/utils/batchcmds.lua
@@ -31,7 +31,7 @@ import("core.language.language")
import("utils.progress", {alias = "progress_utils"})
-- define module
-local batchcmds = batchcmds or object { _init = {"_TARGET", "_CMDS", "_DEPS", "_tip"}}
+local batchcmds = batchcmds or object { _init = {"_TARGET", "_CMDS", "_DEPINFO", "_tip"}}
-- show text
function _show(showtext, progress)
@@ -372,39 +372,39 @@ function batchcmds:show_progress(progress, format, ...)
end
end
--- get deps
-function batchcmds:deps()
- return self._DEPS
+-- get depinfo
+function batchcmds:depinfo()
+ return self._DEPINFO
end
-- add dependent files
function batchcmds:add_depfiles(...)
- local deps = self._DEPS or {}
- deps.files = deps.files or {}
- table.join2(deps.files, ...)
- self._DEPS = deps
+ local depinfo = self._DEPINFO or {}
+ depinfo.files = depinfo.files or {}
+ table.join2(depinfo.files, ...)
+ self._DEPINFO = depinfo
end
-- add dependent values
function batchcmds:add_depvalues(...)
- local deps = self._DEPS or {}
- deps.values = deps.values or {}
- table.join2(deps.values, ...)
- self._DEPS = deps
+ local depinfo = self._DEPINFO or {}
+ depinfo.values = depinfo.values or {}
+ table.join2(depinfo.values, ...)
+ self._DEPINFO = depinfo
end
-- set the last mtime of dependent files and values
function batchcmds:set_depmtime(lastmtime)
- local deps = self._DEPS or {}
- deps.lastmtime = lastmtime
- self._DEPS = deps
+ local depinfo = self._DEPINFO or {}
+ depinfo.lastmtime = lastmtime
+ self._DEPINFO = depinfo
end
-- set cache file of depend info
function batchcmds:set_depcache(cachefile)
- local deps = self._DEPS or {}
- deps.dependfile = cachefile
- self._DEPS = deps
+ local depinfo = self._DEPINFO or {}
+ depinfo.dependfile = cachefile
+ self._DEPINFO = depinfo
end
-- run cmds
@@ -413,11 +413,11 @@ function batchcmds:runcmds(opt)
if self:empty() then
return
end
- local deps = self:deps()
- if deps and deps.files then
+ local depinfo = self:depinfo()
+ if depinfo and depinfo.files then
depend.on_changed(function ()
_runcmds(self:cmds(), opt)
- end, self:deps())
+ end, table.join(depinfo, {dryrun = opt.dryrun, changed = opt.changed}))
else
_runcmds(self:cmds(), opt)
end
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua
index 9f7e2225d..8cf54c883 100644
--- a/xmake/rules/c++/modules/modules_support/clang.lua
+++ b/xmake/rules/c++/modules/modules_support/clang.lua
@@ -247,7 +247,7 @@ function _build_modulefile(target, sourcefile, opt)
local dependfile = opt.dependfile
local compinst = compiler.load("cxx", {target = target})
local compflags = compinst:compflags({sourcefile = sourcefile, target = target})
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
-- need build this object?
local dryrun = option.get("dry-run")
@@ -411,7 +411,7 @@ function generate_dependencies(target, sourcebatch, opt)
end
return {moduleinfo = rawdependinfo}
- end, {dependfile = dependfile, files = {sourcefile}})
+ end, {dependfile = dependfile, files = {sourcefile}, changed = target:is_rebuilt()})
end
return changed
end
@@ -442,7 +442,8 @@ function generate_stl_headerunits_for_batchjobs(target, batchjobs, headerunits,
os.vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args))
end
- end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}})
+ end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}, changed = target:is_rebuilt()})
+
-- libc++ have a builtin module mapper
if not _use_stdlib(target, "libc++") then
_add_module_to_mapper(target, headerunit.name, bmifile)
@@ -523,7 +524,7 @@ function generate_user_headerunits_for_batchjobs(target, batchjobs, headerunits,
end
os.vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args))
- end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}})
+ end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}, changed = target:is_rebuilt()})
_add_module_to_mapper(target, headerunit.name, bmifile)
end, {rootjob = flushjob})
end
@@ -614,7 +615,7 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op
progress.show(opt.progress, "${color.build.object}generating.module.metadata %s", name)
local metadata = common.generate_meta_module_info(target, name, cppfile, module.requires)
json.savefile(metafilepath, metadata)
- end, {dependfile = target:dependfile(metafilepath), files = {cppfile}})
+ end, {dependfile = target:dependfile(metafilepath), files = {cppfile}, changed = target:is_rebuilt()})
end, {rootjob = flushjob})
end
end
diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua
index 20b783821..4fa92e4df 100644
--- a/xmake/rules/c++/modules/modules_support/gcc.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc.lua
@@ -123,7 +123,7 @@ function _build_modulefile(target, sourcefile, opt)
local dependfile = opt.dependfile
local compinst = compiler.load("cxx", {target = target})
local compflags = table.join("-x", "c++", compinst:compflags({sourcefile = sourcefile, target = target}))
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
-- need build this object?
local dryrun = option.get("dry-run")
@@ -219,7 +219,7 @@ function generate_dependencies(target, sourcebatch, opt)
local dependinfo = io.readfile(jsonfile)
return { moduleinfo = dependinfo }
- end, {dependfile = dependfile, files = {sourcefile}})
+ end, {dependfile = dependfile, files = {sourcefile}, changed = target:is_rebuilt()})
end
return changed
end
@@ -255,7 +255,7 @@ function generate_stl_headerunits_for_batchjobs(target, batchjobs, headerunits,
os.vrunv(compinst:program(), flags)
_add_module_to_mapper(mapper_file, headerunit.path, path.absolute(bmifile, projectdir))
os.tryrm(mapper_file_tmp)
- end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}})
+ end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}, changed = target:is_rebuilt()})
end, {rootjob = opt.rootjob})
else
_add_module_to_mapper(mapper_file, headerunit.path, path.absolute(bmifile, projectdir))
@@ -331,7 +331,7 @@ function generate_user_headerunits_for_batchjobs(target, batchjobs, headerunits,
end
os.vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args))
- end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}})
+ end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}, changed = target:is_rebuilt()})
end, {rootjob = opt.rootjob})
_add_module_to_mapper(mapper_file, headerunit_path, path.absolute(bmifile, projectdir))
end
@@ -421,7 +421,7 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op
progress.show((index * 100) / total, "${color.build.object}generating.module.metadata %s", name)
local metadata = common.generate_meta_module_info(target, name, cppfile, module.requires)
json.savefile(metafilepath, metadata)
- end, {dependfile = target:dependfile(metafilepath), files = {cppfile}})
+ end, {dependfile = target:dependfile(metafilepath), files = {cppfile}, changed = target:is_rebuilt()})
end, {rootjob = opt.rootjob})
end
end
diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua
index 0372ca997..0643117d0 100644
--- a/xmake/rules/c++/modules/modules_support/msvc.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc.lua
@@ -100,7 +100,7 @@ function _build_modulefile(target, sourcefile, opt)
local dependfile = opt.dependfile
local compinst = compiler.load("cxx", {target = target})
local compflags = compinst:compflags({sourcefile = sourcefile, target = target})
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
-- need build this object?
local dryrun = option.get("dry-run")
@@ -216,7 +216,7 @@ function generate_dependencies(target, sourcebatch, opt)
local dependinfo = io.readfile(jsonfile)
return { moduleinfo = dependinfo }
- end, {dependfile = dependfile, files = {sourcefile}})
+ end, {dependfile = dependfile, files = {sourcefile}, changed = target:is_rebuilt()})
end
return changed
end
@@ -274,7 +274,7 @@ function generate_stl_headerunits_for_batchjobs(target, batchjobs, headerunits,
}
generate_headerunit_for_batchjob(target, headerunit.name, flags, objectfile, index, total)
- end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}})
+ end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}, changed = target:is_rebuilt()})
_add_module_to_mapper(target, headerunitflag .. ":angle", headerunit.name, headerunit.name, objectfile, bmifile)
end, {rootjob = flushjob})
end
@@ -351,7 +351,7 @@ function generate_user_headerunits_for_batchjobs(target, batchjobs, headerunits,
"/Fo" .. objectfile
}
generate_headerunit_for_batchjob(target, headerunit.name, flags, objectfile, index, total)
- end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}})
+ end, {dependfile = target:dependfile(bmifile), files = {headerunit.path}, changed = target:is_rebuilt()})
_add_module_to_mapper(target, headerunitflag, headerunit.name, headerunit.path, objectfile, bmifile)
end, {rootjob = flushjob})
end
@@ -454,7 +454,7 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op
progress.show((index * 100) / total, "${color.build.object}generating.module.metadata %s", name)
local metadata = common.generate_meta_module_info(target, name, cppfile, module.requires)
json.savefile(metafilepath, metadata)
- end, {dependfile = target:dependfile(metafilepath), files = {cppfile}})
+ end, {dependfile = target:dependfile(metafilepath), files = {cppfile}, changed = target:is_rebuilt()})
end, {rootjob = flushjob})
end
end
diff --git a/xmake/rules/c++/unity_build/unity_build.lua b/xmake/rules/c++/unity_build/unity_build.lua
index ad93753c0..a6059fec0 100644
--- a/xmake/rules/c++/unity_build/unity_build.lua
+++ b/xmake/rules/c++/unity_build/unity_build.lua
@@ -45,7 +45,7 @@ function _merge_unityfile(target, sourcefile_unity, sourcefiles, opt)
end
unityfile:close()
- end, {dependfile = dependfile, files = sourcefiles})
+ end, {dependfile = dependfile, files = sourcefiles, changed = target:is_rebuilt()})
end
function generate_unityfiles(target, sourcebatch, opt)
diff --git a/xmake/rules/c51/xmake.lua b/xmake/rules/c51/xmake.lua
index da12b0922..bf6c7efde 100644
--- a/xmake/rules/c51/xmake.lua
+++ b/xmake/rules/c51/xmake.lua
@@ -39,5 +39,5 @@ rule("c51.binary")
local oh = assert(find_tool("oh51"), "oh51 not found")
os.iorunv(oh.program, {target:targetfile()})
progress.show(opt.progress, "${color.build.target}generating.$(mode) %s", target:targetfile() .. ".hex")
- end, {files = {target:targetfile()}})
+ end, {files = {target:targetfile()}, changed = target:is_rebuilt()})
end)
diff --git a/xmake/rules/cuda/devlink/devlink.lua b/xmake/rules/cuda/devlink/devlink.lua
index 9b76c9775..c849f28e5 100644
--- a/xmake/rules/cuda/devlink/devlink.lua
+++ b/xmake/rules/cuda/devlink/devlink.lua
@@ -107,5 +107,8 @@ function main(target, opt)
assert(linkinst:link(objectfiles, targetfile, {linkflags = linkflags}))
end
- end, {dependfile = target:dependfile(targetfile), lastmtime = os.mtime(targetfile), values = depvalues, files = depfiles, always_changed = dryrun})
+ end, {dependfile = target:dependfile(targetfile),
+ lastmtime = os.mtime(targetfile),
+ changed = target:is_rebuilt(),
+ values = depvalues, files = depfiles, dryrun = dryrun})
end
diff --git a/xmake/rules/platform/linux/driver/driver_modules.lua b/xmake/rules/platform/linux/driver/driver_modules.lua
index 67fbb8d22..845404504 100644
--- a/xmake/rules/platform/linux/driver/driver_modules.lua
+++ b/xmake/rules/platform/linux/driver/driver_modules.lua
@@ -307,7 +307,7 @@ function link(target, opt)
os.mkdir(path.directory(targetfile))
os.vrunv(ld, argv)
- end, {dependfile = dependfile, lastmtime = os.mtime(target:targetfile()), files = objectfiles})
+ end, {dependfile = dependfile, lastmtime = os.mtime(target:targetfile()), files = objectfiles, changed = target:is_rebuilt()})
end
function install(target)
diff --git a/xmake/rules/protobuf/module_parser.lua b/xmake/rules/protobuf/module_parser.lua
index 163d36df2..80314c50a 100644
--- a/xmake/rules/protobuf/module_parser.lua
+++ b/xmake/rules/protobuf/module_parser.lua
@@ -70,7 +70,7 @@ function _generate_moduledeps(target, sourcefile, opt)
return dependinfo
end
- end, {dependfile = dependfile, files = {sourcefile}})
+ end, {dependfile = dependfile, files = {sourcefile}, changed = target:is_rebuilt()})
end
-- build batch jobs with deps
diff --git a/xmake/rules/protobuf/proto.lua b/xmake/rules/protobuf/proto.lua
index f426be350..d702bc255 100644
--- a/xmake/rules/protobuf/proto.lua
+++ b/xmake/rules/protobuf/proto.lua
@@ -141,7 +141,7 @@ function buildcmd(target, batchcmds, sourcefile_proto, opt, sourcekind)
path(prefixdir and prefixdir or path.directory(sourcefile_proto), function (p) return "-I" .. p end),
path(sourcefile_dir, function (p) return (sourcekind == "cxx" and "--cpp_out=" or "--c_out=") .. p end)
}
-
+
if grpc_cpp_plugin then
table.insert(protoc_args, "--plugin=protoc-gen-grpc=" .. grpc_cpp_plugin_bin)
table.insert(protoc_args, path(sourcefile_dir, function (p) return ("--grpc_out=") .. p end))
@@ -155,7 +155,7 @@ function buildcmd(target, batchcmds, sourcefile_proto, opt, sourcekind)
if grpc_cpp_plugin then
batchcmds:compile(sourcefile_cx_grpc, objectfile_grpc, {configs = {includedirs = sourcefile_dir}})
end
-
+
-- add deps
local depmtime = os.mtime(objectfile)
batchcmds:add_depfiles(sourcefile_proto)
@@ -194,7 +194,7 @@ function build_batchjobs(target, batchjobs, sourcebatch, opt, sourcekind)
moduleinfo.job = batchjobs:newjob(sourcefile, function (index, total)
local batchcmds_ = batchcmds.new({target = target})
buildcmd(target, batchcmds_, sourcefile, {progress = (index * 100) / total}, sourcekind)
- batchcmds_:runcmds({dryrun = option.get("dry-run")})
+ batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
end)
end
diff --git a/xmake/rules/qt/deploy/android.lua b/xmake/rules/qt/deploy/android.lua
index 5aea7fa02..9299c61e0 100644
--- a/xmake/rules/qt/deploy/android.lua
+++ b/xmake/rules/qt/deploy/android.lua
@@ -45,7 +45,7 @@ function main(target, opt)
-- need re-generate this apk?
local targetfile = target:targetfile()
local dependfile = target:dependfile(target_apk)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end
diff --git a/xmake/rules/qt/deploy/macosx.lua b/xmake/rules/qt/deploy/macosx.lua
index 5abbe4263..7cc056099 100644
--- a/xmake/rules/qt/deploy/macosx.lua
+++ b/xmake/rules/qt/deploy/macosx.lua
@@ -79,7 +79,7 @@ function main(target, opt)
local target_app = path.join(target:targetdir(), target:basename() .. ".app")
local targetfile = target:targetfile()
local dependfile = target:dependfile(target_app)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end
diff --git a/xmake/rules/utils/merge_archive/xmake.lua b/xmake/rules/utils/merge_archive/xmake.lua
index 39c913804..272b2f641 100644
--- a/xmake/rules/utils/merge_archive/xmake.lua
+++ b/xmake/rules/utils/merge_archive/xmake.lua
@@ -68,7 +68,7 @@ rule("utils.merge.archive")
os.cp(tmpfile, target:targetfile())
os.rm(tmpfile)
end
- end, {dependfile = target:dependfile(target:targetfile() .. ".merge_archive"), files = libraryfiles})
+ end, {dependfile = target:dependfile(target:targetfile() .. ".merge_archive"), files = libraryfiles, changed = target:is_rebuilt()})
end
end)
diff --git a/xmake/rules/utils/merge_object/xmake.lua b/xmake/rules/utils/merge_object/xmake.lua
index 8bebb5f5c..f53138a6d 100644
--- a/xmake/rules/utils/merge_object/xmake.lua
+++ b/xmake/rules/utils/merge_object/xmake.lua
@@ -41,7 +41,7 @@ rule("utils.merge.object")
-- load dependent info
local dependfile = target:dependfile(objectfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
-- need build this object?
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(objectfile)}) then
diff --git a/xmake/rules/utils/symbols/export_all/export_all.lua b/xmake/rules/utils/symbols/export_all/export_all.lua
index a9d264e50..14ea99211 100644
--- a/xmake/rules/utils/symbols/export_all/export_all.lua
+++ b/xmake/rules/utils/symbols/export_all/export_all.lua
@@ -27,7 +27,7 @@ import("core.project.depend")
import("utils.progress")
-- export all symbols for dynamic library
-function main (target, opt)
+function main(target, opt)
-- @note it only supports windows/dll now
assert(target:is_shared(), 'rule("utils.symbols.export_all"): only for shared target(%s)!', target:name())
@@ -95,5 +95,5 @@ function main (target, opt)
wprint('rule("utils.symbols.export_all"): no symbols are exported for target(%s)!', target:name())
end
- end, {dependfile = dependfile, files = target:objectfiles()})
+ end, {dependfile = dependfile, files = target:objectfiles(), changed = target:is_rebuilt()})
end
diff --git a/xmake/rules/utils/symbols/extract/xmake.lua b/xmake/rules/utils/symbols/extract/xmake.lua
index dd1f3a1df..cdc1e044a 100644
--- a/xmake/rules/utils/symbols/extract/xmake.lua
+++ b/xmake/rules/utils/symbols/extract/xmake.lua
@@ -67,7 +67,7 @@ rule("utils.symbols.extract")
local symbolfile = target:symbolfile()
local targetfile = target:targetfile()
local dependfile = target:dependfile(symbolfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end
diff --git a/xmake/rules/verilator/verilator.lua b/xmake/rules/verilator/verilator.lua
index 7800bae18..321191666 100644
--- a/xmake/rules/verilator/verilator.lua
+++ b/xmake/rules/verilator/verilator.lua
@@ -241,6 +241,7 @@ function build_cppfiles(target, batchjobs, sourcebatch, opt)
end, {dependfile = cmakefile .. ".d",
files = sourcebatch.sourcefiles,
+ changed = target:is_rebuilt(),
lastmtime = os.mtime(cmakefile)})
-- get compiled source files
diff --git a/xmake/rules/wdk/inf/xmake.lua b/xmake/rules/wdk/inf/xmake.lua
index 354fbc5a7..19533a463 100644
--- a/xmake/rules/wdk/inf/xmake.lua
+++ b/xmake/rules/wdk/inf/xmake.lua
@@ -83,7 +83,7 @@ rule("wdk.inf")
-- need build this object?
local dependfile = target:dependfile(targetfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(targetfile), values = args}) then
return
end
diff --git a/xmake/rules/wdk/man/xmake.lua b/xmake/rules/wdk/man/xmake.lua
index c5219aa56..c9859b9b8 100644
--- a/xmake/rules/wdk/man/xmake.lua
+++ b/xmake/rules/wdk/man/xmake.lua
@@ -110,7 +110,7 @@ rule("wdk.man")
-- need build this object?
local dependfile = target:dependfile(headerfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(headerfile), values = args}) then
return
end
diff --git a/xmake/rules/wdk/mc/xmake.lua b/xmake/rules/wdk/mc/xmake.lua
index 689c9786c..2c016a85d 100644
--- a/xmake/rules/wdk/mc/xmake.lua
+++ b/xmake/rules/wdk/mc/xmake.lua
@@ -92,7 +92,7 @@ rule("wdk.mc")
-- need build this object?
local dependfile = target:dependfile(headerfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(headerfile), values = args}) then
return
end
diff --git a/xmake/rules/wdk/mof/xmake.lua b/xmake/rules/wdk/mof/xmake.lua
index a1a2a0366..25e3d6a03 100644
--- a/xmake/rules/wdk/mof/xmake.lua
+++ b/xmake/rules/wdk/mof/xmake.lua
@@ -102,7 +102,7 @@ rule("wdk.mof")
-- need build this object?
local dependfile = target:dependfile(headerfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(headerfile), values = args}) then
return
end
diff --git a/xmake/rules/wdk/sign/xmake.lua b/xmake/rules/wdk/sign/xmake.lua
index 6be72e7b3..32d8fc936 100644
--- a/xmake/rules/wdk/sign/xmake.lua
+++ b/xmake/rules/wdk/sign/xmake.lua
@@ -98,7 +98,7 @@ rule("wdk.sign")
-- need build this object?
local tempfile = os.tmpfile(target:targetfile())
local dependfile = tempfile .. ".d"
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(tempfile)}) then
return
end
diff --git a/xmake/rules/wdk/tracewpp/xmake.lua b/xmake/rules/wdk/tracewpp/xmake.lua
index 75f4f37ef..650b0c4db 100644
--- a/xmake/rules/wdk/tracewpp/xmake.lua
+++ b/xmake/rules/wdk/tracewpp/xmake.lua
@@ -88,7 +88,7 @@ rule("wdk.tracewpp")
-- need build this object?
local targetfile = path.join(outputdir, path.basename(sourcefile) .. ".tmh")
local dependfile = target:dependfile(targetfile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(targetfile), values = args}) then
return
end
diff --git a/xmake/rules/xcode/application/build.lua b/xmake/rules/xcode/application/build.lua
index f65ad2855..736de948c 100644
--- a/xmake/rules/xcode/application/build.lua
+++ b/xmake/rules/xcode/application/build.lua
@@ -106,6 +106,6 @@ function main (target, opt)
end
codesign(bundledir, codesign_identity, mobile_provision, {deep = true})
- end, {dependfile = target:dependfile(bundledir), files = {bundledir, target:targetfile()}})
+ end, {dependfile = target:dependfile(bundledir), files = {bundledir, target:targetfile()}, changed = target:is_rebuilt()})
end
diff --git a/xmake/rules/xcode/bundle/xmake.lua b/xmake/rules/xcode/bundle/xmake.lua
index 9713e3b09..31c0a8296 100644
--- a/xmake/rules/xcode/bundle/xmake.lua
+++ b/xmake/rules/xcode/bundle/xmake.lua
@@ -109,7 +109,7 @@ rule("xcode.bundle")
end
codesign(bundledir, codesign_identity)
- end, {dependfile = target:dependfile(bundledir), files = {bundledir, target:targetfile()}})
+ end, {dependfile = target:dependfile(bundledir), files = {bundledir, target:targetfile()}, changed = target:is_rebuilt()})
end)
on_install(function (target)
diff --git a/xmake/rules/xcode/framework/xmake.lua b/xmake/rules/xcode/framework/xmake.lua
index 73370e4e2..10b2f337f 100644
--- a/xmake/rules/xcode/framework/xmake.lua
+++ b/xmake/rules/xcode/framework/xmake.lua
@@ -162,7 +162,7 @@ rule("xcode.framework")
end
codesign(contentsdir, codesign_identity)
end
- end, {dependfile = target:dependfile(bundledir), files = {bundledir, target:targetfile()}})
+ end, {dependfile = target:dependfile(bundledir), files = {bundledir, target:targetfile()}, changed = target:is_rebuilt()})
end)
on_install(function (target)
diff --git a/xmake/rules/xcode/info_plist/xmake.lua b/xmake/rules/xcode/info_plist/xmake.lua
index ddcc30336..235481846 100644
--- a/xmake/rules/xcode/info_plist/xmake.lua
+++ b/xmake/rules/xcode/info_plist/xmake.lua
@@ -43,7 +43,7 @@ rule("xcode.info_plist")
-- need re-compile it?
local dependfile = target:dependfile(sourcefile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end
diff --git a/xmake/rules/xcode/storyboard/xmake.lua b/xmake/rules/xcode/storyboard/xmake.lua
index 3db9db4c3..129e130c2 100644
--- a/xmake/rules/xcode/storyboard/xmake.lua
+++ b/xmake/rules/xcode/storyboard/xmake.lua
@@ -46,7 +46,7 @@ rule("xcode.storyboard")
-- need re-compile it?
local dependfile = target:dependfile(sourcefile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end
diff --git a/xmake/rules/xcode/xcassets/xmake.lua b/xmake/rules/xcode/xcassets/xmake.lua
index 9322d10c1..4479b6b95 100644
--- a/xmake/rules/xcode/xcassets/xmake.lua
+++ b/xmake/rules/xcode/xcassets/xmake.lua
@@ -43,7 +43,7 @@ rule("xcode.xcassets")
-- need re-compile it?
local dependfile = target:dependfile(sourcefile)
- local dependinfo = option.get("rebuild") and {} or (depend.load(dependfile) or {})
+ local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {})
if not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile)}) then
return
end