diff options
| author | ruki <[email protected]> | 2015-05-31 11:32:38 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-05-31 11:32:38 +0800 |
| commit | 529a623ed4eadb802b5174db0957c595af32d5e5 (patch) | |
| tree | 361a0e7fd30f73af0395886e098d2a3ca2b7164e /xmake/scripts/action/_lua.lua | |
| parent | ad9d27ef9a74603063755857b0a0191e486c1e8d (diff) | |
add some tools
Diffstat (limited to 'xmake/scripts/action/_lua.lua')
| -rw-r--r-- | xmake/scripts/action/_lua.lua | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/xmake/scripts/action/_lua.lua b/xmake/scripts/action/_lua.lua index 6389a6925..34f45e84f 100644 --- a/xmake/scripts/action/_lua.lua +++ b/xmake/scripts/action/_lua.lua @@ -25,8 +25,10 @@ local _lua = _lua or {} -- load modules local os = require("base/os") +local path = require("base/path") local utils = require("base/utils") local config = require("base/config") +local string = require("base/string") -- done the given config function _lua.done() @@ -41,13 +43,29 @@ function _lua.done() end -- the arguments - local arguments = options.arguments + local arguments = options.arguments or {} + if type(arguments) ~= "table" then + 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 + + -- trace + utils.verbose("script: %s", options.script) + -- load and run string local script = loadstring(options.script) if script then + setfenv(script, newenv) return script(arguments) end else @@ -66,6 +84,7 @@ function _lua.done() if os.isfile(file) then local script = loadfile(file) if script then + setfenv(script, newenv) return script(arguments) end end |
