summaryrefslogtreecommitdiff
path: root/xmake
diff options
context:
space:
mode:
authorruki <[email protected]>2016-07-14 09:18:37 +0800
committerruki <[email protected]>2016-07-14 09:18:37 +0800
commit6c2d3f0ea4d0ccdb10199bc9462b0dc44ddc8a9a (patch)
tree268de1524680eafc5846ecd731eda7b454b05197 /xmake
parente20c540cbde1694c683bbc3b8c19158bbde57985 (diff)
add colors for verbose info
Diffstat (limited to 'xmake')
-rwxr-xr-xxmake/actions/build/kinds/binary.lua12
-rwxr-xr-xxmake/actions/build/kinds/object.lua14
-rwxr-xr-xxmake/actions/build/kinds/shared.lua14
-rwxr-xr-xxmake/actions/build/kinds/static.lua14
-rw-r--r--xmake/core/project/option.lua22
-rw-r--r--xmake/core/tool/archiver.lua9
-rw-r--r--xmake/core/tool/compiler.lua9
-rw-r--r--xmake/core/tool/linker.lua9
-rw-r--r--xmake/platforms/checker.lua35
9 files changed, 91 insertions, 47 deletions
diff --git a/xmake/actions/build/kinds/binary.lua b/xmake/actions/build/kinds/binary.lua
index 0b3c777ef..c3aafcb55 100755
--- a/xmake/actions/build/kinds/binary.lua
+++ b/xmake/actions/build/kinds/binary.lua
@@ -47,8 +47,16 @@ function build(target, g)
-- the target file
local targetfile = target:targetfile()
- -- trace
- print("[%02d%%]: linking.$(mode) %s", (g.targetindex + 1) * 100 / g.targetcount, path.filename(targetfile))
+ -- is verbose?
+ local verbose = option.get("verbose")
+
+ -- trace percent into
+ cprintf("${yellow}[%02d%%]:${clear} ", (g.targetindex + 1) * 100 / g.targetcount)
+ if verbose then
+ cprint("${dim}linking.$(mode) %s", path.filename(targetfile))
+ else
+ print("linking.$(mode) %s", path.filename(targetfile))
+ end
-- trace verbose info
if option.get("verbose") then
diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua
index c1d8b08dc..f22aafbe0 100755
--- a/xmake/actions/build/kinds/object.lua
+++ b/xmake/actions/build/kinds/object.lua
@@ -132,11 +132,19 @@ function _build(target, g, index)
return
end
- -- trace
- print("[%02d%%]: %scompiling.$(mode) %s", percent, ifelse(config.get("ccache"), "ccache ", ""), sourcefile)
+ -- is verbose?
+ local verbose = option.get("verbose")
+
+ -- trace percent info
+ cprintf("${yellow}[%02d%%]:${clear} ", percent)
+ if verbose then
+ cprint("${dim}%scompiling.$(mode) %s", ifelse(config.get("ccache"), "ccache ", ""), sourcefile)
+ else
+ print("%scompiling.$(mode) %s", ifelse(config.get("ccache"), "ccache ", ""), sourcefile)
+ end
-- trace verbose info
- if option.get("verbose") then
+ if verbose then
print(compiler.compcmd(sourcefile, objectfile, target))
end
diff --git a/xmake/actions/build/kinds/shared.lua b/xmake/actions/build/kinds/shared.lua
index 878507050..a16848b09 100755
--- a/xmake/actions/build/kinds/shared.lua
+++ b/xmake/actions/build/kinds/shared.lua
@@ -60,11 +60,19 @@ function build(target, g)
-- the target file
local targetfile = target:targetfile()
- -- trace
- print("[%02d%%]: linking.$(mode) %s", (g.targetindex + 1) * 100 / g.targetcount, path.filename(targetfile))
+ -- is verbose?
+ local verbose = option.get("verbose")
+
+ -- trace percent info
+ cprintf("${yellow}[%02d%%]:${clear} ", (g.targetindex + 1) * 100 / g.targetcount)
+ if verbose then
+ cprint("${dim}linking.$(mode) %s", path.filename(targetfile))
+ else
+ print("linking.$(mode) %s", path.filename(targetfile))
+ end
-- trace verbose info
- if option.get("verbose") then
+ if verbose then
print(linker.linkcmd(objectfiles, targetfile, target))
end
diff --git a/xmake/actions/build/kinds/static.lua b/xmake/actions/build/kinds/static.lua
index 709c0c936..d7503ffcb 100755
--- a/xmake/actions/build/kinds/static.lua
+++ b/xmake/actions/build/kinds/static.lua
@@ -60,11 +60,19 @@ function build(target, g)
-- the target file
local targetfile = target:targetfile()
- -- trace
- print("[%02d%%]: archiving.$(mode) %s", (g.targetindex + 1) * 100 / g.targetcount, path.filename(targetfile))
+ -- is verbose?
+ local verbose = option.get("verbose")
+
+ -- trace percent info
+ cprintf("${yellow}[%02d%%]:${clear} ", (g.targetindex + 1) * 100 / g.targetcount)
+ if verbose then
+ cprint("${dim}archiving.$(mode) %s", path.filename(targetfile))
+ else
+ print("archiving.$(mode) %s", path.filename(targetfile))
+ end
-- trace verbose info
- if option.get("verbose") then
+ if verbose then
print(archiver.archivecmd(objectfiles, targetfile, target))
end
diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua
index a7bc756de..880926f93 100644
--- a/xmake/core/project/option.lua
+++ b/xmake/core/project/option.lua
@@ -54,7 +54,7 @@ function option:_check_link(sourcefile, objectfile, targetfile)
-- attempt to run this command
local ok, errors = instance:link(objectfile, targetfile, self)
if not ok and option_.get("verbose") then
- print(errors)
+ utils.cprint("${red}" .. (errors or ""))
end
-- ok?
@@ -96,7 +96,7 @@ function option:_check_include(include, srcpath, objpath)
-- attempt to run this command
local ok, errors = instance:compile(srcpath, objpath, nil, self)
if not ok and option_.get("verbose") then
- print(errors)
+ utils.cprint("${red}" .. (errors or ""))
end
-- ok?
@@ -150,7 +150,7 @@ function option:_check_function(checkcode, srcpath, objpath)
-- execute the compile command
local ok, errors = instance:compile(srcpath, objpath, nil, self)
if not ok and option_.get("verbose") then
- print(errors)
+ utils.cprint("${red}" .. (errors or ""))
end
-- ok?
@@ -204,7 +204,7 @@ function option:_check_typedef(typedef, srcpath, objpath)
-- execute the compile command
local ok, errors = instance:compile(srcpath, objpath, nil, self)
if not ok and option_.get("verbose") then
- print(errors)
+ utils.cprint("${red}" .. (errors or ""))
end
-- ok?
@@ -236,7 +236,7 @@ function option:_check_links(cfile, objectfile, targetfile)
if ok then ok = self:_check_link(cfile, objectfile, targetfile) end
-- trace
- utils.print("checking for the links %s ... %s", links_str, utils.ifelse(ok, "ok", "no"))
+ utils.cprint("checking for the links %s ... %s", links_str, utils.ifelse(ok, "${green}ok", "${red}no"))
-- cache the result
option._CHECKED_LINKS[links_str] = ok
@@ -259,7 +259,7 @@ function option:_check_cincludes(cfile, objectfile)
local ok = self:_check_include(cinclude, cfile, objectfile)
-- trace
- utils.print("checking for the c include %s ... %s", cinclude, utils.ifelse(ok, "ok", "no"))
+ utils.cprint("checking for the c include %s ... %s", cinclude, utils.ifelse(ok, "${green}ok", "${red}no"))
-- cache the result
option._CHECKED_CINCLUDES[cinclude] = ok
@@ -286,7 +286,7 @@ function option:_check_cxxincludes(cxxfile, objectfile)
local ok = self:_check_include(cxxinclude, cxxfile, objectfile)
-- trace
- utils.print("checking for the c++ include %s ... %s", cxxinclude, utils.ifelse(ok, "ok", "no"))
+ utils.cprint("checking for the c++ include %s ... %s", cxxinclude, utils.ifelse(ok, "${green}ok", "${red}no"))
-- cache the result
option._CHECKED_CXXINCLUDES[cxxinclude] = ok
@@ -316,7 +316,7 @@ function option:_check_cfuncs(cfile, objectfile, targetfile)
if ok and self:get("links") then ok = self:_check_link(cfile, objectfile, targetfile) end
-- trace
- utils.print("checking for the c function %s ... %s", checkname, utils.ifelse(ok, "ok", "no"))
+ utils.cprint("checking for the c function %s ... %s", checkname, utils.ifelse(ok, "${green}ok", "${red}no"))
-- failed
if not ok then return false end
@@ -343,7 +343,7 @@ function option:_check_cxxfuncs(cxxfile, objectfile, targetfile)
if ok and self:get("links") then ok = self:_check_link(cxxfile, objectfile, targetfile) end
-- trace
- utils.print("checking for the c++ function %s ... %s", checkname, utils.ifelse(ok, "ok", "no"))
+ utils.cprint("checking for the c++ function %s ... %s", checkname, utils.ifelse(ok, "${green}ok", "${red}no"))
-- failed
if not ok then return false end
@@ -363,7 +363,7 @@ function option:_check_ctypes(cfile, objectfile, targetfile)
local ok = self:_check_typedef(ctype, cfile, objectfile)
-- trace
- utils.print("checking for the c type %s ... %s", ctype, utils.ifelse(ok, "ok", "no"))
+ utils.cprint("checking for the c type %s ... %s", ctype, utils.ifelse(ok, "${green}ok", "${red}no"))
-- failed
if not ok then return false end
@@ -383,7 +383,7 @@ function option:_check_cxxtypes(cxxfile, objectfile, targetfile)
local ok = self:_check_typedef(cxxtype, cxxfile, objectfile)
-- trace
- utils.print("checking for the c++ type %s ... %s", cxxtype, utils.ifelse(ok, "ok", "no"))
+ utils.cprint("checking for the c++ type %s ... %s", cxxtype, utils.ifelse(ok, "${green}ok", "${red}no"))
-- failed
if not ok then return false end
diff --git a/xmake/core/tool/archiver.lua b/xmake/core/tool/archiver.lua
index 3b0873ffe..2b539ca33 100644
--- a/xmake/core/tool/archiver.lua
+++ b/xmake/core/tool/archiver.lua
@@ -29,6 +29,7 @@ local path = require("base/path")
local utils = require("base/utils")
local table = require("base/table")
local string = require("base/string")
+local option = require("base/option")
local config = require("project/config")
local sandbox = require("sandbox/sandbox")
local platform = require("platform/platform")
@@ -273,9 +274,11 @@ function archiver:check(flags)
local ok, errors = sandbox.load(ltool.check, flags)
-- trace
- utils.verbose("checking for the flags %s ... %s", flags, utils.ifelse(ok, "ok", "no"))
- if not ok then
- utils.verbose(errors)
+ if option.get("verbose") then
+ utils.cprint("checking for the flags %s ... %s", flags, utils.ifelse(ok, "${green}ok", "${red}no"))
+ if not ok then
+ utils.cprint("${red}" .. errors or "")
+ end
end
-- save the checked result
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index 2de971c73..1f983b60a 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -29,6 +29,7 @@ local path = require("base/path")
local utils = require("base/utils")
local table = require("base/table")
local string = require("base/string")
+local option = require("base/option")
local tool = require("tool/tool")
local config = require("project/config")
local sandbox = require("sandbox/sandbox")
@@ -466,9 +467,11 @@ function compiler:check(flags)
local ok, errors = sandbox.load(ctool.check, flags)
-- trace
- utils.verbose("checking for the flags %s ... %s", flags, utils.ifelse(ok, "ok", "no"))
- if not ok then
- utils.verbose(errors)
+ if option.get("verbose") then
+ utils.cprint("checking for the flags %s ... %s", flags, utils.ifelse(ok, "${green}ok", "${red}no"))
+ if not ok then
+ utils.cprint("${red}" .. errors or "")
+ end
end
-- save the checked result
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index cca0d8275..5d01bd3cd 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -29,6 +29,7 @@ local path = require("base/path")
local utils = require("base/utils")
local table = require("base/table")
local string = require("base/string")
+local option = require("base/option")
local config = require("project/config")
local sandbox = require("sandbox/sandbox")
local platform = require("platform/platform")
@@ -391,9 +392,11 @@ function linker:check(flags)
local ok, errors = sandbox.load(ltool.check, flags)
-- trace
- utils.verbose("checking for the flags %s ... %s", flags, utils.ifelse(ok, "ok", "no"))
- if not ok then
- utils.verbose(errors)
+ if option.get("verbose") then
+ utils.cprint("checking for the flags %s ... %s", flags, utils.ifelse(ok, "${green}ok", "${red}no"))
+ if not ok then
+ utils.cprint("${red}" .. errors or "")
+ end
end
-- save the checked result
diff --git a/xmake/platforms/checker.lua b/xmake/platforms/checker.lua
index dad6f4b1c..24516944e 100644
--- a/xmake/platforms/checker.lua
+++ b/xmake/platforms/checker.lua
@@ -34,7 +34,7 @@ function check_arch(config, default)
config.set("arch", default or os.arch())
-- trace
- print("checking for the architecture ... %s", config.get("arch"))
+ cprint("checking for the architecture ... ${green}%s", config.get("arch"))
end
end
@@ -67,13 +67,13 @@ function check_xcode(config)
config.set("xcode_dir", xcode_dir)
-- trace
- print("checking for the Xcode application directory ... %s", xcode_dir)
+ cprint("checking for the Xcode application directory ... ${green}%s", xcode_dir)
else
-- failed
- print("checking for the Xcode application directory ... no")
- print("please run:")
- print(" - xmake config --xcode_dir=xxx")
- print("or - xmake global --xcode_dir=xxx")
+ cprint("checking for the Xcode application directory ... ${red}no")
+ cprint("${bright red}please run:")
+ cprint("${red} - xmake config --xcode_dir=xxx")
+ cprint("${red}or - xmake global --xcode_dir=xxx")
raise()
end
end
@@ -115,13 +115,13 @@ function check_xcode_sdkver(config)
config.set("xcode_sdkver", xcode_sdkver)
-- trace
- print("checking for the Xcode SDK version for %s ... %s", plat, xcode_sdkver)
+ cprint("checking for the Xcode SDK version for %s ... ${green}%s", plat, xcode_sdkver)
else
-- failed
- print("checking for the Xcode SDK version for %s ... no", plat)
- print("please run:")
- print(" - xmake config --xcode_sdkver=xxx")
- print("or - xmake global --xcode_sdkver=xxx")
+ cprint("checking for the Xcode SDK version for %s ... ${red}no", plat)
+ cprint("${bright red}please run:")
+ cprint("${red} - xmake config --xcode_sdkver=xxx")
+ cprint("${red}or - xmake global --xcode_sdkver=xxx")
raise()
end
end
@@ -148,8 +148,7 @@ function check_target_minver(config)
config.set("target_minver", config.get("xcode_sdkver") or versions[config.get("plat")])
-- trace
- print("checking for the target minimal version ... %s", config.get("target_minver"))
-
+ cprint("checking for the target minimal version ... ${green}%s", config.get("target_minver"))
end
end
@@ -171,7 +170,11 @@ function check_ccache(config)
end
-- trace
- print("checking for the ccache ... %s", ifelse(ccache_path, ccache_path, "no"))
+ if ccache_path then
+ cprint("checking for the ccache ... ${green}%s", ccache_path)
+ else
+ cprint("checking for the ccache ... ${red}no")
+ end
end
end
@@ -231,9 +234,9 @@ function check_toolchain(config, kind, cross, name, description, check)
-- trace
if toolpath then
- print("checking for %s (%s) ... %s", description, kind, path.filename(toolpath))
+ cprint("checking for %s (%s) ... ${green}%s", description, kind, path.filename(toolpath))
else
- print("checking for %s (%s) ... no", description, kind)
+ cprint("checking for %s (%s) ... ${red}no", description, kind)
end
end
end