summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-10-12 16:42:59 +0800
committerGitHub <[email protected]>2023-10-12 16:42:59 +0800
commit3f24b53574e20ced12f4199ec9e64dccc8c383d3 (patch)
treefb20b03d4c67d582ec304f79fa4b946aae885e26
parent9449c51bf2e709ba7807093a6876cf4eadf9fbac (diff)
parent768183611c9334c7727233e5a8f7a78c38aa03db (diff)
Merge pull request #4275 from xmake-io/interp
Support custom scope api
-rw-r--r--tests/apis/custom_scopeapis/.gitignore8
-rw-r--r--tests/apis/custom_scopeapis/src/main.cpp9
-rw-r--r--tests/apis/custom_scopeapis/xmake.lua31
-rw-r--r--xmake/core/base/interpreter.lua43
-rw-r--r--xmake/core/sandbox/modules/import/core/project/project.lua22
-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
20 files changed, 159 insertions, 70 deletions
diff --git a/tests/apis/custom_scopeapis/.gitignore b/tests/apis/custom_scopeapis/.gitignore
new file mode 100644
index 000000000..152105761
--- /dev/null
+++ b/tests/apis/custom_scopeapis/.gitignore
@@ -0,0 +1,8 @@
+# Xmake cache
+.xmake/
+build/
+
+# MacOS Cache
+.DS_Store
+
+
diff --git a/tests/apis/custom_scopeapis/src/main.cpp b/tests/apis/custom_scopeapis/src/main.cpp
new file mode 100644
index 000000000..7c435d251
--- /dev/null
+++ b/tests/apis/custom_scopeapis/src/main.cpp
@@ -0,0 +1,9 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ cout << "hello world!" << endl;
+ return 0;
+}
diff --git a/tests/apis/custom_scopeapis/xmake.lua b/tests/apis/custom_scopeapis/xmake.lua
new file mode 100644
index 000000000..3f20836a5
--- /dev/null
+++ b/tests/apis/custom_scopeapis/xmake.lua
@@ -0,0 +1,31 @@
+add_rules("mode.debug", "mode.release")
+
+interp_add_scopeapis("myscope.set_name", "myscope.add_list", {kind = "values"})
+interp_add_scopeapis("myscope.on_script", {kind = "script"})
+
+myscope("hello")
+ set_name("foo")
+ add_list("value1", "value2")
+ on_script(function ()
+ print("hello")
+ end)
+
+target("test")
+ set_kind("binary")
+ add_files("src/*.cpp")
+ on_config(function (target)
+ import("core.project.project")
+ local myscope = project.scope("myscope")
+ for name, scope in pairs(myscope) do
+ print("myscope(%s)", name)
+ print(" name: %s", scope:get("name"))
+ print(" list: %s", table.concat(scope:get("list"), ", "))
+ print(" script:")
+ local script = scope:get("script")
+ if script then
+ script()
+ end
+ end
+ end)
+
+
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 4733a3369..6060fc319 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_add_scopeapis", interpreter.api_interp_add_scopeapis)
-- 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,22 @@ function interpreter:api_builtin_get_scopename()
end
end
+-- the interpreter api: interp_add_scopeapis()
+function interpreter:api_interp_add_scopeapis(...)
+ local apis = {...}
+ local extra_config = apis[#apis]
+ if table.is_dictionary(extra_config) then
+ table.remove(apis)
+ else
+ extra_config = nil
+ end
+ local kind = "values"
+ if extra_config and extra_config.kind then
+ kind = extra_config.kind
+ end
+ return self:api_define({[kind] = apis})
+end
+
-- get api function
function interpreter:api_func(apiname)
assert(self and self._PUBLIC and apiname)
diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua
index 6d35abaa0..b8feddefc 100644
--- a/xmake/core/sandbox/modules/import/core/project/project.lua
+++ b/xmake/core/sandbox/modules/import/core/project/project.lua
@@ -254,5 +254,27 @@ function sandbox_core_project.chdir(projectdir, projectfile)
config._DIRECTORY = nil
end
+-- get scope
+function sandbox_core_project.scope(scopename)
+ local cachekey = "scope." .. scopename
+ local scope = project._memcache():get(cachekey)
+ if not scope then
+
+ -- load the project file first if has not been loaded?
+ local ok, errors = project._load()
+ if not ok then
+ raise("load project failed, %s", errors or "unknown")
+ end
+
+ -- load scope
+ scope, errors = project._load_scope(scopename, true, false)
+ if not scope then
+ raise("load scope(%s) failed, %s", scopename, errors or "unknown")
+ end
+ project._memcache():set(cachekey, scope)
+ end
+ return scope
+end
+
-- return module
return sandbox_core_project
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