summaryrefslogtreecommitdiff
path: root/xmake/plugins/lua/xmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2018-10-07 22:08:05 +0800
committerruki <[email protected]>2018-10-07 22:08:05 +0800
commit800cc0415eee4f97ee34874a2fb14c33f7c660b6 (patch)
treec6f58199b356890e1ee3ea4ac50e6991b2d5bf08 /xmake/plugins/lua/xmake.lua
parent0809d1b2d92c37c8f67f5daccadb061ff933d877 (diff)
improve lua plugin
Diffstat (limited to 'xmake/plugins/lua/xmake.lua')
-rw-r--r--xmake/plugins/lua/xmake.lua18
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