diff options
Diffstat (limited to 'xmake/plugins/lua/xmake.lua')
| -rw-r--r-- | xmake/plugins/lua/xmake.lua | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua index b5d80e9cd..b5043fad2 100644 --- a/xmake/plugins/lua/xmake.lua +++ b/xmake/plugins/lua/xmake.lua @@ -33,6 +33,7 @@ task("lua") -- imports import("core.base.option") + import("core.sandbox.module") import("core.sandbox.sandbox") -- list all lua scripts? @@ -68,8 +69,21 @@ task("lua") import("scripts." .. script, {anonymous = true})(unpack(option.get("arguments") or {})) else - -- run modules (xmake lua core.xxx.xxx) - print(import(script, {anonymous = true})(unpack(option.get("arguments") or {}))) + -- attempt to find the builtin module + local object = nil + for _, name in ipairs(script:split("%.")) do + object = object and object[name] or module.get(name) + if not object then + break + end + end + if object then + -- run builtin modules (xmake lua core.xxx.xxx) + print(object(unpack(option.get("arguments") or {}))) + else + -- run imported modules (xmake lua core.xxx.xxx) + print(import(script, {anonymous = true})(unpack(option.get("arguments") or {}))) + end end else -- enter interactive mode |
