summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-09-12 22:50:39 +0800
committerruki <[email protected]>2018-09-12 11:03:55 +0800
commit0a8a275f8cb9a51446746f796031882dfc8381ae (patch)
tree4aa0f38d8fcf31804f16e313a144ba430e88e302
parent6638fb5f62e95b465305914953e38233d49a8856 (diff)
check unsupported packages
-rw-r--r--tests/projects/package/basic/xmake.lua2
-rw-r--r--xmake/actions/require/list.lua16
-rw-r--r--xmake/actions/require/package.lua21
-rw-r--r--xmake/core/package/package.lua12
4 files changed, 43 insertions, 8 deletions
diff --git a/tests/projects/package/basic/xmake.lua b/tests/projects/package/basic/xmake.lua
index 30dfe46dd..4ac3497a8 100644
--- a/tests/projects/package/basic/xmake.lua
+++ b/tests/projects/package/basic/xmake.lua
@@ -2,7 +2,7 @@
-- requires
add_requires("tbox master")
add_requires("zlib >=1.2.11", {optional = true})
-add_requires("pcre2", {system = false})
+add_requires("pcre2", "luajit", {system = false})
-- add modes
add_rules("mode.debug", "mode.release")
diff --git a/xmake/actions/require/list.lua b/xmake/actions/require/list.lua
index 297de7d97..51f7d86fa 100644
--- a/xmake/actions/require/list.lua
+++ b/xmake/actions/require/list.lua
@@ -35,7 +35,7 @@ function _from(instance)
if fetchinfo then
return ", ${green}" .. fetchfrom .. "${clear}"
elseif #instance:urls() > 0 then
- return ", ${yellow}remote${clear}"
+ return instance:supported() and format(", ${yellow}remote${clear}(in %s)", instance:repo():name()) or format(", ${yellow}remote${clear}(${red}unsupported${clear} in %s)", instance:repo():name())
elseif instance:from("system") then
return ", ${red}missing${clear}"
else
@@ -43,6 +43,14 @@ function _from(instance)
end
end
+-- get package info
+function _info(instance)
+ local info = instance:version_str() and instance:version_str() or "no version"
+ info = info .. _from(instance)
+ info = info .. (instance:optional() and ", ${yellow}optional${clear}" or "")
+ return info
+end
+
-- list packages
function main()
@@ -65,13 +73,11 @@ function main()
-- list all packages
for _, instance in ipairs(package.load_packages(requires, requires_extra)) do
- local requireinfo = instance:requireinfo() or {}
local packageopt = project.option(instance:alias() or instance:name())
if packageopt then
- cprint(" ${magenta}require${clear}(%s): %s%s%s", requireinfo.originstr, ifelse(instance:version_str(), instance:version_str(), "no version"), _from(instance), ifelse(requireinfo.optional, ", ${yellow}optional${clear}", ""))
+ cprint(" ${magenta}require${clear}(%s): %s", instance:requireinfo().originstr, _info(instance))
for _, dep in ipairs(instance:orderdeps()) do
- requireinfo = dep:requireinfo() or {}
- cprint(" -> ${magenta}dep${clear}(%s): %s%s%s", requireinfo.originstr, ifelse(dep:version_str(), dep:version_str(), "no version"), _from(dep), ifelse(requireinfo.optional, ", ${yellow}optional${clear}", ""))
+ cprint(" -> ${magenta}dep${clear}(%s): %s", dep:requireinfo().originstr, _info(dep))
end
end
end
diff --git a/xmake/actions/require/package.lua b/xmake/actions/require/package.lua
index be82e9460..b95b7bcc4 100644
--- a/xmake/actions/require/package.lua
+++ b/xmake/actions/require/package.lua
@@ -340,13 +340,30 @@ end
-- get user confirm
function _get_confirm(packages)
- -- init confirmed packages
+ -- init confirmed and not supported packages
local confirmed_packages = {}
+ local not_supported_packages = {}
for _, package in ipairs(packages) do
if (option.get("force") or not package:exists()) and (#package:urls() > 0 or package:script("install")) then
- table.insert(confirmed_packages, package)
+ if package:supported() then
+ table.insert(confirmed_packages, package)
+ else
+ table.insert(not_supported_packages, package)
+ end
+ end
+ end
+
+ -- exists not supported packages?
+ if #not_supported_packages > 0 then
+ -- show tips
+ cprint("${bright red}note: ${default red}the following packages are unsupported for $(plat)/$(arch)!")
+ for _, package in ipairs(not_supported_packages) do
+ print(" -> %s %s", package:name(), package:version_str() or "")
end
+ raise()
end
+
+ -- no confirmed packages?
if #confirmed_packages == 0 then
return true
end
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 8c54c941b..5888bff80 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -246,6 +246,18 @@ function _instance:requireinfo_set(requireinfo)
self._REQUIREINFO = requireinfo
end
+-- is optional package?
+function _instance:optional()
+ local requireinfo = self:requireinfo()
+ return requireinfo and requireinfo.optional or false
+end
+
+-- is supported package?
+function _instance:supported()
+ -- attempt to get the build script with the current plat/arch
+ return self:script("build") ~= nil
+end
+
-- get xxx_script
function _instance:script(name, generic)