summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-30 23:18:28 +0800
committerruki <[email protected]>2020-05-30 23:18:28 +0800
commitd50200be0abb94e7e627e7a25b5bab65d420eb16 (patch)
tree06ab0407ff802bee7e9b7275df6081d657fe3609
parent8ee95c16390e8dbac222d1c0e665eb7dc43cccc7 (diff)
add progress.show
-rw-r--r--tests/apis/rules/xmake.lua4
-rw-r--r--xmake/actions/build/kinds/binary.lua8
-rw-r--r--xmake/actions/build/kinds/shared.lua8
-rw-r--r--xmake/actions/build/kinds/static.lua8
-rw-r--r--xmake/actions/build/main.lua4
-rw-r--r--xmake/modules/private/action/build/object.lua9
-rw-r--r--xmake/modules/private/utils/progress.lua11
-rw-r--r--xmake/rules/utils/merge_archive/xmake.lua9
-rw-r--r--xmake/rules/utils/symbols/xmake.lua8
9 files changed, 27 insertions, 42 deletions
diff --git a/tests/apis/rules/xmake.lua b/tests/apis/rules/xmake.lua
index 96103e319..97c7e2c5f 100644
--- a/tests/apis/rules/xmake.lua
+++ b/tests/apis/rules/xmake.lua
@@ -27,8 +27,8 @@ rule("c code")
end)
on_build_file(function (target, sourcefile, opt)
import("core.theme.theme")
- local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} "
- cprint(progress_prefix .. "compiling.$(mode) %s", opt.progress, sourcefile)
+ import("private.utils.progress")
+ progress.show(opt.progress, "compiling.$(mode) %s", sourcefile)
local objectfile_o = os.tmpfile() .. ".o"
local sourcefile_c = os.tmpfile() .. ".c"
os.cp(sourcefile, sourcefile_c)
diff --git a/xmake/actions/build/kinds/binary.lua b/xmake/actions/build/kinds/binary.lua
index 800faeb1f..2d38dc96c 100644
--- a/xmake/actions/build/kinds/binary.lua
+++ b/xmake/actions/build/kinds/binary.lua
@@ -24,6 +24,7 @@ import("core.theme.theme")
import("core.tool.linker")
import("core.tool.compiler")
import("core.project.depend")
+import("private.utils.progress")
import("object", {alias = "add_batchjobs_for_object"})
-- do link target
@@ -71,12 +72,7 @@ function _do_link_target(target, opt)
local verbose = option.get("verbose")
-- trace progress info
- local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} "
- if verbose then
- cprint(progress_prefix .. "${dim color.build.target}linking.$(mode) %s", opt.progress, path.filename(targetfile))
- else
- cprint(progress_prefix .. "${color.build.target}linking.$(mode) %s", opt.progress, path.filename(targetfile))
- end
+ progress.show(opt.progress, "${color.build.target}linking.$(mode) %s", path.filename(targetfile))
-- trace verbose info
if verbose then
diff --git a/xmake/actions/build/kinds/shared.lua b/xmake/actions/build/kinds/shared.lua
index 9df138c09..bd8de01bf 100644
--- a/xmake/actions/build/kinds/shared.lua
+++ b/xmake/actions/build/kinds/shared.lua
@@ -24,6 +24,7 @@ import("core.theme.theme")
import("core.tool.linker")
import("core.tool.compiler")
import("core.project.depend")
+import("private.utils.progress")
import("object", {alias = "add_batchjobs_for_object"})
-- do link target
@@ -84,12 +85,7 @@ function _do_link_target(target, opt)
local verbose = option.get("verbose")
-- trace progress info
- local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} "
- if verbose then
- cprint(progress_prefix .. "${dim color.build.target}linking.$(mode) %s", opt.progress, path.filename(targetfile))
- else
- cprint(progress_prefix .. "${color.build.target}linking.$(mode) %s", opt.progress, path.filename(targetfile))
- end
+ progress.show(opt.progress, "${color.build.target}linking.$(mode) %s", path.filename(targetfile))
-- trace verbose info
if verbose then
diff --git a/xmake/actions/build/kinds/static.lua b/xmake/actions/build/kinds/static.lua
index bf6856ae1..c4ac8ba25 100644
--- a/xmake/actions/build/kinds/static.lua
+++ b/xmake/actions/build/kinds/static.lua
@@ -24,6 +24,7 @@ import("core.theme.theme")
import("core.tool.linker")
import("core.tool.compiler")
import("core.project.depend")
+import("private.utils.progress")
import("object", {alias = "add_batchjobs_for_object"})
-- do link target
@@ -80,12 +81,7 @@ function _do_link_target(target, opt)
local verbose = option.get("verbose")
-- trace progress info
- local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} "
- if verbose then
- cprint(progress_prefix .. "${dim color.build.target}archiving.$(mode) %s", opt.progress, path.filename(targetfile))
- else
- cprint(progress_prefix .. "${color.build.target}archiving.$(mode) %s", opt.progress, path.filename(targetfile))
- end
+ progress.show(opt.progress, "${color.build.target}archiving.$(mode) %s", path.filename(targetfile))
-- trace verbose info
if verbose then
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua
index 4959d3e71..d1c39911d 100644
--- a/xmake/actions/build/main.lua
+++ b/xmake/actions/build/main.lua
@@ -26,6 +26,7 @@ import("core.project.project")
import("core.platform.platform")
import("core.platform.environment")
import("core.theme.theme")
+import("private.utils.progress")
import("build")
import("build_files")
import("cleaner")
@@ -138,6 +139,5 @@ function main()
os.cd(oldir)
-- trace
- local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} "
- cprint(progress_prefix .. "${color.success}build ok!", 100)
+ progress.show(100, "${color.success}build ok!")
end
diff --git a/xmake/modules/private/action/build/object.lua b/xmake/modules/private/action/build/object.lua
index b6e5d63e1..3b5bc1368 100644
--- a/xmake/modules/private/action/build/object.lua
+++ b/xmake/modules/private/action/build/object.lua
@@ -25,6 +25,7 @@ import("core.tool.compiler")
import("core.project.depend")
import("private.tools.ccache")
import("private.async.runjobs")
+import("private.utils.progress")
-- do build file
function _do_build_file(target, sourcefile, opt)
@@ -33,7 +34,6 @@ function _do_build_file(target, sourcefile, opt)
local objectfile = opt.objectfile
local dependfile = opt.dependfile
local sourcekind = opt.sourcekind
- local progress = opt.progress
-- load compiler
local compinst = compiler.load(sourcekind, {target = target})
@@ -60,12 +60,7 @@ function _do_build_file(target, sourcefile, opt)
-- trace progress info
if not opt.quiet then
- local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} "
- if verbose then
- cprint(progress_prefix .. "${dim color.build.object}%scompiling.$(mode) %s", progress, exists_ccache and "ccache " or "", sourcefile)
- else
- cprint(progress_prefix .. "${color.build.object}%scompiling.$(mode) %s", progress, exists_ccache and "ccache " or "", sourcefile)
- end
+ progress.show(opt.progress, "${color.build.object}%scompiling.$(mode) %s", exists_ccache and "ccache " or "", sourcefile)
end
-- trace verbose info
diff --git a/xmake/modules/private/utils/progress.lua b/xmake/modules/private/utils/progress.lua
index eaf82c369..ad1402238 100644
--- a/xmake/modules/private/utils/progress.lua
+++ b/xmake/modules/private/utils/progress.lua
@@ -19,6 +19,7 @@
--
-- imports
+import("core.base.option")
import("core.base.object")
import("core.theme.theme")
@@ -88,6 +89,16 @@ function process:running()
return self._RUNNING and true or false
end
+-- show the message with process
+function show(progress, format, ...)
+ local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} "
+ if option.get("verbose") then
+ cprint(progress_prefix .. "${dim}" .. format, progress, ...)
+ else
+ cprint(progress_prefix .. format, progress, ...)
+ end
+end
+
-- build a progress indicator
-- @params stream - stream to write to, will use io.stdout if not provided
-- @params opt - options
diff --git a/xmake/rules/utils/merge_archive/xmake.lua b/xmake/rules/utils/merge_archive/xmake.lua
index 2361b35c0..01b56caf0 100644
--- a/xmake/rules/utils/merge_archive/xmake.lua
+++ b/xmake/rules/utils/merge_archive/xmake.lua
@@ -33,6 +33,7 @@ rule("utils.merge.archive")
import("core.project.depend")
import("core.tool.extractor")
import("core.project.target", {alias = "project_target"})
+ import("private.utils.progress")
-- @note we cannot process archives in parallel because the current directory may be changed
for i = 1, #sourcebatch.sourcefiles do
@@ -55,13 +56,7 @@ rule("utils.merge.archive")
end
-- trace progress info
- local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} "
- if option.get("verbose") then
- cprint(progress_prefix .. "${dim color.build.object}inserting.$(mode) %s", opt.progress, sourcefile_lib)
- print("extracting %s to %s", sourcefile_lib, objectdir)
- else
- cprint(progress_prefix .. "${color.build.object}inserting.$(mode) %s", opt.progress, sourcefile_lib)
- end
+ progress.show(opt.progress, "${color.build.object}inserting.$(mode) %s", sourcefile_lib)
-- extract the archive library
os.tryrm(objectdir)
diff --git a/xmake/rules/utils/symbols/xmake.lua b/xmake/rules/utils/symbols/xmake.lua
index dae924a08..5277cd783 100644
--- a/xmake/rules/utils/symbols/xmake.lua
+++ b/xmake/rules/utils/symbols/xmake.lua
@@ -41,6 +41,7 @@ rule("utils.symbols.extract")
import("core.theme.theme")
import("core.project.depend")
import("core.platform.platform")
+ import("private.utils.progress")
-- get strip
local strip = platform.tool("strip")
@@ -67,12 +68,7 @@ rule("utils.symbols.extract")
end
-- trace progress info
- local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} "
- if option.get("verbose") then
- cprint(progress_prefix .. "${dim color.build.target}generating.$(mode) %s", opt.progress, path.filename(symbolfile))
- else
- cprint(progress_prefix .. "${color.build.target}generating.$(mode) %s", opt.progress, path.filename(symbolfile))
- end
+ progress.show(opt.progress, "${color.build.target}generating.$(mode) %s", path.filename(symbolfile))
-- we remove the previous symbol file to ensure that it will be re-generated and it's mtime will be changed.
local dryrun = option.get("dry-run")