summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/core/base/interpreter.lua12
-rw-r--r--xmake/core/base/sandbox.lua7
2 files changed, 16 insertions, 3 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 1da93d5a0..869d20b99 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -482,6 +482,16 @@ function interpreter.mtimes(self)
return self._PRIVATE._MTIMES
end
+-- get filter
+function interpreter.filter(self)
+
+ -- check
+ assert(self and self._PRIVATE)
+
+ -- get filter
+ return self._PRIVATE._FILTER
+end
+
-- set filter
function interpreter.filter_set(self, filter)
@@ -792,7 +802,7 @@ function interpreter.api_register_set_script(self, scope_kind, prefix, ...)
local implementation = function (self, scope, name, script)
-- bind script and get new script with sandbox
- local newscript, errors = sandbox.bind(script, self._PRIVATE._FILTER)
+ local newscript, errors = sandbox.bind(script, self)
if not newscript then
utils.error("set_%s(\"%s\"): %s", scope, name, errors)
utils.abort()
diff --git a/xmake/core/base/sandbox.lua b/xmake/core/base/sandbox.lua
index 8654e6290..570a22fa4 100644
--- a/xmake/core/base/sandbox.lua
+++ b/xmake/core/base/sandbox.lua
@@ -140,7 +140,10 @@ function sandbox._init()
end
-- bind script into the sandbox
-function sandbox.bind(script, filter)
+function sandbox.bind(script, interp)
+
+ -- check
+ assert(script and interp)
-- init self
local self = sandbox._init()
@@ -149,7 +152,7 @@ function sandbox.bind(script, filter)
assert(self and self._PUBLIC and self._PRIVATE)
-- save filter
- self._PRIVATE._FILTER = filter
+ self._PRIVATE._FILTER = interp:filter()
-- this script is file? load it first
if type(script) == "string" then