diff options
| author | ruki <[email protected]> | 2016-04-11 14:08:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-04-11 14:08:47 +0800 |
| commit | 833bfb207b3f924eaa81feb496cf74e6223d0041 (patch) | |
| tree | 0b1774ba14cbe63ecb6eb347deea19975f2c8554 /xmake/core/sandbox/modules | |
| parent | 71296f55db2d5b0a9249592c3428797708cd0683 (diff) | |
add new tool module
Diffstat (limited to 'xmake/core/sandbox/modules')
| -rw-r--r-- | xmake/core/sandbox/modules/_g.lua | 25 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import.lua | 23 |
2 files changed, 27 insertions, 21 deletions
diff --git a/xmake/core/sandbox/modules/_g.lua b/xmake/core/sandbox/modules/_g.lua new file mode 100644 index 000000000..124f65c61 --- /dev/null +++ b/xmake/core/sandbox/modules/_g.lua @@ -0,0 +1,25 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> +-- +-- Copyright (C) 2015 - 2016, ruki All rights reserved. +-- +-- @author ruki +-- @file _g.lua +-- + +-- return new instance +return {} + diff --git a/xmake/core/sandbox/modules/import.lua b/xmake/core/sandbox/modules/import.lua index 2b423613c..2a01f7282 100644 --- a/xmake/core/sandbox/modules/import.lua +++ b/xmake/core/sandbox/modules/import.lua @@ -69,27 +69,8 @@ function sandbox_import._loadfile(filepath, instance) return nil, errors end - -- backup the scope variables first - local scope_public = getfenv(instance:script()) - local scope_backup = {} - table.copy2(scope_backup, scope_public) - - -- load module with sandbox - local ok, errors = sandbox.load(instance:script()) - if not ok then - return nil, errors - end - - -- only export new public functions - local result = {} - for k, v in pairs(scope_public) do - if type(v) == "function" and not k:startswith("_") and scope_backup[k] == nil then - result[k] = v - end - end - - -- get module - return result + -- import module + return instance:import() end -- load module without sandbox |
