summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-01-02 00:22:23 +0800
committerruki <[email protected]>2021-01-02 00:22:23 +0800
commit961bea6df23323794a4435d4fee17575588cc6d8 (patch)
tree9efdc3b2781ea3c931782d695fa649b5e2621a5f
parentc8c6c07c028c3ae4e047154194f42af2e2253595 (diff)
improve displayname
-rw-r--r--tests/projects/package/depconfigs/xmake.lua2
-rw-r--r--xmake/actions/require/impl/package.lua40
2 files changed, 30 insertions, 12 deletions
diff --git a/tests/projects/package/depconfigs/xmake.lua b/tests/projects/package/depconfigs/xmake.lua
index b07f12fdd..3f949375d 100644
--- a/tests/projects/package/depconfigs/xmake.lua
+++ b/tests/projects/package/depconfigs/xmake.lua
@@ -1,7 +1,7 @@
add_requires("libpng", "libtiff", {system = false, configs = {vs_runtime = "MD"}})
add_requires("libwebp")
-add_requireconfs("libwebp", {system = false, configs = {vs_runtime = "MD"}})
+add_requireconfs("libwebp", {system = false, configs = {shared = true, vs_runtime = "MD"}})
add_requireconfs("libpng.zlib", {system = false, configs = {cxflags = "-DTEST1"}, version = "1.2.10"})
add_requireconfs("libtiff.*", {system = false, configs = {cxflags = "-DTEST2"}})
add_requireconfs("libwebp.**", {system = false, configs = {cxflags = "-DTEST3"}})
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index 8d7ffcfff..92ad78c7e 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -460,7 +460,13 @@ function _load_package(packagename, requireinfo, opt)
package:requireinfo_set(requireinfo)
-- save display name
- package:displayname_set(opt.requirepath)
+ local packageid = _memcache():get2("packageids", packagename)
+ local displayname = packagename
+ if packageid then
+ displayname = displayname .. "#" .. tostring(packageid)
+ end
+ _memcache():set2("packageids", packagename, (packageid or 0) + 1)
+ package:displayname_set(displayname)
-- add some builtin configurations to package
_add_package_configurations(package)
@@ -572,16 +578,28 @@ function _sort_packages_urls(packages)
end
end
--- get package status string
-function _get_package_status_str(package)
- local status = {}
- if package:debug() then
- table.insert(status, "debug")
- end
+-- get package configs string
+function _get_package_configs_str(package)
+ local configs = {}
if package:optional() then
- table.insert(status, "optional")
+ table.insert(configs, "optional")
+ end
+ local requireinfo = package:requireinfo()
+ if requireinfo then
+ for k, v in pairs(requireinfo.configs) do
+ if type(v) == "boolean" then
+ table.insert(configs, k .. ":" .. (v and "y" or "n"))
+ else
+ table.insert(configs, k .. ":" .. v)
+ end
+ end
+ end
+ local configs_str = #configs > 0 and "(" .. table.concat(configs, ", ") .. ")" or ""
+ local limitwidth = os.getwinsize().width / 2
+ if #configs_str > limitwidth then
+ configs_str = configs_str:sub(1, limitwidth) .. " ..)"
end
- return #status > 0 and "(" .. table.concat(status, ", ") .. ")" or ""
+ return configs_str
end
-- get user confirm
@@ -627,12 +645,12 @@ function _get_confirm(packages)
local group = package:group()
if group and packages_group[group] and #packages_group[group] > 1 then
for idx, package_in_group in ipairs(packages_group[group]) do
- cprint(" ${yellow}%s${clear} %s %s %s", idx == 1 and "->" or " or", package_in_group:requirepath(), package_in_group:version_str() or "", _get_package_status_str(package_in_group))
+ cprint(" ${yellow}%s${clear} %s %s %{dim}%s", idx == 1 and "->" or " or", package_in_group:requirepath(), package_in_group:version_str() or "", _get_package_configs_str(package_in_group))
packages_showed[tostring(package_in_group)] = true
end
packages_group[group] = nil
else
- cprint(" ${yellow}->${clear} %s %s %s", package:displayname(), package:version_str() or "", _get_package_status_str(package))
+ cprint(" ${yellow}->${clear} %s %s ${dim}%s", package:displayname(), package:version_str() or "", _get_package_configs_str(package))
packages_showed[tostring(package)] = true
end
end