Skip to content

Commit

Permalink
fix arm64-v8a for android
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Dec 1, 2015
1 parent d010683 commit e88ecbf
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 18 deletions.
33 changes: 24 additions & 9 deletions xmake/scripts/platform/android/android.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
35 changes: 26 additions & 9 deletions xmake/scripts/platform/android/prober.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit e88ecbf

Please sign in to comment.