diff options
| author | ruki <[email protected]> | 2023-09-01 00:48:08 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-09-01 00:48:08 +0800 |
| commit | 12f2bed0df8299d3765761dc9a7567e8f7b18fa5 (patch) | |
| tree | d2e61100c6031be741afacacd017f800d78f082e | |
| parent | bc32dfdb2c91fc05b368a111a89505569117ccff (diff) | |
improve runcmds to rebuild
| -rw-r--r-- | xmake/actions/build/build.lua | 6 | ||||
| -rw-r--r-- | xmake/actions/build/kinds/binary.lua | 6 | ||||
| -rw-r--r-- | xmake/actions/build/kinds/object.lua | 4 | ||||
| -rw-r--r-- | xmake/actions/build/kinds/shared.lua | 6 | ||||
| -rw-r--r-- | xmake/actions/build/kinds/static.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/private/utils/batchcmds.lua | 42 | ||||
| -rw-r--r-- | xmake/rules/protobuf/proto.lua | 6 |
7 files changed, 38 insertions, 38 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua index 227786a9f..d37386659 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 @@ -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 diff --git a/xmake/actions/build/kinds/binary.lua b/xmake/actions/build/kinds/binary.lua index f12ae736f..dd14d5c95 100644 --- a/xmake/actions/build/kinds/binary.lua +++ b/xmake/actions/build/kinds/binary.lua @@ -95,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 @@ -124,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 @@ -147,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 5e6654767..f4763c608 100644 --- a/xmake/actions/build/kinds/shared.lua +++ b/xmake/actions/build/kinds/shared.lua @@ -95,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 @@ -124,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 @@ -147,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 e075137b5..0d75b58c6 100644 --- a/xmake/actions/build/kinds/static.lua +++ b/xmake/actions/build/kinds/static.lua @@ -95,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 @@ -124,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 @@ -147,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/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/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 |
