diff options
| author | ruki <[email protected]> | 2024-01-20 23:42:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-01-25 12:09:58 +0800 |
| commit | eddb673f8fffc281fa9a5c9ef56ef0c00495a627 (patch) | |
| tree | 4751ce05ae47f80af73f8aa713de55fd513c8cbf | |
| parent | c622a4e8a6542cc9234344ab323139f5e8f23612 (diff) | |
limit toolchain runtimes
| -rw-r--r-- | xmake/core/platform/platform.lua | 7 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 7 | ||||
| -rw-r--r-- | xmake/core/tool/toolchain.lua | 19 | ||||
| -rw-r--r-- | xmake/toolchains/clang/xmake.lua | 5 | ||||
| -rw-r--r-- | xmake/toolchains/gcc/xmake.lua | 8 | ||||
| -rw-r--r-- | xmake/toolchains/llvm/xmake.lua | 11 | ||||
| -rw-r--r-- | xmake/toolchains/msvc/xmake.lua | 10 | ||||
| -rw-r--r-- | xmake/toolchains/ndk/xmake.lua | 10 |
8 files changed, 39 insertions, 38 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index 322e976b8..180e5401e 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -157,8 +157,11 @@ function _instance:runtimes() elseif self:name() == "android" then runtimes = runtimes or config.get("ndk_cxxstl") end - if runtimes then - runtimes = table.unwrap(runtimes:split(",", {plain = true})) + runtimes = runtimes:split(",", {plain = true}) + if #runtimes > 0 then + runtimes = table.unwrap(runtimes) + else + runtimes = nil end runtimes = runtimes or false self:_memcache():set("runtimes", runtimes) diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 74d8b77b5..fd8421051 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -2391,7 +2391,12 @@ function _instance:runtimes() runtimes = runtimes or config.get("ndk_cxxstl") end if runtimes then - runtimes = table.unwrap(runtimes:split(",", {plain = true})) + runtimes = runtimes:split(",", {plain = true}) + if #runtimes > 0 then + runtimes = table.unwrap(runtimes) + else + runtimes = nil + end end runtimes = runtimes or false self:_memcache():set("runtimes", runtimes) diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index 020b790d8..ab9673c91 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -110,7 +110,23 @@ end -- get toolchain runtimes function _instance:runtimes() - return self:config("runtimes") + local runtimes = self._RUNTIMES + if runtimes == nil then + runtimes = {} + local runtimes_supported = hashset.from(table.wrap(self:get("runtimes"))) + for _, runtime in ipairs(table.wrap(self:config("runtimes"))) do + if runtimes_supported:has(runtime) then + table.insert(runtimes, runtime) + end + end + if #runtimes > 0 then + runtimes = table.unwrap(runtimes) + else + runtimes = false + end + self._RUNTIMES = runtimes + end + return runtimes or nil end -- has the given runtime for the current toolchains? @@ -587,6 +603,7 @@ function toolchain.apis() , "toolchain.set_bindir" , "toolchain.set_sdkdir" , "toolchain.set_archs" + , "toolchain.set_runtimes" , "toolchain.set_homepage" , "toolchain.set_description" } diff --git a/xmake/toolchains/clang/xmake.lua b/xmake/toolchains/clang/xmake.lua index 0f9662cee..981cac82e 100644 --- a/xmake/toolchains/clang/xmake.lua +++ b/xmake/toolchains/clang/xmake.lua @@ -25,11 +25,10 @@ if version then suffix = suffix .. "-" .. version end toolchain("clang" .. suffix) - + set_kind("standalone") set_homepage("https://clang.llvm.org/") set_description("A C language family frontend for LLVM" .. (version and (" (" .. version .. ")") or "")) - - set_kind("standalone") + set_runtimes("c++_static", "c++_shared", "stdc++_static", "stdc++_shared") set_toolset("cc", "clang" .. suffix) set_toolset("cxx", "clang" .. suffix, "clang++" .. suffix) diff --git a/xmake/toolchains/gcc/xmake.lua b/xmake/toolchains/gcc/xmake.lua index 365341eda..b21f3592e 100644 --- a/xmake/toolchains/gcc/xmake.lua +++ b/xmake/toolchains/gcc/xmake.lua @@ -25,15 +25,11 @@ if version then suffix = suffix .. "-" .. version end toolchain("gcc" .. suffix) - - -- set homepage + set_kind("standalone") set_homepage("https://gcc.gnu.org/") set_description("GNU Compiler Collection" .. (version and (" (" .. version .. ")") or "")) + set_runtimes("c++_static", "c++_shared", "stdc++_static", "stdc++_shared") - -- mark as standalone toolchain - set_kind("standalone") - - -- set toolset set_toolset("cc", "gcc" .. suffix) set_toolset("cxx", "gcc" .. suffix, "g++" .. suffix) set_toolset("ld", "g++" .. suffix, "gcc" .. suffix) diff --git a/xmake/toolchains/llvm/xmake.lua b/xmake/toolchains/llvm/xmake.lua index 3525a2d6d..ef27a2073 100644 --- a/xmake/toolchains/llvm/xmake.lua +++ b/xmake/toolchains/llvm/xmake.lua @@ -18,17 +18,12 @@ -- @file xmake.lua -- --- define toolchain toolchain("llvm") - - -- set homepage + set_kind("standalone") set_homepage("https://llvm.org/") set_description("A collection of modular and reusable compiler and toolchain technologies") + set_runtimes("c++_static", "c++_shared", "stdc++_static", "stdc++_shared") - -- mark as standalone toolchain - set_kind("standalone") - - -- set toolset set_toolset("cc", "clang") set_toolset("cxx", "clang", "clang++") set_toolset("mxx", "clang", "clang++") @@ -42,10 +37,8 @@ toolchain("llvm") set_toolset("strip", "llvm-strip") set_toolset("mrc", "llvm-rc") - -- check toolchain on_check("check") - -- on load on_load(function (toolchain) -- add march flags diff --git a/xmake/toolchains/msvc/xmake.lua b/xmake/toolchains/msvc/xmake.lua index a79cb4268..9ef6babe1 100644 --- a/xmake/toolchains/msvc/xmake.lua +++ b/xmake/toolchains/msvc/xmake.lua @@ -30,16 +30,10 @@ -- @endcode -- toolchain("msvc") - - -- set homepage + set_kind("standalone") set_homepage("https://visualstudio.microsoft.com") set_description("Microsoft Visual C/C++ Compiler") + set_runtimes("MT", "MTd", "MD", "MDd") - -- mark as standalone toolchain - set_kind("standalone") - - -- check toolchain on_check("check") - - -- load toolchain on_load("load") diff --git a/xmake/toolchains/ndk/xmake.lua b/xmake/toolchains/ndk/xmake.lua index 609efb4a2..108d52275 100644 --- a/xmake/toolchains/ndk/xmake.lua +++ b/xmake/toolchains/ndk/xmake.lua @@ -30,16 +30,10 @@ -- @endcode -- toolchain("ndk") - - -- set homepage + set_kind("standalone") set_homepage("https://developer.android.com/ndk") set_description("Android NDK") + set_runtimes("c++_static", "c++_shared", "gnustl_static", "gnustl_shared", "stlport_static", "stlport_shared") - -- mark as standalone toolchain - set_kind("standalone") - - -- check toolchain on_check("check") - - -- load toolchain on_load("load") |
