diff options
| author | ruki <[email protected]> | 2025-09-26 00:53:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-09-26 00:53:12 +0800 |
| commit | 41071f11cb134a124734b922fe51ef6d8f5cfc20 (patch) | |
| tree | 0c74bc9481babb9fed827cd790b98be622d7f8cc /xmake/modules/private/utils/target.lua | |
| parent | 4321dfa63bb08dc761ab6810e758a8274cc46162 (diff) | |
improve to has_tool
Diffstat (limited to 'xmake/modules/private/utils/target.lua')
| -rw-r--r-- | xmake/modules/private/utils/target.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/xmake/modules/private/utils/target.lua b/xmake/modules/private/utils/target.lua index 84c307788..67fb79577 100644 --- a/xmake/modules/private/utils/target.lua +++ b/xmake/modules/private/utils/target.lua @@ -22,6 +22,28 @@ import("core.base.option") import("core.project.project") +-- Is this target has these tools? +function has_tool(target, toolkind, ...) + local _, toolname = target:tool(toolkind) + if toolname then + -- We need compatibility with gcc/g++, clang/clang++ for c++ compiler/linker + -- @see https://github.com/xmake-io/xmake/issues/6852 + local trim_xx = false + if toolname == "clangxx" or toolname == "gxx" then + toolname = toolname:rtrim("xx") + trim_xx = true + end + for _, v in ipairs(table.pack(...)) do + if trim_xx then + v = v:rtrim("xx") + end + if v and toolname:find("^" .. v:gsub("%-", "%%-") .. "$") then + return true + end + end + end +end + -- does this flag belong to this tool? -- @see https://github.com/xmake-io/xmake/issues/3022 -- |
