diff options
| author | ruki <[email protected]> | 2020-03-10 23:44:11 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-03-10 16:25:10 +0800 |
| commit | fd44c0fef3ed3bab58d27bb28da5884f9dc7945d (patch) | |
| tree | 471d1779104bb57afbe16b98f19e0e21996d8d0c | |
| parent | 8db0c0d333e24556e1a40931eae9166cbd233e35 (diff) | |
fix index
| -rw-r--r-- | xmake/actions/build/kinds/object.lua | 4 | ||||
| -rw-r--r-- | xmake/actions/build/main.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/private/action/build/object.lua | 24 | ||||
| -rw-r--r-- | xmake/rules/c++/xmake.lua | 4 |
4 files changed, 18 insertions, 18 deletions
diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua index 9ac489848..9c3816611 100644 --- a/xmake/actions/build/kinds/object.lua +++ b/xmake/actions/build/kinds/object.lua @@ -37,7 +37,7 @@ function _add_batchjobs_for_rule(batchjobs, rootjob, target, sourcebatch, suffix local script = ruleinst:script(scriptname) if script then if ruleinst:extraconf(scriptname, "batch") then - assert(script(target, batchjobs, sourcebatch, {rootjob = rootjob}), "rule(%s):%s(): no returned job!", rulename, scriptname) + script(target, batchjobs, sourcebatch, {rootjob = rootjob}) else batchjobs:addjob("rule/" .. rulename .. "/" .. scriptname, function (index, total) script(target, sourcebatch, {progress = (index * 100) / total}) @@ -66,7 +66,7 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target, sourcebatch, suff local script = target:script(scriptname) if script then if target:extraconf(scriptname, "batch") then - assert(script(target, batchjobs, sourcebatch, {rootjob = rootjob}), "target(%s):%s(): no returned job!", target:name(), scriptname) + script(target, batchjobs, sourcebatch, {rootjob = rootjob}) else batchjobs:addjob(target:name() .. "/" .. scriptname, function (index, total) script(target, sourcebatch, {progress = (index * 100) / total}) diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua index 61ee24401..4959d3e71 100644 --- a/xmake/actions/build/main.lua +++ b/xmake/actions/build/main.lua @@ -25,6 +25,7 @@ import("core.project.config") import("core.project.project") import("core.platform.platform") import("core.platform.environment") +import("core.theme.theme") import("build") import("build_files") import("cleaner") @@ -137,5 +138,6 @@ function main() os.cd(oldir) -- trace - cprint("${color.success}build ok!") + local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} " + cprint(progress_prefix .. "${color.success}build ok!", 100) end diff --git a/xmake/modules/private/action/build/object.lua b/xmake/modules/private/action/build/object.lua index 0de2729f6..5a87bf825 100644 --- a/xmake/modules/private/action/build/object.lua +++ b/xmake/modules/private/action/build/object.lua @@ -93,7 +93,9 @@ function _build_object(target, sourcebatch, index, opt) local sourcekind = assert(sourcebatch.sourcekind, "%s: sourcekind not found!", sourcefile) -- init build option - local opt = table.join(opt, {objectfile = objectfile, dependfile = dependfile, sourcekind = sourcekind, progress = opt.progress}) + opt.objectfile = objectfile + opt.dependfile = dependfile + opt.sourcekind = sourcekind -- do before build local before_build_file = target:script("build_file_before") @@ -104,9 +106,7 @@ function _build_object(target, sourcebatch, index, opt) -- do build local on_build_file = target:script("build_file") if on_build_file then - opt.origin = _do_build_file on_build_file(target, sourcefile, opt) - opt.origin = nil else _do_build_file(target, sourcefile, opt) end @@ -118,14 +118,12 @@ function _build_object(target, sourcebatch, index, opt) end end --- build the source files -function main(target, sourcebatch, opt) - - -- get the max job count - local jobs = tonumber(option.get("jobs") or "4") - - -- run build jobs for each source file - runjobs("build_objects", function (index) - _build_object(target, sourcebatch, index, opt) - end, {total = #sourcebatch.sourcefiles, comax = jobs}) +-- add batch jobs to build the source files +function main(target, batchjobs, sourcebatch, opt) + local rootjob = opt.rootjob + for i = 1, #sourcebatch.sourcefiles do + batchjobs:addjob(tostring(i), function (index, total) + _build_object(target, sourcebatch, i, {progress = (index * 100) / total}) + end, rootjob) + end end diff --git a/xmake/rules/c++/xmake.lua b/xmake/rules/c++/xmake.lua index 9211db820..1693b38ac 100644 --- a/xmake/rules/c++/xmake.lua +++ b/xmake/rules/c++/xmake.lua @@ -28,7 +28,7 @@ rule("c.build.pcheader") rule("c.build") set_sourcekinds("cc") add_deps("c.build.pcheader") - on_build_files("private.action.build.object") + on_build_files("private.action.build.object", {batch = true}) -- define rule: c++.build.pcheader rule("c++.build.pcheader") @@ -40,7 +40,7 @@ rule("c++.build.pcheader") rule("c++.build") set_sourcekinds("cxx") add_deps("c++.build.pcheader", "c++.build.modules") - on_build_files("private.action.build.object") + on_build_files("private.action.build.object", {batch = true}) -- define rule: cpp rule("c++") |
