diff options
| author | ruki <[email protected]> | 2019-08-30 23:55:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-08-30 17:33:43 +0800 |
| commit | 74108f9a690cab1a9a8749e5e1c6880d59c83c95 (patch) | |
| tree | a4a4c12bf5ddd64e1715ba6a59d5286aad48a729 | |
| parent | 2202a09519c6e0e719735c7c5b1f3be225056080 (diff) | |
fix build progress
| -rw-r--r-- | xmake/actions/build/kinds/object.lua | 13 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua index e730c69b6..70d4dabc6 100644 --- a/xmake/actions/build/kinds/object.lua +++ b/xmake/actions/build/kinds/object.lua @@ -20,14 +20,18 @@ -- imports import("core.base.option") +import("core.project.rule") import("core.project.config") import("core.project.project") -- build source files with the custom rule function _build_files_with_rule(target, sourcebatch, opt, suffix) + -- the rule name + local rulename = assert(sourcebatch.rulename, "unknown rule for sourcebatch!") + -- get rule instance - local ruleinst = assert(sourcebatch.rule, "unknown rule!") + local ruleinst = assert(project.rule(rulename) or rule.rule(rulename), "unknown rule: %s", rulename) -- on_build_files? local on_build_files = ruleinst:script("build_files" .. (suffix and ("_" .. suffix) or "")) @@ -53,7 +57,7 @@ function _build_files_with_rule(target, sourcebatch, opt, suffix) os.cd(curdir) -- calculate progress - local progress_now = (index * (progress.start + progress.stop)) / sourcecount + local progress_now = progress.start + ((index - 1) * (progress.stop - progress.start)) / sourcecount if suffix == "before" then progress_now = progress.start elseif suffix == "after" then @@ -124,8 +128,9 @@ function build_sourcefiles(target, sourcebatches, opt) -- compute the sub-progress range sourcestop = sourcestart + #sourcebatch.sourcefiles - local progress_start = (sourcestart * (progress.start + progress.stop)) / sourcetotal - local progress_stop = (sourcestop * (progress.start + progress.stop)) / sourcetotal + local progress_range = progress.stop - progress.start + local progress_start = progress.start + (sourcestart * progress_range) / sourcetotal + local progress_stop = progress.start + (sourcestop * progress_range) / sourcetotal opt.progress = {start = progress_start, stop = progress_stop} sourcestart = sourcestop diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 2a15482f9..c20d1f190 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -1337,8 +1337,8 @@ function _instance:sourcebatches() local sourcebatch = sourcebatches[rulename] or {sourcefiles = {}} sourcebatches[rulename] = sourcebatch - -- add file rule to this batch - sourcebatch.rule = filerule + -- save the rule name + sourcebatch.rulename = rulename -- add source file to this batch table.insert(sourcebatch.sourcefiles, sourcefile) |
