Make Android targets compile but not link, using clang compiler in NDK, since GCC will be removed in next one (nw)

This commit is contained in:
Miodrag Milanovic 2016-02-25 20:43:40 +01:00
parent 08d84121d4
commit add7a65f3f
6 changed files with 69 additions and 41 deletions

View File

@ -2211,9 +2211,9 @@ namespace bgfx
} }
} }
const Memory* imageAlloc(ImageContainer& _imageContainer, TextureFormat::Enum _format, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _mips) const Memory* imageAlloc(ImageContainer& _imageContainer, TextureFormat::Enum _format, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _mipsActive)
{ {
const uint8_t numMips = _mips ? imageGetNumMips(_format, _width, _height) : 1; const uint8_t numMips = _mipsActive ? imageGetNumMips(_format, _width, _height) : 1;
uint32_t size = imageGetSize(_format, _width, _height, 0, false, numMips); uint32_t size = imageGetSize(_format, _width, _height, 0, false, numMips);
const Memory* image = alloc(size); const Memory* image = alloc(size);

View File

@ -121,7 +121,7 @@ namespace bgfx
bool imageConvert(void* _dst, TextureFormat::Enum _dstFormat, const void* _src, TextureFormat::Enum _srcFormat, uint32_t _width, uint32_t _height); bool imageConvert(void* _dst, TextureFormat::Enum _dstFormat, const void* _src, TextureFormat::Enum _srcFormat, uint32_t _width, uint32_t _height);
/// ///
const Memory* imageAlloc(ImageContainer& _imageContainer, TextureFormat::Enum _format, uint16_t _width, uint16_t _height, uint16_t _depth = 0, bool _cubeMap = false, bool _mips = false); const Memory* imageAlloc(ImageContainer& _imageContainer, TextureFormat::Enum _format, uint16_t _width, uint16_t _height, uint16_t _depth = 0, bool _cubeMap = false, bool _mipsActive = false);
/// ///
void imageFree(const Memory* _memory); void imageFree(const Memory* _memory);

View File

@ -1025,10 +1025,15 @@ configuration { "asmjs" }
configuration { "android*" } configuration { "android*" }
buildoptions { buildoptions {
"-Wno-undef", "-Wno-undef",
"-Wno-typedef-redefinition",
"-Wno-unknown-warning-option",
} }
buildoptions_cpp { buildoptions_cpp {
"-x c++", "-x c++",
"-std=c++14", "-std=c++14",
"-Wno-extern-c-compat",
"-Wno-tautological-constant-out-of-range-compare",
"-Wno-tautological-pointer-compare",
} }
archivesplit_size "20" archivesplit_size "20"

View File

@ -537,10 +537,14 @@ project "luv"
"-Wno-unused-function", "-Wno-unused-function",
"-Wno-strict-prototypes", "-Wno-strict-prototypes",
"-Wno-unused-variable", "-Wno-unused-variable",
"-Wno-maybe-uninitialized",
"-Wno-undef", "-Wno-undef",
} }
configuration { "not android-*" }
buildoptions_c {
"-Wno-maybe-uninitialized",
}
configuration { "vs2015" } configuration { "vs2015" }
buildoptions { buildoptions {
"/wd4701", -- warning C4701: potentially uninitialized local variable 'xxx' used "/wd4701", -- warning C4701: potentially uninitialized local variable 'xxx' used
@ -749,6 +753,11 @@ end
MAME_DIR .. "3rdparty/bgfx/3rdparty/khronos", MAME_DIR .. "3rdparty/bgfx/3rdparty/khronos",
} }
configuration { "android-*"}
buildoptions {
"-Wno-macro-redefined",
}
configuration { "vs*" } configuration { "vs*" }
includedirs { includedirs {
MAME_DIR .. "3rdparty/bx/include/compat/msvc", MAME_DIR .. "3rdparty/bx/include/compat/msvc",
@ -890,7 +899,7 @@ end
local version = str_to_version(_OPTIONS["gcc_version"]) local version = str_to_version(_OPTIONS["gcc_version"])
if (_OPTIONS["gcc"]~=nil) then if (_OPTIONS["gcc"]~=nil) then
if string.find(_OPTIONS["gcc"], "clang") then if string.find(_OPTIONS["gcc"], "clang") or string.find(_OPTIONS["gcc"], "android") then
buildoptions_c { buildoptions_c {
"-Wno-unknown-warning-option", "-Wno-unknown-warning-option",
"-Wno-absolute-value", "-Wno-absolute-value",
@ -1024,7 +1033,7 @@ project "uv"
local version = str_to_version(_OPTIONS["gcc_version"]) local version = str_to_version(_OPTIONS["gcc_version"])
if (_OPTIONS["gcc"]~=nil) then if (_OPTIONS["gcc"]~=nil) then
if string.find(_OPTIONS["gcc"], "clang") then if string.find(_OPTIONS["gcc"], "clang") or string.find(_OPTIONS["gcc"], "android") then
buildoptions_c { buildoptions_c {
"-Wno-unknown-warning-option", "-Wno-unknown-warning-option",
"-Wno-unknown-attributes", "-Wno-unknown-attributes",

View File

@ -25,6 +25,17 @@ else
end end
uuid (os.uuid(_target .."_" .. _subtarget)) uuid (os.uuid(_target .."_" .. _subtarget))
kind "ConsoleApp" kind "ConsoleApp"
configuration { "android*" }
targetextension ".so"
linkoptions {
"-shared",
}
links {
"EGL",
"GLESv2",
}
configuration { }
addprojectflags() addprojectflags()
flags { flags {

View File

@ -106,9 +106,10 @@ function toolchain(_buildDir, _subDir)
print("Set ANDROID_NDK_ARM and ANDROID_NDK_ROOT envrionment variables.") print("Set ANDROID_NDK_ARM and ANDROID_NDK_ROOT envrionment variables.")
end end
premake.gcc.cc = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-gcc" premake.gcc.cc = "$(ANDROID_NDK_ROOT)/toolchains/llvm-3.6/prebuilt/windows-x86_64/bin/clang.exe"
premake.gcc.cxx = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-g++" premake.gcc.cxx = "$(ANDROID_NDK_ROOT)/toolchains/llvm-3.6/prebuilt/windows-x86_64/bin/clang++.exe"
premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar" premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar"
premake.gcc.llvm = true
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-arm") location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-arm")
end end
@ -118,9 +119,10 @@ function toolchain(_buildDir, _subDir)
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.cc = "$(ANDROID_NDK_ROOT)/toolchains/llvm-3.6/prebuilt/windows-x86_64/bin/clang.exe"
premake.gcc.cxx = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-g++" premake.gcc.cxx = "$(ANDROID_NDK_ROOT)/toolchains/llvm-3.6/prebuilt/windows-x86_64/bin/clang++.exe"
premake.gcc.ar = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-ar" premake.gcc.ar = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-ar"
premake.gcc.llvm = true
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-mips") location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-mips")
end end
@ -130,9 +132,10 @@ function toolchain(_buildDir, _subDir)
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.cc = "$(ANDROID_NDK_ROOT)/toolchains/llvm-3.6/prebuilt/windows-x86_64/bin/clang.exe"
premake.gcc.cxx = "$(ANDROID_NDK_X86)/bin/i686-linux-android-g++" premake.gcc.cxx = "$(ANDROID_NDK_ROOT)/toolchains/llvm-3.6/prebuilt/windows-x86_64/bin/clang++.exe"
premake.gcc.ar = "$(ANDROID_NDK_X86)/bin/i686-linux-android-ar" premake.gcc.ar = "$(ANDROID_NDK_X86)/bin/i686-linux-android-ar"
premake.gcc.llvm = true
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-x86") location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-android-x86")
end end
@ -629,11 +632,12 @@ function toolchain(_buildDir, _subDir)
configuration { "android-*" } configuration { "android-*" }
includedirs { includedirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include", MAME_DIR .. "3rdparty/bgfx/3rdparty/khronos",
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libcxx/include",
"$(ANDROID_NDK_ROOT)/sources/android/support/include",
"$(ANDROID_NDK_ROOT)/sources/android/native_app_glue", "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
} }
linkoptions { linkoptions {
"-nostdlib",
"-static-libgcc", "-static-libgcc",
} }
flags { flags {
@ -645,19 +649,18 @@ function toolchain(_buildDir, _subDir)
"m", "m",
"android", "android",
"log", "log",
"gnustl_static",
"gcc", "gcc",
} }
buildoptions { buildoptions {
"-fPIC", "-fpic",
"-no-canonical-prefixes",
"-Wa,--noexecstack",
"-fstack-protector",
"-ffunction-sections", "-ffunction-sections",
"-Wno-cast-align", "-funwind-tables",
"-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0 "-fstack-protector-strong",
"-no-canonical-prefixes",
"-fno-integrated-as",
"-Wunused-value", "-Wunused-value",
"-Wundef", "-Wundef",
"-Wno-cast-align",
} }
linkoptions { linkoptions {
"-no-canonical-prefixes", "-no-canonical-prefixes",
@ -672,44 +675,46 @@ function toolchain(_buildDir, _subDir)
targetdir (_buildDir .. "android-arm" .. "/bin") targetdir (_buildDir .. "android-arm" .. "/bin")
objdir (_buildDir .. "android-arm" .. "/obj") objdir (_buildDir .. "android-arm" .. "/obj")
libdirs { libdirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a", "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib",
} }
includedirs { includedirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/include", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/include",
} }
buildoptions { buildoptions {
"-mthumb", "-gcc-toolchain $(ANDROID_NDK_ARM)",
"-target armv7-none-linux-androideabi",
"-march=armv7-a", "-march=armv7-a",
"-mfloat-abi=softfp", "-mfloat-abi=softfp",
"-mfpu=neon", "-mfpu=vfpv3-d16",
"-Wunused-value", "-mthumb",
"-Wundef",
} }
linkoptions { linkoptions {
"-gcc-toolchain $(ANDROID_NDK_ARM)",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib/crtbegin_so.o", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib/crtbegin_so.o",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-arm/usr/lib/crtend_so.o", "$(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", "-mthumb",
} }
configuration { "android-mips" } configuration { "android-mips" }
targetdir (_buildDir .. "android-mips" .. "/bin") targetdir (_buildDir .. "android-mips" .. "/bin")
objdir (_buildDir .. "android-mips" .. "/obj") objdir (_buildDir .. "android-mips" .. "/obj")
libdirs { libdirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips", "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/",
} }
includedirs { includedirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips/include",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/include", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/include",
} }
buildoptions { buildoptions {
"-Wunused-value", "-gcc-toolchain $(ANDROID_NDK_MIPS)",
"-Wundef", "-target mipsel-none-linux-android",
} }
linkoptions { linkoptions {
"-gcc-toolchain $(ANDROID_NDK_MIPS)",
"-target mipsel-none-linux-android",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtbegin_so.o", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtbegin_so.o",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtend_so.o", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-mips/usr/lib/crtend_so.o",
} }
@ -718,23 +723,21 @@ function toolchain(_buildDir, _subDir)
targetdir (_buildDir .. "android-x86" .. "/bin") targetdir (_buildDir .. "android-x86" .. "/bin")
objdir (_buildDir .. "android-x86" .. "/obj") objdir (_buildDir .. "android-x86" .. "/obj")
libdirs { libdirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86", "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib",
} }
includedirs { includedirs {
"$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/include", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/include",
} }
buildoptions { buildoptions {
"-march=i686", "-gcc-toolchain $(ANDROID_NDK_X86)",
"-mtune=atom", "-target i686-none-linux-android",
"-mstackrealign", "-mssse3"
"-msse3",
"-mfpmath=sse",
"-Wunused-value",
"-Wundef",
} }
linkoptions { linkoptions {
"-gcc-toolchain $(ANDROID_NDK_X86)",
"-target i686-none-linux-android",
"-mssse3",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib/crtbegin_so.o", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib/crtbegin_so.o",
"$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib/crtend_so.o", "$(ANDROID_NDK_ROOT)/platforms/" .. androidPlatform .. "/arch-x86/usr/lib/crtend_so.o",
} }