Forráskód Böngészése

Switched Android toolchain to LLVM.

Branimir Karadžić 9 éve
szülő
commit
be3ff82dc8
1 módosított fájl, 44 hozzáadás és 26 törlés
  1. 44 26
      scripts/toolchain.lua

+ 44 - 26
scripts/toolchain.lua

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