diff options
| author | ruki <[email protected]> | 2016-04-13 20:14:48 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-04-13 20:14:48 +0800 |
| commit | 733935aec221c1bce476e7cfea7b5e64d280f71e (patch) | |
| tree | b78a08fbcaab9ed00af970236c71c88d0421cc53 | |
| parent | 28838d094db827cdf7dd951524c6598f90220bae (diff) | |
add make tool
| -rw-r--r-- | xmake/core/sandbox/modules/import.lua | 8 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/tool/tool.lua (renamed from xmake/core/sandbox/modules/import/core/platform/tool.lua) | 19 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 10 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/tonumber.lua | 25 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/tostring.lua | 25 | ||||
| -rw-r--r-- | xmake/core/tool/tool.lua | 17 |
6 files changed, 86 insertions, 18 deletions
diff --git a/xmake/core/sandbox/modules/import.lua b/xmake/core/sandbox/modules/import.lua index 4338ec221..6871abd53 100644 --- a/xmake/core/sandbox/modules/import.lua +++ b/xmake/core/sandbox/modules/import.lua @@ -70,7 +70,13 @@ function sandbox_import._loadfile(filepath, instance) end -- import module - return instance:import(), instance:script() + local result, errors = instance:import() + if not result then + return nil, errors + end + + -- ok + return result, instance:script() end -- load module without sandbox diff --git a/xmake/core/sandbox/modules/import/core/platform/tool.lua b/xmake/core/sandbox/modules/import/core/tool/tool.lua index cc7811e21..f02fb1c15 100644 --- a/xmake/core/sandbox/modules/import/core/platform/tool.lua +++ b/xmake/core/sandbox/modules/import/core/tool/tool.lua @@ -21,37 +21,38 @@ -- -- define module -local sandbox_core_platform_tool = sandbox_core_platform_tool or {} +local sandbox_core_tool = sandbox_core_tool or {} -- load modules -local tool = require("platform/tool") +local tool = require("tool/tool") local platform = require("platform/platform") local raise = require("sandbox/modules/raise") -- get the tool shell name -function sandbox_core_platform_tool.shellname(name) +function sandbox_core_tool.shellname(name) -- get it return platform.tool(name) end -- run the tool -function sandbox_core_platform_tool.run(name, ...) +function sandbox_core_tool.run(name, ...) -- check assert(name) - -- get the tool instance - local instance, errors = tool.get(name) + -- load the tool instance + local instance, errors = tool.load(name) if not instance then raise(errors) end -- run it - if not instance:main(...) then - raise("run tool: %s failed!", name) + local ok, errors = instance:run(...) + if not ok then + raise(errors) end end -- return module -return sandbox_core_platform_tool +return sandbox_core_tool diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 44bef94e1..e6fa1018a 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -172,6 +172,16 @@ function sandbox_os.run(cmd, ...) end end +-- execute shell +function sandbox_os.execute(cmd, ...) + + -- make command + cmd = vformat(cmd, ...) + + -- run it + return os.execute(cmd) +end + -- match files or directories function sandbox_os.match(pattern, findir) diff --git a/xmake/core/sandbox/modules/tonumber.lua b/xmake/core/sandbox/modules/tonumber.lua new file mode 100644 index 000000000..5bbe2cbbf --- /dev/null +++ b/xmake/core/sandbox/modules/tonumber.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 tonumber.lua +-- + +-- load module +return tonumber + diff --git a/xmake/core/sandbox/modules/tostring.lua b/xmake/core/sandbox/modules/tostring.lua new file mode 100644 index 000000000..aaec1fddf --- /dev/null +++ b/xmake/core/sandbox/modules/tostring.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 tostring.lua +-- + +-- load module +return tostring + diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua index b38bd6ee2..bca361388 100644 --- a/xmake/core/tool/tool.lua +++ b/xmake/core/tool/tool.lua @@ -169,14 +169,15 @@ function tool._directories(name) -- the kinds local kinds = { - cc = "compiler" - , cxx = "compiler" - , mm = "compiler" - , mxx = "compiler" - , sc = "compiler" - , ar = "archiver" - , sh = "linker" - , ld = "linker" + cc = "compiler" + , cxx = "compiler" + , mm = "compiler" + , mxx = "compiler" + , sc = "compiler" + , ar = "archiver" + , sh = "linker" + , ld = "linker" + , make = "other" } -- get kind sub-directory |
