diff --git a/xmake/scripts/platform/android/android.lua b/xmake/scripts/platform/android/android.lua index 402a1547f7a..5226495b0ea 100644 --- a/xmake/scripts/platform/android/android.lua +++ b/xmake/scripts/platform/android/android.lua @@ -33,7 +33,7 @@ android._HOST = xmake._HOST android._OS = "android" -- init architectures -android._ARCHS = {"armv5te", "armv6", "armv7-a", "arm64-v8a"} +android._ARCHS = {"armv5te", "armv6", "armv7-a", "armv8-a", "arm64-v8a"} -- make configure function android.make(configs) @@ -56,20 +56,35 @@ function android.make(configs) configs.tools.sh = config.get("sh") -- init flags - configs.cxflags = { "-march=" .. config.get("arch"), "-mthumb" } - configs.asflags = { "-march=" .. config.get("arch"), "-mthumb" } - configs.ldflags = { "-march=" .. config.get("arch"), "-llog", "-mthumb" } - configs.shflags = { "-march=" .. config.get("arch"), "-llog", "-mthumb" } + local arch = config.get("arch") + if arch:startswith("arm64") then + configs.cxflags = {} + configs.asflags = {} + configs.ldflags = {"-llog"} + configs.shflags = {"-llog"} + else + configs.cxflags = { "-march=" .. arch, "-mthumb"} + configs.asflags = { "-march=" .. arch, "-mthumb"} + configs.ldflags = { "-march=" .. arch, "-llog", "-mthumb"} + configs.shflags = { "-march=" .. arch, "-llog", "-mthumb"} + end -- add flags for the sdk directory of ndk local ndk = config.get("ndk") local ndk_sdkver = config.get("ndk_sdkver") if ndk and ndk_sdkver then local ndk_sdkdir = path.translate(string.format("%s/platforms/android-%d", ndk, ndk_sdkver)) - table.insert(configs.cxflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) - table.insert(configs.asflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) - table.insert(configs.ldflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) - table.insert(configs.shflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) + if arch:startswith("arm64") then + table.insert(configs.cxflags, string.format("--sysroot=%s/arch-arm64", ndk_sdkdir)) + table.insert(configs.asflags, string.format("--sysroot=%s/arch-arm64", ndk_sdkdir)) + table.insert(configs.ldflags, string.format("--sysroot=%s/arch-arm64", ndk_sdkdir)) + table.insert(configs.shflags, string.format("--sysroot=%s/arch-arm64", ndk_sdkdir)) + else + table.insert(configs.cxflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) + table.insert(configs.asflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) + table.insert(configs.ldflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) + table.insert(configs.shflags, string.format("--sysroot=%s/arch-arm", ndk_sdkdir)) + end end end diff --git a/xmake/scripts/platform/android/prober.lua b/xmake/scripts/platform/android/prober.lua index d01a49d5ce3..6149b54fb2e 100644 --- a/xmake/scripts/platform/android/prober.lua +++ b/xmake/scripts/platform/android/prober.lua @@ -178,10 +178,16 @@ function prober._probe_toolpath(configs, kind, cross, name, description) if ndk then -- match all toolchains - toolchains = os.match(string.format("%s/toolchains/arm-linux-androideabi-**/prebuilt/*/bin/%s%s", ndk, cross, name)) + local arch = configs.get("arch") + if arch and arch:startswith("arm64") then + toolchains = os.match(string.format("%s/toolchains/aarch64-linux-android-**/prebuilt/*/bin/%s%s", ndk, cross, name)) + else + toolchains = os.match(string.format("%s/toolchains/arm-linux-androideabi-**/prebuilt/*/bin/%s%s", ndk, cross, name)) + end + + -- probe the tool path if toolchains then for _, filepath in ipairs(toolchains) do - -- probe the tool path toolpath = tools.probe(cross .. name, path.directory(filepath)) if toolpath then break end end @@ -193,7 +199,11 @@ function prober._probe_toolpath(configs, kind, cross, name, description) if toolpath then configs.set(kind, toolpath) end -- trace - utils.verbose("checking for %s (%s) ... %s", description, kind, utils.ifelse(toolpath, path.filename(toolpath), "no")) + if toolpath then + utils.verbose("checking for %s (%s) ... %s", description, kind, path.filename(toolpath), "no") + else + utils.verbose("checking for %s (%s) ... no", description, kind) + end -- ok return true @@ -202,13 +212,20 @@ end -- probe the toolchains function prober._probe_toolchains(configs) + -- init prefix + local prefix = "arm-linux-androideabi-" + local arch = configs.get("arch") + if arch and arch:startswith("arm64") then + prefix = "aarch64-linux-android-" + end + -- done - if not prober._probe_toolpath(configs, "cc", "arm-linux-androideabi-", "gcc", "the c compiler") then return false end - if not prober._probe_toolpath(configs, "cxx", "arm-linux-androideabi-", "g++", "the c++ compiler") then return false end - if not prober._probe_toolpath(configs, "as", "arm-linux-androideabi-", "gcc", "the assember") then return false end - if not prober._probe_toolpath(configs, "ld", "arm-linux-androideabi-", "g++", "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", "arm-linux-androideabi-", "ar", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", "arm-linux-androideabi-", "g++", "the shared library linker") then return false end + if not prober._probe_toolpath(configs, "cc", prefix, "gcc", "the c compiler") then return false end + if not prober._probe_toolpath(configs, "cxx", prefix, "g++", "the c++ compiler") then return false end + if not prober._probe_toolpath(configs, "as", prefix, "gcc", "the assember") then return false end + if not prober._probe_toolpath(configs, "ld", prefix, "g++", "the linker") then return false end + if not prober._probe_toolpath(configs, "ar", prefix, "ar", "the static library linker") then return false end + if not prober._probe_toolpath(configs, "sh", prefix, "g++", "the shared library linker") then return false end return true end