Switched Android toolchain to LLVM.

This commit is contained in:
Branimir Karadžić
2016-12-26 20:50:22 -08:00
parent 30559bbd47
commit be3ff82dc8

View File

@@ -126,7 +126,7 @@ function toolchain(_buildDir, _libDir)
os.exit(1)
end
local androidPlatform = "android-14"
local androidPlatform = "android-24"
if _OPTIONS["with-android"] then
androidPlatform = "android-" .. _OPTIONS["with-android"]
end
@@ -164,35 +164,41 @@ function toolchain(_buildDir, _libDir)
if "android-arm" == _OPTIONS["gcc"] then
if not os.getenv("ANDROID_NDK_ARM") or not os.getenv("ANDROID_NDK_ROOT") then
print("Set ANDROID_NDK_ARM and ANDROID_NDK_ROOT envrionment variables.")
if not os.getenv("ANDROID_NDK_ARM")
or not os.getenv("ANDROID_NDK_CLANG")
or not os.getenv("ANDROID_NDK_ROOT") then
print("Set ANDROID_NDK_CLANG and ANDROID_NDK_ROOT envrionment variables.")
end
premake.gcc.cc = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-gcc"
premake.gcc.cxx = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-g++"
premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar"
premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
premake.gcc.llvm = true
location (path.join(_buildDir, "projects", _ACTION .. "-android-arm"))
elseif "android-mips" == _OPTIONS["gcc"] then
if not os.getenv("ANDROID_NDK_MIPS") or not os.getenv("ANDROID_NDK_ROOT") then
if not os.getenv("ANDROID_NDK_MIPS")
or not os.getenv("ANDROID_NDK_CLANG")
or not os.getenv("ANDROID_NDK_ROOT") then
print("Set ANDROID_NDK_MIPS and ANDROID_NDK_ROOT envrionment variables.")
end
premake.gcc.cc = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-gcc"
premake.gcc.cxx = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-g++"
premake.gcc.ar = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-ar"
premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
premake.gcc.llvm = true
location (path.join(_buildDir, "projects", _ACTION .. "-android-mips"))
elseif "android-x86" == _OPTIONS["gcc"] then
if not os.getenv("ANDROID_NDK_X86") or not os.getenv("ANDROID_NDK_ROOT") then
if not os.getenv("ANDROID_NDK_X86")
or not os.getenv("ANDROID_NDK_CLANG")
or not os.getenv("ANDROID_NDK_ROOT") then
print("Set ANDROID_NDK_X86 and ANDROID_NDK_ROOT envrionment variables.")
end
premake.gcc.cc = "$(ANDROID_NDK_X86)/bin/i686-linux-android-gcc"
premake.gcc.cxx = "$(ANDROID_NDK_X86)/bin/i686-linux-android-g++"
premake.gcc.ar = "$(ANDROID_NDK_X86)/bin/i686-linux-android-ar"
premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
premake.gcc.llvm = true
location (path.join(_buildDir, "projects", _ACTION .. "-android-x86"))
elseif "asmjs" == _OPTIONS["gcc"] then
@@ -811,12 +817,11 @@ function toolchain(_buildDir, _libDir)
"NoImportLib",
}
includedirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/include",
"$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
}
linkoptions {
"-nostdlib",
"-static-libgcc",
}
links {
"c",
@@ -824,16 +829,15 @@ function toolchain(_buildDir, _libDir)
"m",
"android",
"log",
"gnustl_static",
"c++",
"gcc",
}
buildoptions {
"-fPIC",
"-no-canonical-prefixes",
"-Wa,--noexecstack",
"-fstack-protector",
"-fstack-protector-strong",
"-ffunction-sections",
"-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
"-Wunused-value",
"-Wundef",
}
@@ -877,14 +881,16 @@ function toolchain(_buildDir, _libDir)
objdir (path.join(_buildDir, "android-arm/obj"))
libdirs {
path.join(_libDir, "lib/android-arm"),
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
}
includedirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/include",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/include",
}
buildoptions {
"-gcc-toolchain $(ANDROID_NDK_ARM)",
"--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
"-target armv7-none-linux-androideabi",
"-mthumb",
"-march=armv7-a",
"-mfloat-abi=softfp",
@@ -893,9 +899,11 @@ function toolchain(_buildDir, _libDir)
"-Wundef",
}
linkoptions {
"-gcc-toolchain $(ANDROID_NDK_ARM)",
"--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtbegin_so.o"),
path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtend_so.o"),
"-target armv7-none-linux-androideabi",
"-march=armv7-a",
"-Wl,--fix-cortex-a8",
}
@@ -905,20 +913,26 @@ function toolchain(_buildDir, _libDir)
objdir (path.join(_buildDir, "android-mips/obj"))
libdirs {
path.join(_libDir, "lib/android-mips"),
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips",
}
includedirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips/include",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips/include",
}
buildoptions {
"-gcc-toolchain $(ANDROID_NDK_MIPS)",
"--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
"-target mipsel-none-linux-android",
"-mips32",
"-Wunused-value",
"-Wundef",
}
linkoptions {
"-gcc-toolchain $(ANDROID_NDK_MIPS)",
"--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtbegin_so.o"),
path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtend_so.o"),
"-target mipsel-none-linux-android",
"-mips32",
}
configuration { "android-x86" }
@@ -926,13 +940,15 @@ function toolchain(_buildDir, _libDir)
objdir (path.join(_buildDir, "android-x86/obj"))
libdirs {
path.join(_libDir, "lib/android-x86"),
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86",
}
includedirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86/include",
}
buildoptions {
"-gcc-toolchain $(ANDROID_NDK_X86)",
"--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
"-target i686-none-linux-android",
"-march=i686",
"-mtune=atom",
"-mstackrealign",
@@ -942,9 +958,11 @@ function toolchain(_buildDir, _libDir)
"-Wundef",
}
linkoptions {
"-gcc-toolchain $(ANDROID_NDK_X86)",
"--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtbegin_so.o"),
path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtend_so.o"),
"-target i686-none-linux-android",
}
configuration { "asmjs" }