diff options
| author | ruki <[email protected]> | 2024-09-16 22:43:31 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-09-16 22:43:31 +0800 |
| commit | f9b056838089fad93ef2bd09d520b9503c27a35f (patch) | |
| tree | a6605199f82879edeff70839f38cdd90fb7e4b8d | |
| parent | be182710a90a20276ac7f2ff76547ddf8e63254e (diff) | |
check policy values
| -rw-r--r-- | xmake/core/project/policy.lua | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua index acfcc2a0e..0647fa091 100644 --- a/xmake/core/project/policy.lua +++ b/xmake/core/project/policy.lua @@ -85,7 +85,7 @@ function policy.policies() -- Force C++ modules fallback dependency scanner for msvc ["build.c++.msvc.fallbackscanner"] = {description = "Force msvc fallback module dependency scanner.", default = false, type = "boolean"}, -- Set the default vs runtime, e.g. MT, MD - ["build.c++.msvc.runtime"] = {description = "Set the default vs runtime.", default = "MT", type = "string"}, + ["build.c++.msvc.runtime"] = {description = "Set the default vs runtime.", default = "MT", type = "string", values = {"MT", "MD"}}, -- Force C++ modules fallback dependency scanner for gcc ["build.c++.gcc.fallbackscanner"] = {description = "Force gcc fallback module dependency scanner.", default = false, type = "boolean"}, -- Force to enable new cxx11 abi in C++ modules for gcc @@ -179,7 +179,25 @@ function policy.check(name, value) else local valtype = type(value) if valtype ~= defined_policy.type then - utils.warning("policy(%s): invalid value type(%s), it shound be '%s'!", name, valtype, defined_policy.type) + utils.warning("policy(%s): invalid value type(%s), it shound be '%s'!", + name, valtype, defined_policy.type) + end + if defined_policy.values then + local found = false + for _, policy_value in ipairs(defined_policy.values) do + if tostring(value) == tostring(policy_value) then + found = true + break + end + end + if not found then + local values = {} + for _, policy_value in ipairs(defined_policy.values) do + table.insert(values, tostring(policy_value)) + end + utils.warning("policy(%s): invalid value(%s)), please set value from {%s}.", + name, value, table.concat(values, ", ")) + end end end return value |
