diff options
| author | ruki <[email protected]> | 2025-04-09 23:42:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-04-09 23:42:30 +0800 |
| commit | 77d90d253447ea6992f4f0a81d8df219e23b499c (patch) | |
| tree | 6765217c72d7f05ba2e0dab0f18285a566b872c1 /xmake/plugins/project/utils/target_cmds.lua | |
| parent | 811f8772bbc14d90172aa294b20aed44d41902d9 (diff) | |
improve target_cmds
Diffstat (limited to 'xmake/plugins/project/utils/target_cmds.lua')
| -rw-r--r-- | xmake/plugins/project/utils/target_cmds.lua | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/xmake/plugins/project/utils/target_cmds.lua b/xmake/plugins/project/utils/target_cmds.lua index debc6fdc5..c25a2c3e3 100644 --- a/xmake/plugins/project/utils/target_cmds.lua +++ b/xmake/plugins/project/utils/target_cmds.lua @@ -122,3 +122,50 @@ function prepare_targets() target_buildutils.run_targetjobs(targets_root, {job_kind = "prepare"}) end +-- get target buildcmds +function get_target_buildcmds(target, opt) + opt = opt or {} + local progress_wrapper = {} + progress_wrapper.current = function () + return count + end + progress_wrapper.total = function () + return total + end + progress_wrapper.percent = function () + if total and total > 0 then + return math.floor((count * 100) / total) + else + return 0 + end + end + debug.setmetatable(progress_wrapper, { + __tostring = function () + -- we do not output any progress info for the project generators + return "" + end + }) + local buildcmds = batchcmds.new({target = target}) + local jobgraph = target_buildutils.get_targetjobs({target}, { + job_kind = "build", + buildcmds = buildcmds, + with_stages = hashset.from(opt.stages or {}), + ignored_rules = hashset.from(opt.ignored_rules or {}), + progress = progress_wrapper}) + if jobgraph and not jobgraph:empty() then + local jobqueue = jobgraph:build() + while true do + local job = jobqueue:getfree() + if job then + if job.run then + job.run() + end + jobqueue:remove(job) + else + break + end + end + end + return buildcmds:cmds() +end + |
