summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-23 22:43:58 +0800
committerruki <[email protected]>2024-01-25 12:09:58 +0800
commita053cf76793f0b0ce3da1d709a0d10db4ec45a30 (patch)
tree104232db560e23810e57f78722871e44306a5e13
parent0b4aa5644e51a62aa69e8d41f81b48629910a5c2 (diff)
improve package runtime type
-rw-r--r--xmake/modules/private/action/require/impl/package.lua16
-rw-r--r--xmake/modules/private/action/require/impl/remove_packages.lua2
2 files changed, 10 insertions, 8 deletions
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index c46a62025..cd61404d0 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -356,14 +356,13 @@ function _add_package_configurations(package)
if package:extraconf("configs", "runtimes", "default") == nil then
local values = {"MT", "MTd", "MD", "MDd",
"c++_static", "c++_shared", "stdc++_static", "stdc++_shared"}
- package:add("configs", "runtimes", {builtin = true, description = "Set the compiler runtimes.", values = values, restrict = function (value)
+ package:add("configs", "runtimes", {builtin = true, description = "Set the compiler runtimes.", type = "string", values = values, restrict = function (value)
local values_set = hashset.from(values)
- if type(value) == "string" then
- if not values_set:has(value) then
- return false
- end
- elseif type(value) == "table" then
- for _, item in ipairs(value) do
+ if type(value) ~= "string" then
+ return false
+ end
+ if value then
+ for _, item in ipairs(value:split(",", {plain = true})) do
if not values_set:has(item) then
return false
end
@@ -539,6 +538,9 @@ function _init_requireinfo(requireinfo, package, opt)
if project.policy("package.inherit_external_configs") then
requireinfo.configs.runtimes = requireinfo.configs.runtimes or get_config("runtimes") or get_config("vs_runtime")
end
+ if type(requireinfo.configs.runtimes) == "table" then
+ requireinfo.configs.runtimes = table.concat(requireinfo.configs.runtimes, ",")
+ end
if requireinfo.configs.lto == nil then
requireinfo.configs.lto = project.policy("build.optimization.lto")
end
diff --git a/xmake/modules/private/action/require/impl/remove_packages.lua b/xmake/modules/private/action/require/impl/remove_packages.lua
index 1a5e99f83..3dcfeecf9 100644
--- a/xmake/modules/private/action/require/impl/remove_packages.lua
+++ b/xmake/modules/private/action/require/impl/remove_packages.lua
@@ -33,7 +33,7 @@ function _get_package_configs_str(manifest_file)
if type(v) == "boolean" then
table.insert(configs, k .. ":" .. (v and "y" or "n"))
else
- table.insert(configs, k .. ":" .. v)
+ table.insert(configs, k .. ":" .. string.serialize(v, {strip = true, indent = false}))
end
end
local configs_str = #configs > 0 and "[" .. table.concat(configs, ", ") .. "]" or ""