summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-09 23:07:50 +0800
committerruki <[email protected]>2023-11-09 23:07:50 +0800
commitd2b88ed47beac7188c95ea67947852378608e8a0 (patch)
tree2d2aaf572ddc45a7cd9c0898faf3a4b560b61275
parentbe11a41f594e743743dd34abf52e28adc6219f10 (diff)
improve add scopeapis
-rw-r--r--xmake/core/base/interpreter.lua12
-rw-r--r--xmake/includes/xpack/xmake.lua7
2 files changed, 9 insertions, 10 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 7ba677a8f..e4d6c3046 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -1897,11 +1897,15 @@ function interpreter:api_interp_add_scopeapis(...)
else
extra_config = nil
end
- local kind = "values"
- if extra_config and extra_config.kind then
- kind = extra_config.kind
+ if extra_config and #apis == 0 then
+ self:api_define(extra_config)
+ else
+ local kind = "values"
+ if extra_config and extra_config.kind then
+ kind = extra_config.kind
+ end
+ return self:api_define({[kind] = apis})
end
- return self:api_define({[kind] = apis})
end
-- get api function
diff --git a/xmake/includes/xpack/xmake.lua b/xmake/includes/xpack/xmake.lua
index 59c813531..30efaf2ac 100644
--- a/xmake/includes/xpack/xmake.lua
+++ b/xmake/includes/xpack/xmake.lua
@@ -52,9 +52,4 @@ local apis = {
"xpack.on_uninstallcmd"
}
}
-for _, apiname in ipairs(apis.values) do
- interp_add_scopeapis(apiname, {kind = "values"})
-end
-for _, apiname in ipairs(apis.script) do
- interp_add_scopeapis(apiname, {kind = "script"})
-end
+interp_add_scopeapis(apis)