diff options
| author | ruki <[email protected]> | 2021-09-27 23:15:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-27 23:15:13 +0800 |
| commit | 19b2916a1e97e5c5fb2965cab9b6b4aecd1e03b4 (patch) | |
| tree | 6488593d622daeb01582408cdb685cac000abaa4 | |
| parent | 130d0f14a97915934eb2e82fda05b25ca7f7284f (diff) | |
improve languages
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 17 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 22 | ||||
| -rw-r--r-- | xmake/modules/core/tools/nvcc.lua | 15 | ||||
| -rw-r--r-- | xmake/modules/core/tools/sdcc.lua | 18 |
4 files changed, 52 insertions, 20 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index 0cad0abd6..54eafe227 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -203,8 +203,8 @@ function nf_language(self, stdname) , gnu11 = {"-std:c11", "-TP"} , c17 = {"-std:c17", "-TP"} , gnu17 = {"-std:c17", "-TP"} - , clatest = "-std:c17" - , gnulatest = "-std:c17" + , clatest = {"-std:c17", "-std:c11"} + , gnulatest = {"-std:c17", "-std:c11"} } end @@ -241,14 +241,17 @@ function nf_language(self, stdname) end -- map it - local flags = maps[stdname] - if flags then - for _, flag in ipairs(table.wrap(flags)) do - if self:has_flags(flag, "cxflags") then - return flag + local result = maps[stdname] + if type(result) == "table" then + for _, v in ipairs(result) do + if self:has_flags(v, "cxflags") then + result = v + maps[stdname] = result + break end end end + return result end -- make the define flag diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index bb0bef168..c6422d204 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -180,8 +180,8 @@ function nf_language(self, stdname) , gnu11 = "-std=gnu11" , c17 = "-std=c17" , gnu17 = "-std=gnu17" - , clatest = "-std=c17" - , gnulatest = "-std=gnu17" + , clatest = {"-std=c17", "-std=c11", "-std=c99", "-std=c89", "-ansi"} + , gnulatest = {"-std=gnu17", "-std=gnu11", "-std=gnu99", "-std=gnu89", "-ansi"} } end @@ -203,8 +203,8 @@ function nf_language(self, stdname) , gnuxx20 = "-std=gnu++20" , cxx2a = "-std=c++2a" , gnuxx2a = "-std=gnu++2a" - , cxxlatest = "-std=c++2a" - , gnuxxlatest = "-std=gnu++2a" + , cxxlatest = {"-std=c++20", "-std=c++2a", "-std=c++17", "-std=c++14", "-std=c++11", "-std=c++1z", "-std=c++98"} + , gnuxxlatest = {"-std=gnu++20", "-std=gnu++2a", "-std=gnu++17", "-std=gnu++14", "-std=gnu++11", "-std=c++1z", "-std=gnu++98"} } local cxxmaps2 = {} for k, v in pairs(_g.cxxmaps) do @@ -220,9 +220,17 @@ function nf_language(self, stdname) elseif self:kind() == "sc" then maps = {} end - - -- make it - return maps[stdname] + local result = maps[stdname] + if type(result) == "table" then + for _, v in ipairs(result) do + if self:has_flags(v, "cxflags") then + result = v + maps[stdname] = result + break + end + end + end + return result end -- make the define flag diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index b5e41367f..c28d8e271 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -179,7 +179,7 @@ function nf_language(self, stdname) , cxx11 = "--std c++11" , cxx14 = "--std c++14" , cxx17 = "--std c++17" - , cxxlatest = "--std c++17" + , cxxlatest = {"--std c++17", "--std c++14", "--std c++11", "--std c++03"} } local cxxmaps2 = {} for k, v in pairs(_g.cxxmaps) do @@ -187,7 +187,18 @@ function nf_language(self, stdname) end table.join2(_g.cxxmaps, cxxmaps2) end - return _g.cxxmaps[stdname] + local maps = _g.cxxmaps + local result = maps[stdname] + if type(result) == "table" then + for _, v in ipairs(result) do + if self:has_flags(v, "cxflags") then + result = v + maps[stdname] = result + break + end + end + end + return result end -- make the define flag diff --git a/xmake/modules/core/tools/sdcc.lua b/xmake/modules/core/tools/sdcc.lua index d2aece2e1..526254fe7 100644 --- a/xmake/modules/core/tools/sdcc.lua +++ b/xmake/modules/core/tools/sdcc.lua @@ -106,7 +106,6 @@ function nf_language(self, stdname) if _g.cmaps == nil then _g.cmaps = { - -- stdc ansi = "--std-c89" , c89 = "--std-c89" , gnu89 = "--std-sdcc89" @@ -116,11 +115,22 @@ function nf_language(self, stdname) , gnu11 = "--std-sdcc11" , c20 = "--std-c2x" , gnu20 = "--std-sdcc2x" - , clatest = "--std-c2x" - , gnulatest = "--std-sdcc2x" + , clatest = {"--std-c2x", "--std-c11", "--std-c99", "--std-c89"} + , gnulatest = {"--std-sdcc2x", "--std-sdcc11", "--std-sdcc99", "--std-sdcc89"} } end - return _g.cmaps[stdname] + local maps = _g.cmaps + local result = maps[stdname] + if type(result) == "table" then + for _, v in ipairs(result) do + if self:has_flags(v, "cxflags") then + result = v + maps[stdname] = result + break + end + end + end + return result end -- make the define flag |
