summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2016-03-21 21:50:35 +0800
committerruki <[email protected]>2016-03-21 21:50:35 +0800
commitd1f010fc5582cdaabb2ed758b2aaf7ffa5a95a43 (patch)
treed71bacbac82886d60e67ea8747de864d69dacf0f /xmake/core
parent308b4d3661fad938dae830ee357778f85918f963 (diff)
add tool module for sandbox
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/project/target.lua23
-rw-r--r--xmake/core/sandbox/modules/import/core/platform/tool.lua37
2 files changed, 59 insertions, 1 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 68dfefe3a..4fef8fbd6 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -30,6 +30,7 @@ local table = require("base/table")
local option = require("project/option")
local config = require("project/config")
local linker = require("platform/linker")
+local compiler = require("platform/compiler")
local platform = require("platform/platform")
-- get the filename from the given name and kind
@@ -62,9 +63,12 @@ function target.name(self)
return self._NAME
end
--- get the linker with the target kind
+-- get the linker
function target.linker(self)
+ -- check
+ assert(self)
+
-- init the linker from the given kind
local result = linker.init(self:get("kind"))
if not result then
@@ -76,6 +80,23 @@ function target.linker(self)
end
+-- get the compiler with the given source file
+function target.compiler(self, srcfile)
+
+ -- check
+ assert(self and srcfile)
+
+ -- init the linker from the given kind
+ local result, errors = compiler.init(srcfile)
+ if not result then
+ os.raise(errors)
+ end
+
+ -- ok?
+ return result
+
+end
+
-- get the options
function target.options(self)
diff --git a/xmake/core/sandbox/modules/import/core/platform/tool.lua b/xmake/core/sandbox/modules/import/core/platform/tool.lua
new file mode 100644
index 000000000..27cb9af52
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/core/platform/tool.lua
@@ -0,0 +1,37 @@
+--!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 tool.lua
+--
+
+-- define module
+local sandbox_core_platform_tool = sandbox_core_platform_tool or {}
+
+-- load modules
+local platform = require("platform/platform")
+
+-- get the tool shell name
+function sandbox_core_platform_tool.shellname(name)
+
+ -- get it
+ return platform.tool(name)
+end
+
+-- return module
+return sandbox_core_platform_tool