summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-31 10:31:59 +0800
committerruki <[email protected]>2020-05-31 10:31:59 +0800
commit6d67b96bf3977f9f9376e03195933638e75f92ba (patch)
treeb77a0db55b27c090a5e4a61eb86f7a9f6bc590e4
parentaab3a9a8bf7c07cbf80d62c7bc5bc11c8cbf6fd3 (diff)
add ninja theme
-rw-r--r--xmake/actions/build/build.lua7
-rw-r--r--xmake/modules/core/tools/ar.lua1
-rw-r--r--xmake/modules/core/tools/cl.lua4
-rw-r--r--xmake/modules/core/tools/gcc.lua4
-rw-r--r--xmake/modules/core/tools/nvcc.lua4
-rw-r--r--xmake/modules/core/tools/sdcc.lua30
-rw-r--r--xmake/modules/private/utils/progress.lua24
-rw-r--r--xmake/themes/dark/xmake.lua1
-rw-r--r--xmake/themes/default/xmake.lua1
-rw-r--r--xmake/themes/emoji/xmake.lua1
-rw-r--r--xmake/themes/ninja/xmake.lua84
-rw-r--r--xmake/themes/plain/xmake.lua1
-rw-r--r--xmake/themes/powershell/xmake.lua1
13 files changed, 138 insertions, 25 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua
index 11cb00783..0df393317 100644
--- a/xmake/actions/build/build.lua
+++ b/xmake/actions/build/build.lua
@@ -218,7 +218,12 @@ function main(targetname)
local batchjobs = get_batchjobs(targetname)
if batchjobs and batchjobs:size() > 0 then
environment.enter("toolchains")
- runjobs("build", batchjobs, {comax = option.get("jobs") or 1})
+ runjobs("build", batchjobs, {comax = option.get("jobs") or 1, exit = function ()
+ import("private.utils.progress")
+ if progress.showing_without_scroll() then
+ print("")
+ end
+ end})
environment.leave("toolchains")
end
end
diff --git a/xmake/modules/core/tools/ar.lua b/xmake/modules/core/tools/ar.lua
index 774afdd9c..e034924dc 100644
--- a/xmake/modules/core/tools/ar.lua
+++ b/xmake/modules/core/tools/ar.lua
@@ -20,6 +20,7 @@
-- imports
import("core.tool.compiler")
+import("private.utils.progress")
-- init it
function init(self)
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index 3a050fd64..d6a71f619 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -24,6 +24,7 @@ import("core.project.project")
import("core.language.language")
import("private.tools.vstool")
import("private.tools.cl.parse_include")
+import("private.utils.progress")
-- init it
function init(self)
@@ -400,6 +401,9 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
end
if #lines > 0 then
local warnings = table.concat(table.slice(lines, 1, ifelse(#lines > 8, 8, #lines)), "\r\n")
+ if progress.showing_without_scroll() then
+ print("")
+ end
cprint("${color.warning}%s", warnings)
end
end
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 1df869751..04839ceaf 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -25,6 +25,7 @@ import("core.project.config")
import("core.project.project")
import("core.language.language")
import("private.tools.ccache")
+import("private.utils.progress")
-- init it
function init(self)
@@ -463,6 +464,9 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
local lines = errdata:split('\n', {plain = true})
if #lines > 0 then
local warnings = table.concat(table.slice(lines, 1, ifelse(#lines > 8, 8, #lines)), "\n")
+ if progress.showing_without_scroll() then
+ print("")
+ end
cprint("${color.warning}%s", warnings)
end
end
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua
index ec35a9b34..6aab1225d 100644
--- a/xmake/modules/core/tools/nvcc.lua
+++ b/xmake/modules/core/tools/nvcc.lua
@@ -25,6 +25,7 @@ import("core.project.project")
import("core.platform.platform")
import("core.language.language")
import("private.tools.ccache")
+import("private.utils.progress")
-- init it
function init(self)
@@ -353,6 +354,9 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
-- print some warnings
if warnings and #warnings > 0 and (option.get("verbose") or option.get("warning")) then
+ if progress.showing_without_scroll() then
+ print("")
+ end
cprint("${color.warning}%s", table.concat(table.slice(warnings:split('\n', {plain = true}), 1, 8), '\n'))
end
diff --git a/xmake/modules/core/tools/sdcc.lua b/xmake/modules/core/tools/sdcc.lua
index 03879677c..af61b21e1 100644
--- a/xmake/modules/core/tools/sdcc.lua
+++ b/xmake/modules/core/tools/sdcc.lua
@@ -20,6 +20,7 @@
-- imports
import("core.base.option")
+import("private.utils.progress")
-- init it
function init(self)
@@ -165,12 +166,12 @@ function link(self, objectfiles, targetkind, targetfile, flags)
end
-- make the compile arguments list
-function _compargv1(self, sourcefile, objectfile, flags)
+function compargv(self, sourcefile, objectfile, flags)
return self:program(), table.join("-c", flags, "-o", objectfile, sourcefile)
end
-- compile the source file
-function _compile1(self, sourcefile, objectfile, dependinfo, flags)
+function compile(self, sourcefile, objectfile, dependinfo, flags)
-- ensure the object directory
os.mkdir(path.directory(objectfile))
@@ -179,7 +180,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
try
{
function ()
- local outdata, errdata = os.iorunv(_compargv1(self, sourcefile, objectfile, flags))
+ local outdata, errdata = os.iorunv(compargv(self, sourcefile, objectfile, flags))
return (outdata or "") .. (errdata or "")
end,
catch
@@ -215,6 +216,9 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
-- print some warnings
if warnings and #warnings > 0 and (option.get("verbose") or option.get("warning")) then
+ if progress.showing_without_scroll() then
+ print("")
+ end
cprint("${color.warning}%s", table.concat(table.slice(warnings:split('\n'), 1, 8), '\n'))
end
end
@@ -222,23 +226,3 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
}
end
--- make the compile arguments list
-function compargv(self, sourcefiles, objectfile, flags)
-
- -- only support single source file now
- assert(type(sourcefiles) ~= "table", "'object:sources' not support!")
-
- -- for only single source file
- return _compargv1(self, sourcefiles, objectfile, flags)
-end
-
--- compile the source file
-function compile(self, sourcefiles, objectfile, dependinfo, flags)
-
- -- only support single source file now
- assert(type(sourcefiles) ~= "table", "'object:sources' not support!")
-
- -- for only single source file
- _compile1(self, sourcefiles, objectfile, dependinfo, flags)
-end
-
diff --git a/xmake/modules/private/utils/progress.lua b/xmake/modules/private/utils/progress.lua
index ad1402238..dbcc69a55 100644
--- a/xmake/modules/private/utils/progress.lua
+++ b/xmake/modules/private/utils/progress.lua
@@ -89,13 +89,35 @@ function process:running()
return self._RUNNING and true or false
end
+-- showing progress line without scroll?
+function showing_without_scroll()
+ return _g.showing_without_scroll
+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, ...)
+ local is_scroll = _g.is_scroll
+ if is_scroll == nil then
+ is_scroll = theme.get("text.build.progress_style") == "scroll"
+ _g.is_scroll = is_scroll
+ end
+ if is_scroll then
+ cprint(progress_prefix .. format, progress, ...)
+ else
+ utils.clearline()
+ cprintf(progress_prefix .. format, progress, ...)
+ if math.floor(progress) == 100 then
+ print("")
+ _g.showing_without_scroll = false
+ else
+ _g.showing_without_scroll = true
+ end
+ io.flush()
+ end
end
end
diff --git a/xmake/themes/dark/xmake.lua b/xmake/themes/dark/xmake.lua
index d4c63e00f..c2933fa5b 100644
--- a/xmake/themes/dark/xmake.lua
+++ b/xmake/themes/dark/xmake.lua
@@ -43,6 +43,7 @@ theme("dark")
-- the building progress
set_text("build.progress_format", "[%3d%%]")
+ set_text("build.progress_style", "scroll")
set_color("build.progress", "green")
-- the building object file
diff --git a/xmake/themes/default/xmake.lua b/xmake/themes/default/xmake.lua
index bc3085d17..88b8ab90e 100644
--- a/xmake/themes/default/xmake.lua
+++ b/xmake/themes/default/xmake.lua
@@ -43,6 +43,7 @@ theme("default")
-- the building progress
set_text("build.progress_format", "[%3d%%]")
+ set_text("build.progress_style", "scroll")
set_color("build.progress", "green bright")
-- the building object file
diff --git a/xmake/themes/emoji/xmake.lua b/xmake/themes/emoji/xmake.lua
index bd1015c38..771c3f640 100644
--- a/xmake/themes/emoji/xmake.lua
+++ b/xmake/themes/emoji/xmake.lua
@@ -43,6 +43,7 @@ theme("emoji")
-- the building progress
set_text("build.progress_format", "[%3d%%]")
+ set_text("build.progress_style", "scroll")
set_color("build.progress", "green")
-- the building object file
diff --git a/xmake/themes/ninja/xmake.lua b/xmake/themes/ninja/xmake.lua
new file mode 100644
index 000000000..6ed1f8f26
--- /dev/null
+++ b/xmake/themes/ninja/xmake.lua
@@ -0,0 +1,84 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+-- define theme
+theme("ninja")
+
+ -- the success status
+ set_text("success", "$ok")
+ set_color("success", "green bright")
+
+ -- the failure status
+ set_text("failure", "$failed")
+ set_color("failure", "red bright")
+
+ -- the nothing status
+ set_text("nothing", "$no")
+ set_color("nothing", "red bright")
+
+ -- the error info
+ set_text("error", "$error")
+ set_color("error", "red bright")
+
+ -- the warning info
+ set_text("warning", "$warning")
+ set_color("warning", "yellow bright")
+
+ -- the building progress
+ set_text("build.progress_format", "[%3d%%]")
+ set_text("build.progress_style", "noscroll")
+ set_color("build.progress", "green bright")
+
+ -- the building object file
+ set_color("build.object", "")
+
+ -- the building target file
+ set_color("build.target", "magenta bright")
+
+ -- the spinner chars
+ set_text("spinner.chars", '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏')
+
+ -- color dump
+ set_text("dump.default_format", "%s")
+ set_text("dump.udata_format", "%s")
+ set_text("dump.table_format", "%s")
+ set_text("dump.anchor", "&%s")
+ set_text("dump.reference", "*%s")
+ set_color("dump.anchor", "yellow")
+ set_color("dump.reference", "yellow")
+ set_color("dump.default", "red")
+ set_color("dump.udata", "yellow")
+ set_color("dump.table", "bright")
+ set_color("dump.string", "magenta bright")
+ set_color("dump.string_quote", "magenta")
+ set_color("dump.keyword", "blue")
+ set_color("dump.number", "green bright")
+ set_color("dump.function", "cyan")
+
+ -- menu
+ set_color("menu.main.task.name", "magenta")
+ set_color("menu.option.name", "green")
+ set_color("menu.usage", "cyan")
+
+ -- interactive mode
+ set_text("interactive.prompt", "xmake>")
+ set_text("interactive.prompt2", "xmake>>")
+ set_color("interactive.prompt", "green")
+ set_color("interactive.prompt2", "green")
diff --git a/xmake/themes/plain/xmake.lua b/xmake/themes/plain/xmake.lua
index 358834384..1c2709ca1 100644
--- a/xmake/themes/plain/xmake.lua
+++ b/xmake/themes/plain/xmake.lua
@@ -43,6 +43,7 @@ theme("plain")
-- the building progress
set_text("build.progress_format", "[%3d%%]")
+ set_text("build.progress_style", "scroll")
set_color("build.progress", "")
-- the building object file
diff --git a/xmake/themes/powershell/xmake.lua b/xmake/themes/powershell/xmake.lua
index 457b0fad8..08d477e2c 100644
--- a/xmake/themes/powershell/xmake.lua
+++ b/xmake/themes/powershell/xmake.lua
@@ -43,6 +43,7 @@ theme("powershell")
-- the building progress
set_text("build.progress_format", "[%3d%%]")
+ set_text("build.progress_style", "scroll")
set_color("build.progress", "green bright")
-- the building object file