diff options
| author | ruki <[email protected]> | 2018-06-22 22:51:28 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-06-22 11:08:51 +0800 |
| commit | 8cffaa773fe48eaf4afe957ff09f8d80f88f68ca (patch) | |
| tree | d6e50e819a9e19d916b8b625d46e1ff310318e26 /xmake/modules | |
| parent | 752e703e0041b6fd9770968693b0f625aa246d3e (diff) | |
improve find cross toolchain
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/detect/sdks/find_cross_toolchain.lua (renamed from xmake/modules/detect/sdks/find_cross_toolchains.lua) | 41 | ||||
| -rw-r--r-- | xmake/modules/detect/sdks/find_ndk.lua | 8 |
2 files changed, 31 insertions, 18 deletions
diff --git a/xmake/modules/detect/sdks/find_cross_toolchains.lua b/xmake/modules/detect/sdks/find_cross_toolchain.lua index 1e92d04c8..107d7c916 100644 --- a/xmake/modules/detect/sdks/find_cross_toolchains.lua +++ b/xmake/modules/detect/sdks/find_cross_toolchain.lua @@ -19,25 +19,26 @@ -- Copyright (C) 2015 - 2018, TBOOX Open Source Group. -- -- @author ruki --- @file find_cross_toolchains.lua +-- @file find_cross_toolchain.lua -- -- imports import("core.project.config") +import("lib.detect.find_file") --- find cross toolchains +-- find cross toolchain -- --- @param rootdir the root directory of cross toolchains +-- @param rootdir the root directory of cross toolchain -- @param opt the argument options -- .e.g {bin = .., cross = ..} -- --- @return the toolchains array. .e.g {{bin = .., cross = ..}, .. } +-- @return the toolchain .e.g {bin = .., cross = ..} -- -- @code -- --- local cross_toolchains = find_cross_toolchains("/xxx/android-cross-r10e") --- local cross_toolchains = find_cross_toolchains("/xxx/android-cross-r10e", {cross = "arm-linux-androideabi-"}) --- local cross_toolchains = find_cross_toolchains("/xxx/android-cross-r10e", {cross = "arm-linux-androideabi-", bin = ..}) +-- local toolchain = find_cross_toolchain("/xxx/android-cross-r10e") +-- local toolchain = find_cross_toolchain("/xxx/android-cross-r10e", {cross = "arm-linux-androideabi-"}) +-- local toolchain = find_cross_toolchain("/xxx/android-cross-r10e", {cross = "arm-linux-androideabi-", bin = ..}) -- -- @endcode -- @@ -48,15 +49,27 @@ function main(rootdir, opt) -- get root directory if not rootdir or not os.isdir(rootdir) then - return {} + return end - -- find bin directory and cross - local cross_toolchains = {} - for _, ldpath in ipairs(os.files(path.join(opt.bin or rootdir, "**" .. (opt.cross or '-') .. "ld"))) do - table.insert(cross_toolchains, {bin = path.directory(ldpath), cross = path.basename(ldpath):sub(1, -3)}) + -- init pathes + local pathes = {} + if opt.bin then + table.insert(pathes, opt.bin) end + table.insert(pathes, path.join(rootdir, "bin")) + table.insert(pathes, path.join(rootdir, "**", "bin")) - -- ok? - return cross_toolchains + -- attempt to find *-ld + local ldname = os.host() == "windows" and "ld.exe" or "ld" + local ldpath = find_file((opt.cross or '*-') .. ldname, pathes) + if ldpath then + return {bin = path.directory(ldpath), cross = path.basename(ldpath):sub(1, -3)} + end + + -- find ld + ldpath = find_file(ldname, pathes) + if ldpath then + return {bin = path.directory(ldpath), cross = ""} + end end diff --git a/xmake/modules/detect/sdks/find_ndk.lua b/xmake/modules/detect/sdks/find_ndk.lua index dfbc7454a..73f643f4f 100644 --- a/xmake/modules/detect/sdks/find_ndk.lua +++ b/xmake/modules/detect/sdks/find_ndk.lua @@ -19,7 +19,7 @@ -- Copyright (C) 2015 - 2018, TBOOX Open Source Group. -- -- @author ruki --- @file find_toolchains.lua +-- @file find_ndk.lua -- -- imports @@ -31,12 +31,12 @@ import("core.project.config") -- @param opt the argument options -- .e.g {arch = "[armv5te|armv6|armv7-a|armv8-a|arm64-v8a]"} -- --- @return the toolchains array. .e.g {{bin = .., cross = ..}, .. } +-- @return the ndk toolchains array. .e.g {{bin = .., cross = ..}, .. } -- -- @code -- --- local toolchains = find_toolchains("/xxx/android-ndk-r10e") --- local toolchains = find_toolchains("/xxx/android-ndk-r10e", {arch = "arm64-v8a"}) +-- local toolchains = find_ndk("/xxx/android-ndk-r10e") +-- local toolchains = find_ndk("/xxx/android-ndk-r10e", {arch = "arm64-v8a"}) -- -- @endcode -- |
