Add compilation target android-arm64 (#208)

* Add android-arm64 support

cd bgfx
export ANDROID_NDK_ROOT=$NDK_ROOT
export ANDROID_NDK_ARM=$NDK_ROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64
export ANDROID_NDK_CLANG=$NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64
make android-arm64

* Expect ANDROID_NDK_ARM64 to define the compilation aarch64 toolchain

Using _ARM64 will generate less conflict in configuration files than
reusing the _ARM var.

For example, to setup an android-arm64:

export ANDROID_NDK_ROOT=$NDK_ROOT
export ANDROID_NDK_ARM64=$NDK_ROOT/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64
export ANDROID_NDK_CLANG=$NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64

make android-arm64
This commit is contained in:
magic/foo
2019-06-27 01:21:04 -05:00
committed by Бранимир Караџић
parent 71dae1cdb6
commit b86f343f30
2 changed files with 58 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ GENIE=../bx/tools/bin/$(OS)/genie
all:
$(GENIE) vs2017
$(GENIE) --gcc=android-arm gmake
$(GENIE) --gcc=android-arm64 gmake
$(GENIE) --gcc=android-mips gmake
$(GENIE) --gcc=android-x86 gmake
$(GENIE) --gcc=mingw-gcc gmake
@@ -27,6 +28,14 @@ android-arm-release: .build/projects/gmake-android-arm
make -R -C .build/projects/gmake-android-arm config=release
android-arm: android-arm-debug android-arm-release
.build/projects/gmake-android-arm64:
$(GENIE) --gcc=android-arm64 gmake
android-arm64-debug: .build/projects/gmake-android-arm64
make -R -C .build/projects/gmake-android-arm64 config=debug
android-arm64-release: .build/projects/gmake-android-arm64
make -R -C .build/projects/gmake-android-arm64 config=release
android-arm64: android-arm64-debug android-arm64-release
.build/projects/gmake-android-mips:
$(GENIE) --gcc=android-mips gmake
android-mips-debug: .build/projects/gmake-android-mips

View File

@@ -50,6 +50,7 @@ function toolchain(_buildDir, _libDir)
description = "Choose GCC flavor",
allowed = {
{ "android-arm", "Android - ARM" },
{ "android-arm64", "Android - ARM64" },
{ "android-x86", "Android - x86" },
{ "asmjs", "Emscripten/asm.js" },
{ "freebsd", "FreeBSD" },
@@ -221,6 +222,21 @@ function toolchain(_buildDir, _libDir)
premake.gcc.llvm = true
location (path.join(_buildDir, "projects", _ACTION .. "-android-arm"))
elseif "android-arm64" == _OPTIONS["gcc"] then
if not os.getenv("ANDROID_NDK_ARM64")
or not os.getenv("ANDROID_NDK_CLANG")
or not os.getenv("ANDROID_NDK_ROOT") then
print("Set ANDROID_NDK_CLANG, ANDROID_NDK_ARM64, and ANDROID_NDK_ROOT environment variables.")
end
premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
premake.gcc.ar = "$(ANDROID_NDK_ARM64)/bin/aarch64-linux-android-ar"
premake.gcc.llvm = true
location (path.join(_buildDir, "projects", _ACTION .. "-android-arm64"))
elseif "android-x86" == _OPTIONS["gcc"] then
if not os.getenv("ANDROID_NDK_X86")
@@ -893,6 +909,33 @@ function toolchain(_buildDir, _libDir)
"-Wl,--fix-cortex-a8",
}
configuration { "android-arm64" }
targetdir (path.join(_buildDir, "android-arm64/bin"))
objdir (path.join(_buildDir, "android-arm64/obj"))
libdirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/arm64-v8a",
}
includedirs {
"$(ANDROID_NDK_ROOT)/sysroot/usr/include/aarch64-linux-android",
}
buildoptions {
"-gcc-toolchain $(ANDROID_NDK_ARM64)",
"--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64"),
"-target aarch64-none-linux-androideabi",
"-march=armv8-a",
"-Wunused-value",
"-Wundef",
}
linkoptions {
"-gcc-toolchain $(ANDROID_NDK_ARM64)",
"--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64"),
path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64/usr/lib/crtbegin_so.o"),
path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64/usr/lib/crtend_so.o"),
"-target aarch64-none-linux-androideabi",
"-march=armv8-a",
"-Wl,--fix-cortex-a8",
}
configuration { "android-x86" }
targetdir (path.join(_buildDir, "android-x86/bin"))
objdir (path.join(_buildDir, "android-x86/obj"))
@@ -1202,6 +1245,12 @@ function strip()
"$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
}
configuration { "android-arm64", "Release" }
postbuildcommands {
"$(SILENT) echo Stripping symbols.",
"$(SILENT) $(ANDROID_NDK_ARM64)/bin/aarch64-linux-android-strip -s \"$(TARGET)\""
}
configuration { "android-x86", "Release" }
postbuildcommands {
"$(SILENT) echo Stripping symbols.",