diff options
| author | ruki <[email protected]> | 2015-06-04 14:08:40 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-04 14:08:40 +0800 |
| commit | 1481ec887abef9ce33f4cff93f7a0e6ab04b5741 (patch) | |
| tree | 609560fefb90242fb8deabd525201e00cd078b12 /xmake/scripts/action/_lua.lua | |
| parent | 2f468e35a6c681a22308d1c6d1d37764c386c00c (diff) | |
modify some tool interfaces
Diffstat (limited to 'xmake/scripts/action/_lua.lua')
| -rw-r--r-- | xmake/scripts/action/_lua.lua | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/xmake/scripts/action/_lua.lua b/xmake/scripts/action/_lua.lua index 2f7597b03..f693a1514 100644 --- a/xmake/scripts/action/_lua.lua +++ b/xmake/scripts/action/_lua.lua @@ -49,14 +49,6 @@ function _lua.done() arguments = {} end - -- init new environment - local newenv = {} - setmetatable(newenv, {__index = _G}) - newenv.os = os - newenv.path = path - newenv.utils = utils - newenv.string = string - -- is string script? if options.string then @@ -66,7 +58,6 @@ function _lua.done() -- load and run string local script = loadstring(options.script) if script then - setfenv(script, newenv) return script(arguments) end else @@ -83,10 +74,23 @@ function _lua.done() -- load and run the script file if os.isfile(file) then + + -- load script local script = loadfile(file) if script then - setfenv(script, newenv) - return script(arguments) + + -- load module + local module = script() + if module then + + -- init module + if module.init then + module.init() + end + + -- done module + return module.main(arguments) + end end end end |
