diff options
| author | ruki <[email protected]> | 2021-09-26 11:24:49 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-26 11:24:49 +0800 |
| commit | be70f45c99e92a8f72c52bca943601761e18215d (patch) | |
| tree | d115872c6d73ea9601c574ed43740a0ad0a56a5f | |
| parent | 32f89fbfcfb6367f09813750c8c791647e24b63d (diff) | |
improve android ndk support for r23
| -rw-r--r-- | xmake/modules/detect/sdks/find_ndk.lua | 10 | ||||
| -rw-r--r-- | xmake/toolchains/ndk/check.lua | 1 | ||||
| -rw-r--r-- | xmake/toolchains/ndk/load.lua | 6 |
3 files changed, 12 insertions, 5 deletions
diff --git a/xmake/modules/detect/sdks/find_ndk.lua b/xmake/modules/detect/sdks/find_ndk.lua index bc07f6081..4e355e49b 100644 --- a/xmake/modules/detect/sdks/find_ndk.lua +++ b/xmake/modules/detect/sdks/find_ndk.lua @@ -188,8 +188,12 @@ function _find_ndk(sdkdir, arch, ndk_sdkver, ndk_toolchains_ver) local gcc_toolchain_subdir = gcc_toolchain_subdirs[arch] or "arm-linux-androideabi-*" -- find the binary directory - local bindir = find_directory("bin", path.join(sdkdir, "toolchains", "llvm", "prebuilt", "*")) -- larger than ndk r16 - if not bindir then + local llvm_toolchain + local prebuilt = (is_host("macosx") and "darwin" or os.host()) .. "-x86_64" + local bindir = find_directory("bin", path.join(sdkdir, "toolchains", "llvm", "prebuilt", prebuilt)) -- larger than ndk r16 + if bindir then + llvm_toolchain = path.directory(bindir) + else bindir = find_directory("bin", path.join(sdkdir, "toolchains", gcc_toolchain_subdir, "prebuilt", "*")) end if not bindir then @@ -231,6 +235,7 @@ function _find_ndk(sdkdir, arch, ndk_sdkver, ndk_toolchains_ver) bindir = bindir, cross = cross, sdkver = sdkver, + llvm_toolchain = llvm_toolchain, -- >= ndk r22 gcc_toolchain = gcc_toolchain, toolchains_ver = toolchains_ver, sysroot = sysroot} @@ -280,7 +285,6 @@ function main(sdkdir, opt) if opt.verbose or option.get("verbose") then cprint("checking for NDK directory ... ${color.success}%s", ndk.sdkdir) cprint("checking for SDK version of NDK ... ${color.success}%s", ndk.sdkver) - cprint("checking for toolchains version of NDK ... ${color.success}%s", ndk.toolchains_ver) end else diff --git a/xmake/toolchains/ndk/check.lua b/xmake/toolchains/ndk/check.lua index aaf1d609a..991e4e3d9 100644 --- a/xmake/toolchains/ndk/check.lua +++ b/xmake/toolchains/ndk/check.lua @@ -49,6 +49,7 @@ function _check_ndk(toolchain) toolchain:config_set("ndk", ndk.sdkdir) toolchain:config_set("bindir", ndk.bindir) toolchain:config_set("cross", ndk.cross) + toolchain:config_set("llvm_toolchain", ndk.llvm_toolchain) toolchain:config_set("gcc_toolchain", ndk.gcc_toolchain) toolchain:config_set("ndkver", ndk.ndkver) toolchain:config_set("ndk_sdkver", ndk.sdkver) diff --git a/xmake/toolchains/ndk/load.lua b/xmake/toolchains/ndk/load.lua index 29e88d7ad..059f6b417 100644 --- a/xmake/toolchains/ndk/load.lua +++ b/xmake/toolchains/ndk/load.lua @@ -167,8 +167,10 @@ function main(toolchain) local ndk_sysroot = toolchain:config("ndk_sysroot") if ndk_sysroot and os.isdir(ndk_sysroot) then local triple = _get_triple(arch) - toolchain:add("cxflags", "-D__ANDROID_API__=" .. ndk_sdkver) - toolchain:add("asflags", "-D__ANDROID_API__=" .. ndk_sdkver) + if ndkver and tonumber(ndkver) < 22 then + toolchain:add("cxflags", "-D__ANDROID_API__=" .. ndk_sdkver) + toolchain:add("asflags", "-D__ANDROID_API__=" .. ndk_sdkver) + end toolchain:add("cflags", "--sysroot=" .. ndk_sysroot) toolchain:add("cxxflags","--sysroot=" .. ndk_sysroot) toolchain:add("asflags", "--sysroot=" .. ndk_sysroot) |
