diff options
| author | ruki <[email protected]> | 2016-04-14 09:24:24 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-04-14 09:24:24 +0800 |
| commit | 9e736d8b83930330edaee2958b4c66093ca87e37 (patch) | |
| tree | cefcd89bbc72f1aac02535699f97626560be12ab /xmake/core/project/target.lua | |
| parent | 733935aec221c1bce476e7cfea7b5e64d280f71e (diff) | |
reimpl compiler and linker
Diffstat (limited to 'xmake/core/project/target.lua')
| -rw-r--r-- | xmake/core/project/target.lua | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 42a4df4bf..ef170fa4f 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -29,7 +29,7 @@ local path = require("base/path") local table = require("base/table") local option = require("project/option") local config = require("project/config") -local linker = require("platform/linker") +local linker = require("tool/linker") local compiler = require("tool/compiler") local platform = require("platform/platform") @@ -70,7 +70,7 @@ function target:linker() assert(self) -- init the linker from the given kind - local result, errors = linker.init(self:get("kind")) + local result, errors = linker.load(self:get("kind")) if not result then os.raise(errors) end @@ -87,7 +87,7 @@ function target:compiler(srcfile) assert(self and srcfile) -- load the compiler - local result, errors = compiler.load(srcfile) + local result, errors = compiler.load(compiler.kind_of_file(srcfile)) if not result then os.raise(errors) end @@ -311,6 +311,38 @@ function target:headerfiles() return srcheaders, dstheaders end +-- get the kinds of sourcefiles +-- +-- .e.g cc cxx mm mxx as ... +-- +function target:sourcekinds() + + -- cached? return it directly + if self._SOURCEKINDS then + return self._SOURCEKINDS + end + + -- make kinds + local kinds = {} + for _, sourcefile in pairs(self:sourcefiles()) do + + -- get kind + local kind = compiler.kind_of_file(sourcefile) + if kind then + table.insert(kinds, kind) + end + end + + -- remove repeat + kinds = table.unique(kinds) + + -- cache it + self._SOURCEKINDS = kinds + + -- ok? + return kinds +end + -- return module return target |
