diff options
| author | ruki <[email protected]> | 2016-08-08 14:11:35 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-08-08 14:11:35 +0800 |
| commit | 36cffe6922680493c36d9f9ba4a8fa18b60d8539 (patch) | |
| tree | 594150c0d7286d5adc8325ba70d9d300594e1357 /xmake/core/tool/compiler.lua | |
| parent | 92f5c739180afb80ddf99865902a68f122c3aef1 (diff) | |
add compflags and linkflags interfaces
Diffstat (limited to 'xmake/core/tool/compiler.lua')
| -rw-r--r-- | xmake/core/tool/compiler.lua | 93 |
1 files changed, 43 insertions, 50 deletions
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index 14a3178c3..d14b4dcbd 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -49,44 +49,6 @@ function compiler:_flagnames() return self._FLAGNAMES end --- get the flags -function compiler:_flags(target) - - -- get the target key - local key = tostring(target) - - -- get it directly from cache dirst - self._FLAGS = self._FLAGS or {} - if self._FLAGS[key] then - return self._FLAGS[key] - end - - -- add flags from the configure - local flags = {} - self:_addflags_from_config(flags) - - -- add flags from the target - self:_addflags_from_target(flags, target) - - -- add flags from the platform - self:_addflags_from_platform(flags) - - -- add flags from the compiler - self:_addflags_from_compiler(flags, target:get("kind")) - - -- remove repeat - flags = table.unique(flags) - - -- merge flags - flags = table.concat(flags, " "):trim() - - -- save flags - self._FLAGS[key] = flags - - -- get it - return flags -end - -- map gcc flag to the given compiler flag function compiler:_mapflag(flag, mapflags) @@ -359,27 +321,58 @@ end -- compile the source file function compiler:compile(sourcefile, objectfile, incdepfile, target) - -- get flags - local flags = nil - if target then - flags = self:_flags(target) - end - -- compile it - return sandbox.load(self:_tool().compile, sourcefile, objectfile, incdepfile, flags or "") + return sandbox.load(self:_tool().compile, sourcefile, objectfile, incdepfile, self:compflags(target)) end -- get the compile command function compiler:compcmd(sourcefile, objectfile, target) - -- get flags - local flags = nil - if target then - flags = self:_flags(target) + -- get it + return self:_tool().compcmd(sourcefile, objectfile, self:compflags(target)) +end + +-- get the compling flags +function compiler:compflags(target) + + -- no target? + if not target then + return "" end + -- get the target key + local key = tostring(target) + + -- get it directly from cache dirst + self._FLAGS = self._FLAGS or {} + if self._FLAGS[key] then + return self._FLAGS[key] + end + + -- add flags from the configure + local flags = {} + self:_addflags_from_config(flags) + + -- add flags from the target + self:_addflags_from_target(flags, target) + + -- add flags from the platform + self:_addflags_from_platform(flags) + + -- add flags from the compiler + self:_addflags_from_compiler(flags, target:get("kind")) + + -- remove repeat + flags = table.unique(flags) + + -- merge flags + flags = table.concat(flags, " "):trim() + + -- save flags + self._FLAGS[key] = flags + -- get it - return self:_tool().compcmd(sourcefile, objectfile, flags or "") + return flags end -- make the symbol flag |
