diff options
| author | ruki <[email protected]> | 2017-07-14 12:43:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-07-14 12:43:16 +0800 |
| commit | f39f4a27d43a1f63d56ae3c9f7fc34b5158e299a (patch) | |
| tree | 37d3667077443d79f9f1425d8aa9d54b42ff8599 /xmake/core/tool/compiler.lua | |
| parent | be1cbe6488d15f3f802539dacc74bc98471268f0 (diff) | |
fix has_flags when generating vs201x project
Diffstat (limited to 'xmake/core/tool/compiler.lua')
| -rw-r--r-- | xmake/core/tool/compiler.lua | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index 00d05fa6c..3be1f9749 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -208,20 +208,9 @@ function compiler:compflags(opt) -- get target local target = opt.target - -- make the key - local key = nil - for _, arg in pairs(opt) do - key = (key or "") .. tostring(arg) - end - - -- get it directly from cache dirst - if key then - self._FLAGS = self._FLAGS or {} - local flags_cached = self._FLAGS[key] - if flags_cached then - return flags_cached - end - end + -- init cache + self._COMPFLAGS = self._COMPFLAGS or {} + local cache = self._COMPFLAGS -- get target kind local targetkind = opt.targetkind @@ -233,14 +222,25 @@ function compiler:compflags(opt) local flags = {} self:_addflags_from_config(flags) - -- add flags for the target - if target then - self:_addflags_from_target(flags, target) - end - - -- add flags (named) from language + -- add flags about target if target then - self:_addflags_from_language(flags, target) + + -- get flags from cache first + local key = tostring(target) + local targetflags = cache[key] + if not targetflags then + + -- add flags for the target + targetflags = {} + self:_addflags_from_target(targetflags, target) + + -- add flags (named) from language + self:_addflags_from_language(targetflags, target) + + -- cache it + cache[key] = targetflags + end + table.join2(flags, targetflags) end -- add flags for the argument @@ -270,11 +270,6 @@ function compiler:compflags(opt) end end - -- save flags - if key then - self._FLAGS[key] = results - end - -- get it return results end |
