diff options
| author | ruki <[email protected]> | 2023-02-08 23:36:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-08 23:36:27 +0800 |
| commit | 99e671bf5659f24696ae1baf23de6b593c702f9c (patch) | |
| tree | a6a7d57fe0d99f276ae1f1b1f28ab50e17448262 /xmake/modules/lib | |
| parent | 1d61e87f3c869a7e33884fa0edc01c4110ddb72d (diff) | |
add some linkers
Diffstat (limited to 'xmake/modules/lib')
| -rw-r--r-- | xmake/modules/lib/detect/find_toolname.lua | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/xmake/modules/lib/detect/find_toolname.lua b/xmake/modules/lib/detect/find_toolname.lua index 912f0ee8a..77ed776d2 100644 --- a/xmake/modules/lib/detect/find_toolname.lua +++ b/xmake/modules/lib/detect/find_toolname.lua @@ -19,8 +19,24 @@ -- -- imports +import("core.base.hashset") import("core.sandbox.module") +-- remove some suffix +-- +-- we just remove some known extension, because we need reverse others, e.g. ld.lld, ld64.lld +-- +function _remove_suffix(name) + local exts = hashset.of("exe", "bat", "sh", "ps1", "ps") + name = name:gsub("%.(%w+)", function (ext) + ext = ext:lower() + if exts:has(ext) then + return "" + end + end) + return name +end + -- find the the whole name function _find_with_whole_name(program) @@ -34,7 +50,7 @@ function _find_with_whole_name(program) local names = path.filename(program):lower():split("%s") for _, name in ipairs(names) do -- remove suffix: ".exe", e.g. "zig.exe cc" - name = name:gsub("%.%w+", "") + name = _remove_suffix(name) -- "zig c++" -> zig_cxx name = name:gsub("%+", "x") -- skip -arguments @@ -70,8 +86,8 @@ function _find(program) end -- remove suffix: ".xxx" - name = name:gsub("%.%w+", "") - toolname = name:gsub("[%+%-]", function (ch) return (ch == "+" and "x" or "_") end) + name = _remove_suffix(name) + toolname = name:gsub("[%+%-%.]", function (ch) return (ch == "+" and "x" or "_") end) if module.find("detect.tools.find_" .. toolname) then return toolname end |
