diff options
| author | ruki <[email protected]> | 2020-05-12 00:42:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-11 22:13:39 +0800 |
| commit | 3d9eda6bf206d4bbcccc840c1f3ba477aefcbfc5 (patch) | |
| tree | 7a572be3436058d93265f5667f806e038b2125b7 /xmake | |
| parent | f4deeedb389e6d5f7ed3cd6594be27da67d8b19b (diff) | |
improve find_cross_toolchain
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/modules/detect/sdks/find_cross_toolchain.lua | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/xmake/modules/detect/sdks/find_cross_toolchain.lua b/xmake/modules/detect/sdks/find_cross_toolchain.lua index 8c70e0b87..86fd829a1 100644 --- a/xmake/modules/detect/sdks/find_cross_toolchain.lua +++ b/xmake/modules/detect/sdks/find_cross_toolchain.lua @@ -33,17 +33,21 @@ function _find_bindir(sdkdir, opt) table.insert(bindirs, path.join(sdkdir, "bin")) table.insert(bindirs, path.join(sdkdir, "**", "bin")) - -- attempt to find *-ld - local ldname = is_host("windows") and "ld.exe" or "ld" - local ldpath = find_file((opt.cross or '*-') .. ldname, bindirs) - if ldpath then - return path.directory(ldpath), path.basename(ldpath):sub(1, -3) - end - - -- find ld - ldpath = find_file(ldname, bindirs) - if ldpath then - return path.directory(ldpath), "" + -- attempt to find *-[gcc|clang|ld] + for _, toolname in ipairs({"gcc", "clang", "ld"}) do + if is_plat("windows") then + toolname = toolname .. ".exe" + end + local toolpath = find_file((opt.cross or '*-') .. toolname, bindirs) + if toolpath then + return path.directory(toolpath), path.filename(toolpath):sub(1, -(#toolname + 1)) + end + + -- find tool path + toolpath = find_file(toolname, bindirs) + if toolpath then + return path.directory(toolpath), "" + end end -- attempt to use the bin directory |
