summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-09-25 21:57:16 +0800
committerruki <[email protected]>2021-09-25 21:57:16 +0800
commit697d7cc20e1e2914e72e396cf3158d9893a04e66 (patch)
tree37aa610373d521a5768ab53bf8fe8f5bd925724f
parent50eeea59ecee08e93e2c69929d12fa6953b92855 (diff)
improve error tips for package
-rw-r--r--xmake/core/package/package.lua16
-rw-r--r--xmake/modules/lib/detect/check_cxsnippets.lua8
-rw-r--r--xmake/modules/private/action/require/impl/actions/download.lua17
-rw-r--r--xmake/modules/private/action/require/impl/actions/install.lua11
4 files changed, 35 insertions, 17 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 8b7e26806..4b3432246 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -1485,7 +1485,7 @@ end
-- @param funcs the funcs
-- @param opt the argument options, e.g. { includes = ""}
--
--- @return true or false
+-- @return true or false, errors
--
function _instance:has_cfuncs(funcs, opt)
opt = opt or {}
@@ -1499,7 +1499,7 @@ end
-- @param funcs the funcs
-- @param opt the argument options, e.g. {includes = ""}
--
--- @return true or false
+-- @return true or false, errors
--
function _instance:has_cxxfuncs(funcs, opt)
opt = opt or {}
@@ -1513,7 +1513,7 @@ end
-- @param types the types
-- @param opt the argument options, e.g. { defines = ""}
--
--- @return true or false
+-- @return true or false, errors
--
function _instance:has_ctypes(types, opt)
opt = opt or {}
@@ -1527,7 +1527,7 @@ end
-- @param types the types
-- @param opt the argument options, e.g. { defines = ""}
--
--- @return true or false
+-- @return true or false, errors
--
function _instance:has_cxxtypes(types, opt)
opt = opt or {}
@@ -1541,7 +1541,7 @@ end
-- @param includes the includes
-- @param opt the argument options, e.g. { defines = ""}
--
--- @return true or false
+-- @return true or false, errors
--
function _instance:has_cincludes(includes, opt)
opt = opt or {}
@@ -1555,7 +1555,7 @@ end
-- @param includes the includes
-- @param opt the argument options, e.g. { defines = ""}
--
--- @return true or false
+-- @return true or false, errors
--
function _instance:has_cxxincludes(includes, opt)
opt = opt or {}
@@ -1569,7 +1569,7 @@ end
-- @param snippets the snippets
-- @param opt the argument options, e.g. { includes = ""}
--
--- @return true or false
+-- @return true or false, errors
--
function _instance:check_csnippets(snippets, opt)
opt = opt or {}
@@ -1583,7 +1583,7 @@ end
-- @param snippets the snippets
-- @param opt the argument options, e.g. { includes = ""}
--
--- @return true or false
+-- @return true or false, errors
--
function _instance:check_cxxsnippets(snippets, opt)
opt = opt or {}
diff --git a/xmake/modules/lib/detect/check_cxsnippets.lua b/xmake/modules/lib/detect/check_cxsnippets.lua
index 5352301b0..ea0e941d3 100644
--- a/xmake/modules/lib/detect/check_cxsnippets.lua
+++ b/xmake/modules/lib/detect/check_cxsnippets.lua
@@ -143,9 +143,9 @@ end
-- @return true or false
--
-- @code
--- local ok = check_cxsnippets("void test() {}")
--- local ok = check_cxsnippets({"void test(){}", "#define TEST 1"}, {types = "wchar_t", includes = "stdio.h"})
--- local ok = check_cxsnippets({snippet_name = "void test(){}", "#define TEST 1"}, {types = "wchar_t", includes = "stdio.h"})
+-- local ok, output_or_errors = check_cxsnippets("void test() {}")
+-- local ok, output_or_errors = check_cxsnippets({"void test(){}", "#define TEST 1"}, {types = "wchar_t", includes = "stdio.h"})
+-- local ok, output_or_errors = check_cxsnippets({snippet_name = "void test(){}", "#define TEST 1"}, {types = "wchar_t", includes = "stdio.h"})
-- @endcode
--
function main(snippets, opt)
@@ -265,6 +265,6 @@ function main(snippets, opt)
if errors and option.get("diagnosis") and #tostring(errors) > 0 then
cprint("${color.warning}checkinfo:${clear dim} %s", errors)
end
- return ok, output
+ return ok, ok and output or errors
end
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua
index ba918e7f4..63e4c0d80 100644
--- a/xmake/modules/private/action/require/impl/actions/download.lua
+++ b/xmake/modules/private/action/require/impl/actions/download.lua
@@ -159,7 +159,7 @@ function _download(package, url, sourcedir, url_alias, url_excludes)
-- create an empty source directory if do not extract package file
os.tryrm(sourcedir)
os.mkdir(sourcedir)
- raise("cannot extract %s", packagefile)
+ raise("cannot extract %s, maybe missing extractor or invalid package file!", packagefile)
end
-- save original file path
@@ -230,6 +230,7 @@ function main(package)
end
-- download url
+ local allerrors = {}
ok = try
{
function ()
@@ -248,8 +249,12 @@ function main(package)
function (errors)
-- show or save the last errors
- if errors and (option.get("verbose") or option.get("diagnosis")) then
- cprint("${dim color.error}error: ${clear}%s", errors)
+ if errors then
+ if (option.get("verbose") or option.get("diagnosis")) then
+ cprint("${dim color.error}error: ${clear}%s", errors)
+ else
+ table.insert(allerrors, errors)
+ end
end
-- trace
@@ -275,7 +280,11 @@ function main(package)
cprint(" ${bright}- %s", table.concat(searchnames:to_array(), ", "))
cprint("and we can run `xmake g --pkg_searchdirs=/xxx` to set the search directories.")
end
- raise("download failed!")
+ if #allerrors then
+ raise(table.concat(allerrors, "\n"))
+ else
+ raise("download failed!")
+ end
end
end
}
diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua
index 8e8d92d39..9dcbc537b 100644
--- a/xmake/modules/private/action/require/impl/actions/install.lua
+++ b/xmake/modules/private/action/require/impl/actions/install.lua
@@ -278,7 +278,16 @@ function main(package)
-- failed
if not package:requireinfo().optional then
if os.isfile(errorfile) then
- print("if you want to get verbose errors, please see:")
+ if errors then
+ print("")
+ for idx, line in ipairs(errors:split("\n")) do
+ print(line)
+ if idx > 16 then
+ break
+ end
+ end
+ end
+ cprint("if you want to get more verbose errors, please see:")
cprint(" -> ${bright}%s", errorfile)
end
raise("install failed!")