diff options
| author | ruki <[email protected]> | 2017-06-27 19:57:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-27 19:59:50 +0800 |
| commit | d88cab7a400904e6a44f795479cbc3f2bdcc6297 (patch) | |
| tree | daa207a507d1a6d836a22a5b6616c8936d0ff8f6 /xmake/core/tool/compiler.lua | |
| parent | 08423656d08715670959b69c64957e9e9b1b3db1 (diff) | |
improve has_cxsnippet and add links
Diffstat (limited to 'xmake/core/tool/compiler.lua')
| -rw-r--r-- | xmake/core/tool/compiler.lua | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index a4f8dc5f4..622ed946b 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -192,36 +192,51 @@ function compiler:compflags(opt) -- get target local target = opt.target - -- no target? - if not target then - return "", {} - end - -- get the target key - local key = tostring(target) + local key = nil + if target then + key = tostring(target) + end -- get it directly from cache dirst - self._FLAGS = self._FLAGS or {} - local flags_cached = self._FLAGS[key] - if flags_cached then - return flags_cached[1], flags_cached[2] + if key then + self._FLAGS = self._FLAGS or {} + local flags_cached = self._FLAGS[key] + if flags_cached then + return flags_cached[1], flags_cached[2] + end + end + + -- get target kind + local targetkind = opt.targetkind + if not targetkind and target then + targetkind = target:get("kind") 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 for the target + if target then + self:_addflags_from_target(flags, target) + end + -- add flags (named) from language - self:_addflags_from_language(flags, target) + if target then + self:_addflags_from_language(flags, target) + end + + -- add flags for the argument + self:_addflags_from_argument(flags, opt) -- add flags from the platform - self:_addflags_from_platform(flags, target:get("kind")) + if target then + self:_addflags_from_platform(flags, targetkind) + end -- add flags from the compiler - self:_addflags_from_compiler(flags, target:get("kind")) + self:_addflags_from_compiler(flags, targetkind) -- remove repeat flags = table.unique(flags) @@ -230,7 +245,9 @@ function compiler:compflags(opt) local flags_str = table.concat(flags, " "):trim() -- save flags - self._FLAGS[key] = {flags_str, flags} + if key then + self._FLAGS[key] = {flags_str, flags} + end -- get it return flags_str, flags |
