diff options
| author | ruki <[email protected]> | 2024-05-08 23:43:28 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-05-08 23:43:28 +0800 |
| commit | eed3d87b3d383ad6fe5055c56ec2ebaa872a3b9a (patch) | |
| tree | 4e6113269231d2d1dc24c1c154e3b800aec41bd9 /xmake/modules/lib/detect/find_toolname.lua | |
| parent | f7ee280ab5326abf641fe7bc1ebf12b31cf2423c (diff) | |
improve find gcc_ar
Diffstat (limited to 'xmake/modules/lib/detect/find_toolname.lua')
| -rw-r--r-- | xmake/modules/lib/detect/find_toolname.lua | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/xmake/modules/lib/detect/find_toolname.lua b/xmake/modules/lib/detect/find_toolname.lua index 8a9541031..3f8171a07 100644 --- a/xmake/modules/lib/detect/find_toolname.lua +++ b/xmake/modules/lib/detect/find_toolname.lua @@ -74,7 +74,7 @@ function _find(program) end -- get file name first - name = path.filename(program):lower() + local name = path.filename(program):lower() -- remove arguments: " -xxx" or " --xxx" name = name:gsub("%s%-+%w+", " ") @@ -93,16 +93,21 @@ function _find(program) end -- try last valid name: xxx-xxx-toolname-5 + -- + -- e.g. + -- arm-none-eabi-gcc-ar -> gcc_ar + -- arm-none-eabi-gcc -> gcc local partnames = {} for partname in name:gmatch("([%a%+]+)") do table.insert(partnames, partname) end - if #partnames > 0 then - name = partnames[#partnames] - end - toolname = name:gsub("%+", "x") - if module.find("detect.tools.find_" .. toolname) then - return toolname + while #partnames > 0 do + name = table.concat(partnames, "_") + table.remove(partnames, 1) + toolname = name:gsub("%+", "x") + if module.find("detect.tools.find_" .. toolname) then + return toolname + end end end |
