diff options
| author | ruki <[email protected]> | 2016-07-09 22:34:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-07-09 22:34:16 +0800 |
| commit | f54223a97ba93b02128df84d52d3efe7abd2a36a (patch) | |
| tree | b6d5e5d1b4d70bd1eeadf936751eb50930f3bab6 /xmake/core/sandbox | |
| parent | 0d3075a0739eff0e28db11889a62ed3db8f4ab9f (diff) | |
add archiver and extractor
Diffstat (limited to 'xmake/core/sandbox')
3 files changed, 109 insertions, 16 deletions
diff --git a/xmake/core/sandbox/modules/import/core/tool/archiver.lua b/xmake/core/sandbox/modules/import/core/tool/archiver.lua new file mode 100644 index 000000000..db354258c --- /dev/null +++ b/xmake/core/sandbox/modules/import/core/tool/archiver.lua @@ -0,0 +1,61 @@ +--!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 archiver.lua +-- + +-- define module +local sandbox_core_tool_archiver = sandbox_core_tool_archiver or {} + +-- load modules +local platform = require("platform/platform") +local archiver = require("tool/archiver") +local raise = require("sandbox/modules/raise") + +-- make command for archiving library file +function sandbox_core_tool_archiver.archivecmd(objectfiles, targetfile, target) + + -- get the archiver instance + local instance, errors = archiver.load() + if not instance then + raise(errors) + end + + -- make command + return instance:archivecmd(objectfiles, targetfile, target) +end + +-- archive library file +function sandbox_core_tool_archiver.archive(objectfiles, targetfile, target) + + -- get the archiver instance + local instance, errors = archiver.load() + if not instance then + raise(errors) + end + + -- archive it + local ok, errors = instance:archive(objectfiles, targetfile, target) + if not ok then + raise(errors) + end +end + +-- return module +return sandbox_core_tool_archiver diff --git a/xmake/core/sandbox/modules/import/core/tool/extractor.lua b/xmake/core/sandbox/modules/import/core/tool/extractor.lua new file mode 100644 index 000000000..5c7ec29f1 --- /dev/null +++ b/xmake/core/sandbox/modules/import/core/tool/extractor.lua @@ -0,0 +1,48 @@ +--!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 extractor.lua +-- + +-- define module +local sandbox_core_tool_extractor = sandbox_core_tool_extractor or {} + +-- load modules +local platform = require("platform/platform") +local extractor = require("tool/extractor") +local raise = require("sandbox/modules/raise") + +-- extract library file +function sandbox_core_tool_extractor.extract(libraryfile, objectdir) + + -- get the extractor instance + local instance, errors = extractor.load() + if not instance then + raise(errors) + end + + -- extract it + local ok, errors = instance:extract(libraryfile, objectdir) + if not ok then + raise(errors) + end +end + +-- return module +return sandbox_core_tool_extractor diff --git a/xmake/core/sandbox/modules/import/core/tool/tool.lua b/xmake/core/sandbox/modules/import/core/tool/tool.lua index 539c9eeb6..27e20d6f4 100644 --- a/xmake/core/sandbox/modules/import/core/tool/tool.lua +++ b/xmake/core/sandbox/modules/import/core/tool/tool.lua @@ -36,22 +36,6 @@ function sandbox_core_tool.shellname(name) return platform.tool(name) end --- run the tool -function sandbox_core_tool.run(name, ...) - - -- check - assert(name) - - -- load the tool instance - local instance, errors = tool.load(name) - if not instance then - raise(errors) - end - - -- run it - instance.run(...) -end - -- check the tool and return the absolute path if exists function sandbox_core_tool.check(shellname, dirs, check) |
