summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-01-09 00:51:57 +0800
committerruki <[email protected]>2025-01-09 00:51:57 +0800
commit94918773a3a33398b2ee0dbf23c00199c164a50c (patch)
tree1f6d83a566b73f84744b92035b5e17f53588c890
parented685ecd74c5267781713f3bd00ce4e4e40b27d7 (diff)
remove config.has
-rw-r--r--xmake/core/project/config.lua17
-rw-r--r--xmake/core/project/project.lua13
-rw-r--r--xmake/core/sandbox/modules/has_config.lua12
3 files changed, 23 insertions, 19 deletions
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index d4d510c09..789eada09 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -296,23 +296,6 @@ function config.is_value(name, ...)
return false
end
--- has the given configs?
-function config.has(names, opt)
- opt = opt or {}
- for _, name in ipairs(names) do
- if name and type(name) == "string" then
- local value = config.get(name)
- if value == nil and opt.namespace then
- value = config.get(opt.namespace .. "::" .. name)
- end
- if value then
- return true
- end
- end
- end
- return false
-end
-
-- dump the configure
function config.dump()
if not option.get("quiet") then
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua
index ee2b55a63..2fac8f50b 100644
--- a/xmake/core/project/project.lua
+++ b/xmake/core/project/project.lua
@@ -113,7 +113,18 @@ end
-- some configs are enabled?
function project._api_has_config(interp, ...)
- return config.has(table.pack(...), {namespace = interp:namespace()})
+ local names = table.pack(...)
+ local namespace = interp:namespace()
+ for _, name in ipairs(names) do
+ local value = config.get(name)
+ if value == nil and namespace then
+ value = config.get(namespace .. "::" .. name)
+ end
+ if value then
+ return true
+ end
+ end
+ return false
end
-- some packages are enabled?
diff --git a/xmake/core/sandbox/modules/has_config.lua b/xmake/core/sandbox/modules/has_config.lua
index 2cf5a86d0..e1538a504 100644
--- a/xmake/core/sandbox/modules/has_config.lua
+++ b/xmake/core/sandbox/modules/has_config.lua
@@ -28,6 +28,16 @@ return function (...)
if instance then
namespace = instance:namespace()
end
- return config.has(table.pack(...), {namespace = namespace})
+ local names = table.pack(...)
+ for _, name in ipairs(names) do
+ local value = config.get(name)
+ if value == nil and namespace then
+ value = config.get(namespace .. "::" .. name)
+ end
+ if value then
+ return true
+ end
+ end
+ return false
end