diff options
| author | ruki <[email protected]> | 2025-04-19 00:42:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-08-28 11:35:53 +0800 |
| commit | 9de0be5040e3feda8aface1174cd1e6fc696fe4e (patch) | |
| tree | b9256e58a7acfe57d8d6252277f8247b74bfa56d /xmake/core/main.lua | |
| parent | 5c371c00ead44993b83f26a754c32a3f8a799aa4 (diff) | |
bind sandbox
Diffstat (limited to 'xmake/core/main.lua')
| -rw-r--r-- | xmake/core/main.lua | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/xmake/core/main.lua b/xmake/core/main.lua index 632165717..826a2c3d8 100644 --- a/xmake/core/main.lua +++ b/xmake/core/main.lua @@ -41,6 +41,7 @@ local project = require("project/project") local localcache = require("cache/localcache") local profiler = require("base/profiler") local debugger = require("base/debugger") +local sandbox = require("sandbox/sandbox") -- init the option menu local menu = @@ -276,15 +277,27 @@ end -- run thread function main._run_thread(callinfo_str) + + -- get callback info local callinfo, errors = string.deserialize(callinfo_str) if not callinfo then return false, string.format("invalid thread callinfo, %s!", errors or "unknown") end local callback = callinfo.callback - if callback then - callback(callinfo.argv) + if not callback then + return false, string.format("no callback") end - return true + + -- bind sandbox +-- local sandbox_inst, errors = sandbox.new(callback, { +-- filter = interp:filter(), rootdir = interp:rootdir(), namespace = interp:namespace()}) + local sandbox_inst, errors = sandbox.new(callback) + if not sandbox_inst then + return false, errors + end + + -- do callback + return sandbox.load(sandbox_inst:script(), table.unpack(callinfo.argv or {})) end -- the main entry function |
