summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-09-08 11:17:51 +0800
committerruki <[email protected]>2019-09-08 11:17:51 +0800
commitce51c2de7c11b6368ce8956329f9ebbe4ffd1b67 (patch)
tree2103b3eebb2dbdbcca008bc16f5ef9774fbdb40e
parent1e3b7f298e1cbeb9bb63fd85fc06f2c9b0ee6e75 (diff)
improve show progress
-rw-r--r--xmake/actions/build/kinds/object.lua18
-rw-r--r--xmake/rules/c++/modules/build_modulefiles.lua7
2 files changed, 19 insertions, 6 deletions
diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua
index 8cf9bba99..2959a0114 100644
--- a/xmake/actions/build/kinds/object.lua
+++ b/xmake/actions/build/kinds/object.lua
@@ -33,9 +33,18 @@ function _build_files_with_rule(target, sourcebatch, opt, suffix)
-- get rule instance
local ruleinst = assert(project.rule(rulename) or rule.rule(rulename), "unknown rule: %s", rulename)
+ -- get progress
+ local progress = opt.progress
+
-- on_build_files?
local on_build_files = ruleinst:script("build_files" .. (suffix and ("_" .. suffix) or ""))
if on_build_files then
+ opt = table.copy(opt)
+ if suffix == "before" then
+ opt.progress = {start = progress.start, stop = progress.start}
+ elseif suffix == "after" then
+ opt.progress = {start = progress.stop, stop = progress.stop}
+ end
on_build_files(target, sourcebatch, opt)
else
-- get the build file script
@@ -45,9 +54,6 @@ function _build_files_with_rule(target, sourcebatch, opt, suffix)
-- get the max job count
local jobs = tonumber(option.get("jobs") or "4")
- -- get progress range
- local progress = opt.progress
-
-- run build jobs for each source file
local curdir = os.curdir()
local sourcecount = #sourcebatch.sourcefiles
@@ -56,7 +62,7 @@ function _build_files_with_rule(target, sourcebatch, opt, suffix)
-- force to set the current directory first because the other jobs maybe changed it
os.cd(curdir)
- -- calculate progress
+ -- get current progress
local progress_now = progress.start + ((index - 1) * (progress.stop - progress.start)) / sourcecount
if suffix == "before" then
progress_now = progress.start
@@ -86,6 +92,8 @@ function _build_files(target, sourcebatch, opt)
-- do before build
local before_build_files = target:script("build_files_before")
if before_build_files then
+ opt = table.copy(opt)
+ opt.progress = {start = progress.start, stop = progress.start}
before_build_files(target, sourcebatch, opt)
end
@@ -102,6 +110,8 @@ function _build_files(target, sourcebatch, opt)
-- do after build
local after_build_files = target:script("build_files_after")
if after_build_files then
+ opt = table.copy(opt)
+ opt.progress = {start = progress.stop, stop = progress.stop}
after_build_files(target, sourcebatch, opt)
end
end
diff --git a/xmake/rules/c++/modules/build_modulefiles.lua b/xmake/rules/c++/modules/build_modulefiles.lua
index 2847d5791..08924e814 100644
--- a/xmake/rules/c++/modules/build_modulefiles.lua
+++ b/xmake/rules/c++/modules/build_modulefiles.lua
@@ -59,9 +59,11 @@ function _build_modulefiles_clang(target, sourcebatch, opt)
end
end
+-- TODO
-- build module files using gcc
function _build_modulefiles_gcc(target, sourcebatch, opt)
+ --[[
-- attempt to compile the module files as cxx
local modulefiles = {}
opt = table.join(opt, {configs = {}})
@@ -85,7 +87,8 @@ function _build_modulefiles_gcc(target, sourcebatch, opt)
-- add module files
for _, modulefile in ipairs(modulefiles) do
target:add("cxxflags", "-fmodules-ts", "-fmodule-file=" .. modulefile)
- end
+ end]]
+ raise("compiler(gcc): not implemented for c++ module!")
end
-- build module files using msvc
@@ -129,7 +132,7 @@ function main(target, sourcebatch, opt)
elseif compinst:name() == "cl" and compinst:has_flags("/experimental:module") then
_build_modulefiles_msvc(target, sourcebatch, opt)
else
- raise("compiler(%s): does not support module!", compinst:name())
+ raise("compiler(%s): does not support c++ module!", compinst:name())
end
end