summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-10-12 22:46:20 +0800
committerruki <[email protected]>2023-10-12 22:46:20 +0800
commit09ad995e7113f2273b5e441905a914198e23927b (patch)
tree0b88d1b20bfbfda75aa52d0ec26ae2f6f2ad86dd
parent9449c51bf2e709ba7807093a6876cf4eadf9fbac (diff)
rename interp interfaces
-rw-r--r--xmake/core/base/interpreter.lua32
-rw-r--r--xmake/includes/check_cflags.lua8
-rw-r--r--xmake/includes/check_cfuncs.lua8
-rw-r--r--xmake/includes/check_cincludes.lua8
-rw-r--r--xmake/includes/check_csnippets.lua8
-rw-r--r--xmake/includes/check_ctypes.lua8
-rw-r--r--xmake/includes/check_cxxflags.lua8
-rw-r--r--xmake/includes/check_cxxfuncs.lua8
-rw-r--r--xmake/includes/check_cxxincludes.lua8
-rw-r--r--xmake/includes/check_cxxsnippets.lua8
-rw-r--r--xmake/includes/check_cxxtypes.lua8
-rw-r--r--xmake/includes/check_features.lua8
-rw-r--r--xmake/includes/check_links.lua8
-rw-r--r--xmake/includes/check_macros.lua8
-rw-r--r--xmake/includes/check_syslinks.lua8
-rw-r--r--xmake/includes/find_and_add_packages.lua4
16 files changed, 78 insertions, 70 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 4733a3369..8a4672284 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -688,10 +688,13 @@ function interpreter.new()
instance:api_register(nil, "add_subdirs", interpreter.api_builtin_add_subdirs)
instance:api_register(nil, "add_subfiles", interpreter.api_builtin_add_subfiles)
instance:api_register(nil, "set_xmakever", interpreter.api_builtin_set_xmakever)
- instance:api_register(nil, "save_scope", interpreter.api_builtin_save_scope)
- instance:api_register(nil, "restore_scope",interpreter.api_builtin_restore_scope)
- instance:api_register(nil, "get_scopekind",interpreter.api_builtin_get_scopekind)
- instance:api_register(nil, "get_scopename",interpreter.api_builtin_get_scopename)
+
+ -- register the interpreter interfaces
+ instance:api_register(nil, "interp_save_scope", interpreter.api_interp_save_scope)
+ instance:api_register(nil, "interp_restore_scope", interpreter.api_interp_restore_scope)
+ instance:api_register(nil, "interp_get_scopekind", interpreter.api_interp_get_scopekind)
+ instance:api_register(nil, "interp_get_scopename", interpreter.api_interp_get_scopename)
+ instance:api_register(nil, "interp_register_apis", interpreter.api_interp_register_apis)
-- register the builtin modules
for module_name, module in pairs(interpreter._builtin_modules()) do
@@ -1798,9 +1801,9 @@ function interpreter:api_builtin_add_subfiles(...)
deprecated.add("includes(%s)", "add_subfiles(%s)", table.concat(files, ", "), table.concat(files, ", "))
end
--- the builtin api: save_scope()
+-- the interpreter api: interp_save_scope()
-- save the current scope
-function interpreter:api_builtin_save_scope()
+function interpreter:api_interp_save_scope()
assert(self and self._PRIVATE)
-- the scopes
@@ -1815,9 +1818,9 @@ function interpreter:api_builtin_save_scope()
table.insert(self._PRIVATE._SCOPES_SAVED, scope)
end
--- the builtin api: restore_scope()
+-- the interpreter api: interp_restore_scope()
-- restore the current scope
-function interpreter:api_builtin_restore_scope()
+function interpreter:api_interp_restore_scope()
assert(self and self._PRIVATE)
-- the scopes
@@ -1836,14 +1839,14 @@ function interpreter:api_builtin_restore_scope()
end
end
--- the builtin api: get_scopekind()
-function interpreter:api_builtin_get_scopekind()
+-- the interpreter api: interp_get_scopekind()
+function interpreter:api_interp_get_scopekind()
local scopes = self._PRIVATE._SCOPES
return scopes._CURRENT_KIND
end
--- the builtin api: get_scopename()
-function interpreter:api_builtin_get_scopename()
+-- the interpreter api: interp_get_scopename()
+function interpreter:api_interp_get_scopename()
local scopes = self._PRIVATE._SCOPES
local scope_kind = scopes._CURRENT_KIND
if scope_kind and scopes[scope_kind] then
@@ -1856,6 +1859,11 @@ function interpreter:api_builtin_get_scopename()
end
end
+-- the interpreter api: interp_register_apis()
+function interpreter:api_interp_register_apis(apis)
+ return self:api_define(apis)
+end
+
-- get api function
function interpreter:api_func(apiname)
assert(self and self._PUBLIC and apiname)
diff --git a/xmake/includes/check_cflags.lua b/xmake/includes/check_cflags.lua
index cc126a31c..5da75b699 100644
--- a/xmake/includes/check_cflags.lua
+++ b/xmake/includes/check_cflags.lua
@@ -28,7 +28,7 @@
function check_cflags(definition, flags, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_defines(definition)
@@ -39,7 +39,7 @@ function check_cflags(definition, flags, opt)
end
end)
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -57,7 +57,7 @@ function configvar_check_cflags(definition, flags, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
if opt.default == nil then
@@ -70,7 +70,7 @@ function configvar_check_cflags(definition, flags, opt)
end
end)
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_cfuncs.lua b/xmake/includes/check_cfuncs.lua
index 98f47a4ad..a7a2cfb22 100644
--- a/xmake/includes/check_cfuncs.lua
+++ b/xmake/includes/check_cfuncs.lua
@@ -34,7 +34,7 @@
function check_cfuncs(definition, funcs, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cfuncs(funcs)
@@ -61,7 +61,7 @@ function check_cfuncs(definition, funcs, opt)
set_warnings(opt.warnings)
end
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -78,7 +78,7 @@ function configvar_check_cfuncs(definition, funcs, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cfuncs(funcs)
@@ -107,7 +107,7 @@ function configvar_check_cfuncs(definition, funcs, opt)
set_warnings(opt.warnings)
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_cincludes.lua b/xmake/includes/check_cincludes.lua
index bc6eac5d9..68ace5980 100644
--- a/xmake/includes/check_cincludes.lua
+++ b/xmake/includes/check_cincludes.lua
@@ -28,7 +28,7 @@
function check_cincludes(definition, includes, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cincludes(includes)
@@ -37,7 +37,7 @@ function check_cincludes(definition, includes, opt)
end
add_defines(definition)
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -53,7 +53,7 @@ function configvar_check_cincludes(definition, includes, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cincludes(includes)
@@ -64,7 +64,7 @@ function configvar_check_cincludes(definition, includes, opt)
set_configvar(defname, defval or 1, {quote = opt.quote})
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_csnippets.lua b/xmake/includes/check_csnippets.lua
index 57f232d45..2e22c3220 100644
--- a/xmake/includes/check_csnippets.lua
+++ b/xmake/includes/check_csnippets.lua
@@ -29,7 +29,7 @@
function check_csnippets(definition, snippets, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_csnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output})
@@ -71,7 +71,7 @@ function check_csnippets(definition, snippets, opt)
end)
end
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -89,7 +89,7 @@ function configvar_check_csnippets(definition, snippets, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_csnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output})
@@ -125,7 +125,7 @@ function configvar_check_csnippets(definition, snippets, opt)
end)
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_ctypes.lua b/xmake/includes/check_ctypes.lua
index 218048a1f..e89345eea 100644
--- a/xmake/includes/check_ctypes.lua
+++ b/xmake/includes/check_ctypes.lua
@@ -28,7 +28,7 @@
function check_ctypes(definition, types, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_ctypes(types)
@@ -49,7 +49,7 @@ function check_ctypes(definition, types, opt)
add_cincludes(opt.includes)
end
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -66,7 +66,7 @@ function configvar_check_ctypes(definition, types, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_ctypes(types)
@@ -89,7 +89,7 @@ function configvar_check_ctypes(definition, types, opt)
add_cincludes(opt.includes)
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_cxxflags.lua b/xmake/includes/check_cxxflags.lua
index 51a073fa3..6b6e78d0f 100644
--- a/xmake/includes/check_cxxflags.lua
+++ b/xmake/includes/check_cxxflags.lua
@@ -28,7 +28,7 @@
function check_cxxflags(definition, flags, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_defines(definition)
@@ -39,7 +39,7 @@ function check_cxxflags(definition, flags, opt)
end
end)
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -57,7 +57,7 @@ function configvar_check_cxxflags(definition, flags, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
if opt.default == nil then
@@ -70,7 +70,7 @@ function configvar_check_cxxflags(definition, flags, opt)
end
end)
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_cxxfuncs.lua b/xmake/includes/check_cxxfuncs.lua
index 4f2d15654..2ac98d799 100644
--- a/xmake/includes/check_cxxfuncs.lua
+++ b/xmake/includes/check_cxxfuncs.lua
@@ -34,7 +34,7 @@
function check_cxxfuncs(definition, funcs, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cxxfuncs(funcs)
@@ -61,7 +61,7 @@ function check_cxxfuncs(definition, funcs, opt)
set_warnings(opt.warnings)
end
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -78,7 +78,7 @@ function configvar_check_cxxfuncs(definition, funcs, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cxxfuncs(funcs)
@@ -107,7 +107,7 @@ function configvar_check_cxxfuncs(definition, funcs, opt)
set_warnings(opt.warnings)
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_cxxincludes.lua b/xmake/includes/check_cxxincludes.lua
index 983e50035..4eff5f53e 100644
--- a/xmake/includes/check_cxxincludes.lua
+++ b/xmake/includes/check_cxxincludes.lua
@@ -28,13 +28,13 @@
function check_cxxincludes(definition, includes, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cxxincludes(includes)
add_defines(definition)
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -50,7 +50,7 @@ function configvar_check_cxxincludes(definition, includes, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cxxincludes(includes)
@@ -58,7 +58,7 @@ function configvar_check_cxxincludes(definition, includes, opt)
set_configvar(defname, defval or 1, {quote = opt.quote})
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_cxxsnippets.lua b/xmake/includes/check_cxxsnippets.lua
index 586a3f1ee..358818844 100644
--- a/xmake/includes/check_cxxsnippets.lua
+++ b/xmake/includes/check_cxxsnippets.lua
@@ -29,7 +29,7 @@
function check_cxxsnippets(definition, snippets, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cxxsnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output})
@@ -71,7 +71,7 @@ function check_cxxsnippets(definition, snippets, opt)
end)
end
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -89,7 +89,7 @@ function configvar_check_cxxsnippets(definition, snippets, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cxxsnippets(definition, snippets, {tryrun = opt.tryrun, output = opt.output})
@@ -125,7 +125,7 @@ function configvar_check_cxxsnippets(definition, snippets, opt)
end)
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_cxxtypes.lua b/xmake/includes/check_cxxtypes.lua
index d833e8439..28964b6f4 100644
--- a/xmake/includes/check_cxxtypes.lua
+++ b/xmake/includes/check_cxxtypes.lua
@@ -28,7 +28,7 @@
function check_cxxtypes(definition, types, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cxxtypes(types)
@@ -49,7 +49,7 @@ function check_cxxtypes(definition, types, opt)
add_cxxincludes(opt.includes)
end
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -66,7 +66,7 @@ function configvar_check_cxxtypes(definition, types, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_cxxtypes(types)
@@ -89,7 +89,7 @@ function configvar_check_cxxtypes(definition, types, opt)
add_cxxincludes(opt.includes)
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_features.lua b/xmake/includes/check_features.lua
index c5e86721f..2dca743fa 100644
--- a/xmake/includes/check_features.lua
+++ b/xmake/includes/check_features.lua
@@ -28,7 +28,7 @@
function check_features(definition, features, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_features(features)
@@ -46,7 +46,7 @@ function check_features(definition, features, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -62,7 +62,7 @@ function configvar_check_features(definition, features, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_features(features)
@@ -82,7 +82,7 @@ function configvar_check_features(definition, features, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_links.lua b/xmake/includes/check_links.lua
index 8f29e30e2..075be25b0 100644
--- a/xmake/includes/check_links.lua
+++ b/xmake/includes/check_links.lua
@@ -28,13 +28,13 @@
function check_links(definition, links, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_links(links)
add_defines(definition)
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -50,7 +50,7 @@ function configvar_check_links(definition, links, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_links(links)
@@ -58,7 +58,7 @@ function configvar_check_links(definition, links, opt)
set_configvar(defname, defval or 1, {quote = opt.quote})
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_macros.lua b/xmake/includes/check_macros.lua
index d5ef3e8af..2235798ec 100644
--- a/xmake/includes/check_macros.lua
+++ b/xmake/includes/check_macros.lua
@@ -30,7 +30,7 @@ function check_macros(definition, macros, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local snippets = {}
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
for _, macro in ipairs(macros) do
@@ -69,7 +69,7 @@ function check_macros(definition, macros, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -84,7 +84,7 @@ function configvar_check_macros(definition, macros, opt)
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
local snippets = {}
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
for _, macro in ipairs(macros) do
@@ -125,7 +125,7 @@ function configvar_check_macros(definition, macros, opt)
add_cxxflags(opt.cxxflags)
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/check_syslinks.lua b/xmake/includes/check_syslinks.lua
index 29e1e2734..ff44f8098 100644
--- a/xmake/includes/check_syslinks.lua
+++ b/xmake/includes/check_syslinks.lua
@@ -28,13 +28,13 @@
function check_syslinks(definition, links, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_syslinks(links)
add_defines(definition)
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
@@ -50,7 +50,7 @@ function configvar_check_syslinks(definition, links, opt)
opt = opt or {}
local optname = opt.name or ("__" .. definition)
local defname, defval = table.unpack(definition:split('='))
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
add_syslinks(links)
@@ -58,7 +58,7 @@ function configvar_check_syslinks(definition, links, opt)
set_configvar(defname, defval or 1, {quote = opt.quote})
end
option_end()
- restore_scope()
+ interp_restore_scope()
if opt.default == nil then
add_options(optname)
else
diff --git a/xmake/includes/find_and_add_packages.lua b/xmake/includes/find_and_add_packages.lua
index eddc15d3a..d0d98fac7 100644
--- a/xmake/includes/find_and_add_packages.lua
+++ b/xmake/includes/find_and_add_packages.lua
@@ -33,14 +33,14 @@
function find_and_add_packages(...)
for _, name in ipairs({...}) do
local optname = "__" .. name
- save_scope()
+ interp_save_scope()
option(optname)
set_showmenu(false)
before_check(function (option)
option:add(find_packages(name))
end)
option_end()
- restore_scope()
+ interp_restore_scope()
add_options(optname)
end
end