diff --git a/makefile b/makefile index bd0f334876b..ca2b88c8495 100644 --- a/makefile +++ b/makefile @@ -1043,27 +1043,31 @@ ifdef FASTBUILD $(SILENT) fbuild.exe -config $(PROJECTDIR_WIN)/vs2015-fastbuild/ftbuild.bff $(FASTBUILD_PARAMS) endif +#------------------------------------------------- +# android-ndk +#------------------------------------------------- + +.PHONY: android-ndk +android-ndk: +ifndef ANDROID_NDK_LLVM + $(error ANDROID_NDK_LLVM is not set) +endif +ifndef ANDROID_NDK_ROOT + $(error ANDROID_NDK_ROOT is not set) +endif + #------------------------------------------------- # android-arm #------------------------------------------------- -$(PROJECTDIR_SDL)/gmake-android-arm/Makefile: makefile $(SCRIPTS) $(GENIE) +$(PROJECTDIR_SDL)/gmake-android-arm/Makefile: makefile android-ndk $(SCRIPTS) $(GENIE) ifndef ANDROID_NDK_ARM $(error ANDROID_NDK_ARM is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) endif $(SILENT) $(GENIE) $(PARAMS) --gcc=android-arm --gcc_version=3.8.0 --osd=sdl --targetos=android --PLATFORM=arm --NO_USE_MIDI=1 --NO_OPENGL=1 --USE_QTDEBUG=0 --NO_X11=1 --DONT_USE_NETWORK=1 --NOASM=1 gmake .PHONY: android-arm android-arm: generate $(PROJECTDIR_SDL)/gmake-android-arm/Makefile -ifndef ANDROID_NDK_ARM - $(error ANDROID_NDK_ARM is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) -endif $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-arm config=$(CONFIG) precompile $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-arm config=$(CONFIG) @@ -1071,23 +1075,14 @@ endif # android-arm64 #------------------------------------------------- -$(PROJECTDIR_SDL)/gmake-android-arm64/Makefile: makefile $(SCRIPTS) $(GENIE) +$(PROJECTDIR_SDL)/gmake-android-arm64/Makefile: makefile android-ndk $(SCRIPTS) $(GENIE) ifndef ANDROID_NDK_ARM64 $(error ANDROID_NDK_ARM64 is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) endif $(SILENT) $(GENIE) $(PARAMS) --gcc=android-arm64 --gcc_version=3.8.0 --osd=sdl --targetos=android --PLATFORM=arm64 --NO_USE_MIDI=1 --NO_OPENGL=1 --USE_QTDEBUG=0 --NO_X11=1 --DONT_USE_NETWORK=1 --NOASM=1 gmake .PHONY: android-arm64 android-arm64: generate $(PROJECTDIR_SDL)/gmake-android-arm64/Makefile -ifndef ANDROID_NDK_ARM64 - $(error ANDROID_NDK_ARM64 is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) -endif $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-arm64 config=$(CONFIG) precompile $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-arm64 config=$(CONFIG) @@ -1095,23 +1090,14 @@ endif # android-mips #------------------------------------------------- -$(PROJECTDIR_SDL)/gmake-android-mips/Makefile: makefile $(SCRIPTS) $(GENIE) +$(PROJECTDIR_SDL)/gmake-android-mips/Makefile: makefile android-ndk $(SCRIPTS) $(GENIE) ifndef ANDROID_NDK_MIPS $(error ANDROID_NDK_MIPS is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) endif $(SILENT) $(GENIE) $(PARAMS) --gcc=android-mips --gcc_version=3.8.0 --osd=sdl --targetos=android --PLATFORM=mips --NO_USE_MIDI=1 --NO_OPENGL=1 --USE_QTDEBUG=0 --NO_X11=1 --DONT_USE_NETWORK=1 --NOASM=1 gmake .PHONY: android-mips android-mips: generate $(PROJECTDIR_SDL)/gmake-android-mips/Makefile -ifndef ANDROID_NDK_MIPS - $(error ANDROID_NDK_MIPS is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) -endif $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-mips config=$(CONFIG) precompile $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-mips config=$(CONFIG) @@ -1119,23 +1105,14 @@ endif # android-mips64 #------------------------------------------------- -$(PROJECTDIR_SDL)/gmake-android-mips64/Makefile: makefile $(SCRIPTS) $(GENIE) +$(PROJECTDIR_SDL)/gmake-android-mips64/Makefile: makefile android-ndk $(SCRIPTS) $(GENIE) ifndef ANDROID_NDK_MIPS64 $(error ANDROID_NDK_MIPS64 is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) endif $(SILENT) $(GENIE) $(PARAMS) --gcc=android-mips64 --gcc_version=3.8.0 --osd=sdl --targetos=android --PLATFORM=mips64 --NO_USE_MIDI=1 --NO_OPENGL=1 --USE_QTDEBUG=0 --NO_X11=1 --DONT_USE_NETWORK=1 --NOASM=1 gmake .PHONY: android-mips64 android-mips64: generate $(PROJECTDIR_SDL)/gmake-android-mips64/Makefile -ifndef ANDROID_NDK_MIPS64 - $(error ANDROID_NDK_MIPS64 is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) -endif $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-mips64 config=$(CONFIG) precompile $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-mips64 config=$(CONFIG) @@ -1143,23 +1120,14 @@ endif # android-x86 #------------------------------------------------- -$(PROJECTDIR_SDL)/gmake-android-x86/Makefile: makefile $(SCRIPTS) $(GENIE) +$(PROJECTDIR_SDL)/gmake-android-x86/Makefile: makefile android-ndk $(SCRIPTS) $(GENIE) ifndef ANDROID_NDK_X86 $(error ANDROID_NDK_X86 is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) endif $(SILENT) $(GENIE) $(PARAMS) --gcc=android-x86 --gcc_version=3.8.0 --osd=sdl --targetos=android --PLATFORM=x86 --NO_USE_MIDI=1 --NO_OPENGL=1 --USE_QTDEBUG=0 --NO_X11=1 --DONT_USE_NETWORK=1 gmake .PHONY: android-x86 android-x86: generate $(PROJECTDIR_SDL)/gmake-android-x86/Makefile -ifndef ANDROID_NDK_X86 - $(error ANDROID_NDK_X86 is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) -endif $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-x86 config=$(CONFIG) precompile $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-x86 config=$(CONFIG) @@ -1167,23 +1135,14 @@ endif # android-x64 #------------------------------------------------- -$(PROJECTDIR_SDL)/gmake-android-x64/Makefile: makefile $(SCRIPTS) $(GENIE) +$(PROJECTDIR_SDL)/gmake-android-x64/Makefile: makefile android-ndk $(SCRIPTS) $(GENIE) ifndef ANDROID_NDK_X64 $(error ANDROID_NDK_X64 is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) endif $(SILENT) $(GENIE) $(PARAMS) --gcc=android-x64 --gcc_version=3.8.0 --osd=sdl --targetos=android --PLATFORM=x64 --NO_USE_MIDI=1 --NO_OPENGL=1 --USE_QTDEBUG=0 --NO_X11=1 --DONT_USE_NETWORK=1 gmake .PHONY: android-x64 android-x64: generate $(PROJECTDIR_SDL)/gmake-android-x64/Makefile -ifndef ANDROID_NDK_X64 - $(error ANDROID_NDK_X64 is not set) -endif -ifndef ANDROID_NDK_LLVM - $(error ANDROID_NDK_LLVM is not set) -endif $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-x64 config=$(CONFIG) precompile $(SILENT) $(MAKE) $(MAKEPARAMS) -C $(PROJECTDIR_SDL)/gmake-android-x64 config=$(CONFIG) diff --git a/scripts/toolchain.lua b/scripts/toolchain.lua index d94b8abddec..8536845c266 100644 --- a/scripts/toolchain.lua +++ b/scripts/toolchain.lua @@ -95,6 +95,8 @@ function toolchain(_buildDir, _subDir) local androidPlatform = "android-14" if _OPTIONS["with-android"] then androidPlatform = "android-" .. _OPTIONS["with-android"] + elseif _OPTIONS["PLATFORM"]:find("64", -2) then + androidPlatform = "android-21" end local iosPlatform = "" @@ -115,73 +117,40 @@ function toolchain(_buildDir, _subDir) end if string.find(_OPTIONS["gcc"], "android") then - if not os.getenv("ANDROID_NDK_LLVM") then - print("Set ANDROID_NDK_LLVM envrionment variables.") + -- 64-bit android platform requires >= 21 + if _OPTIONS["PLATFORM"]:find("64", -2) and tonumber(androidPlatform:sub(9)) < 21 then + error("64-bit android requires platform 21 or higher") end + if not os.getenv("ANDROID_NDK_ROOT") then + print("Set ANDROID_NDK_ROOT environment variable.") + end + if not os.getenv("ANDROID_NDK_LLVM") then + print("Set ANDROID_NDK_LLVM envrionment variable.") + end + platform_ndk_env = "ANDROID_NDK_" .. _OPTIONS["PLATFORM"]:upper() + if not os.getenv(platform_ndk_env) then + print("Set " .. platform_ndk_env .. " environment variable.") + end + + local platformToolchainMap = { + ['arm'] = "arm-linux-androideabi", + ['arm64'] = "aarch64-linux-android", + ['mips64'] = "mips64el-linux-android", + ['mips'] = "mipsel-linux-android", + ['x86'] = "i686-linux-android", + ['x64'] = "x86_64-linux-android", + } + + toolchainPrefix = os.getenv(platform_ndk_env) .. "/bin/" .. platformToolchainMap[_OPTIONS["PLATFORM"]] .. "-" premake.gcc.cc = "$(ANDROID_NDK_LLVM)/bin/clang" premake.gcc.cxx = "$(ANDROID_NDK_LLVM)/bin/clang++" + premake.gcc.ar = toolchainPrefix .. "ar" premake.gcc.llvm = true + + location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-" .. _OPTIONS["PLATFORM"]) end - if "android-arm" == _OPTIONS["gcc"] then - if not os.getenv("ANDROID_NDK_ARM") then - print("Set ANDROID_NDK_ARM envrionment variables.") - end - - premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar" - location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-arm") - end - - if "android-arm64" == _OPTIONS["gcc"] then - if not os.getenv("ANDROID_NDK_ARM64") then - print("Set ANDROID_NDK_ARM64 envrionment variables.") - end - - premake.gcc.ar = "$(ANDROID_NDK_ARM64)/bin/aarch64-linux-android-ar" - premake.gcc.llvm = true - location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-arm64") - end - - if "android-mips" == _OPTIONS["gcc"] then - if not os.getenv("ANDROID_NDK_MIPS") then - print("Set ANDROID_NDK_MIPS envrionment variables.") - end - - premake.gcc.ar = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-ar" - premake.gcc.llvm = true - location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-mips") - end - - if "android-mips64" == _OPTIONS["gcc"] then - if not os.getenv("ANDROID_NDK_MIPS64") then - print("Set ANDROID_NDK_MIPS64 envrionment variables.") - end - - premake.gcc.ar = "$(ANDROID_NDK_MIPS64)/bin/mips64el-linux-android-ar" - premake.gcc.llvm = true - location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-mips64") - end - - if "android-x86" == _OPTIONS["gcc"] then - if not os.getenv("ANDROID_NDK_X86") then - print("Set ANDROID_NDK_X86 envrionment variables.") - end - - premake.gcc.ar = "$(ANDROID_NDK_X86)/bin/i686-linux-android-ar" - premake.gcc.llvm = true - location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-x86") - end - - if "android-x64" == _OPTIONS["gcc"] then - if not os.getenv("ANDROID_NDK_X64") then - print("Set ANDROID_NDK_X64 envrionment variables.") - end - - premake.gcc.ar = "$(ANDROID_NDK_X64)/bin/x86_64-linux-android-ar" - premake.gcc.llvm = true - location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-x64") - end if "asmjs" == _OPTIONS["gcc"] then if not os.getenv("EMSCRIPTEN") then @@ -804,6 +773,8 @@ function toolchain(_buildDir, _subDir) targetdir (_buildDir .. "openbsd" .. "/bin/x64/Debug") configuration { "android-*" } + targetdir (_buildDir .. "android-" .. _OPTIONS["PLATFORM"] .. "/bin") + objdir (_buildDir .. "android-" .. _OPTIONS["PLATFORM"] .. "/obj") includedirs { MAME_DIR .. "3rdparty/bgfx/3rdparty/khronos", "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libcxx/include", @@ -848,8 +819,6 @@ function toolchain(_buildDir, _subDir) configuration { "android-arm" } - targetdir (_buildDir .. "android-arm" .. "/bin") - objdir (_buildDir .. "android-arm" .. "/obj") libdirs { "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib", @@ -876,9 +845,6 @@ function toolchain(_buildDir, _subDir) } configuration { "android-arm64" } - androidPlatform = "android-21" -- supported from API 21 - targetdir (_buildDir .. "android-arm64" .. "/bin") - objdir (_buildDir .. "android-arm64" .. "/obj") libdirs { "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/arm64-v8a", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm64/usr/lib64", @@ -899,8 +865,6 @@ function toolchain(_buildDir, _subDir) } configuration { "android-mips" } - targetdir (_buildDir .. "android-mips" .. "/bin") - objdir (_buildDir .. "android-mips" .. "/obj") libdirs { "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/", @@ -921,9 +885,6 @@ function toolchain(_buildDir, _subDir) } configuration { "android-mips64" } - androidPlatform = "android-21" -- supported from API 21 - targetdir (_buildDir .. "android-mips64" .. "/bin") - objdir (_buildDir .. "android-mips64" .. "/obj") libdirs { "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips64", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips64/usr/lib64/", @@ -944,8 +905,6 @@ function toolchain(_buildDir, _subDir) } configuration { "android-x86" } - targetdir (_buildDir .. "android-x86" .. "/bin") - objdir (_buildDir .. "android-x86" .. "/obj") libdirs { "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib", @@ -968,9 +927,6 @@ function toolchain(_buildDir, _subDir) } configuration { "android-x64" } - androidPlatform = "android-21" -- supported from API 21 - targetdir (_buildDir .. "android-x64" .. "/bin") - objdir (_buildDir .. "android-x64" .. "/obj") libdirs { "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86_64", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86_64/usr/lib64", @@ -1092,22 +1048,10 @@ function strip() "$(SILENT) " .. (_OPTIONS['TOOLCHAIN'] and toolchainPrefix) .. "strip \"$(TARGET)\"", } - configuration { "android-arm", "Release" } + configuration { "android-*", "Release" } postbuildcommands { "$(SILENT) echo Stripping symbols.", - "$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\"" - } - - configuration { "android-mips", "Release" } - postbuildcommands { - "$(SILENT) echo Stripping symbols.", - "$(SILENT) $(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-strip -s \"$(TARGET)\"" - } - - configuration { "android-x86", "Release" } - postbuildcommands { - "$(SILENT) echo Stripping symbols.", - "$(SILENT) $(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\"" + "$(SILENT) " .. toolchainPrefix .. "strip -s \"$(TARGET)\"" } configuration { "linux-* or rpi", "Release" }