if not NDKEnv.isHostOsSupported(self.env.ndk.hostOsName):
raise Exception("NDK '%s' is not supported on this machine" % self.env.ndk.hostOsName)
- supportedNDKVersion = [11, 15]
- if self.env.ndk.version[0] not in supportedNDKVersion:
- raise Exception("Android NDK version %d is not supported; build requires NDK version %s" % (self.env.ndk.version[0], supportedNDKVersion))
-
- # https://gitlab.khronos.org/Tracker/vk-gl-cts/issues/723
- if self.env.ndk.version[0] == 15:
- if "armeabi-v7a" in self.abis:
- raise Exception("dEQP is incompatible with NDK r15 for armeabi-v7a")
- else:
- print >> sys.stderr, "WARNING: Support for NDK r15 is experimental; NDK r11c is recommended for official submissions"
+ if self.env.ndk.version[0] < 15 and self.env.ndk.version[0] != 11:
+ raise Exception("Android NDK version %d is not supported; build requires NDK version 11c or >= 15" % (self.env.ndk.version[0]))
if self.env.sdk.buildToolsVersion == (0,0,0):
raise Exception("No build tools directory found at %s" % os.path.join(self.env.sdk.path, "build-tools"))
return "r%d%s" % (version[0], minorVersionString)
def getBuildArgs (config, abiName):
- toolchain = 'ndk-%s' % makeNDKVersionString((config.env.ndk.version[0], 0))
+ if config.env.ndk.version[0] == 11:
+ toolchain = 'ndk-%s' % makeNDKVersionString((config.env.ndk.version[0], 0))
+ else:
+ toolchain = 'ndk-modern'
return ['-DDEQP_TARGET=android',
'-DDEQP_TARGET_TOOLCHAIN=%s' % toolchain,
'-DCMAKE_C_FLAGS=-Werror',
--- /dev/null
+#-------------------------------------------------------------------------
+# drawElements CMake utilities
+# ----------------------------
+#
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-------------------------------------------------------------------------
+
+# Delegate most things to the NDK's cmake toolchain script
+
+if (NOT DEFINED ANDROID_NDK_PATH)
+ message(FATAL_ERROR "Please provide ANDROID_NDK_PATH")
+endif ()
+
+set(ANDROID_PLATFORM "android-${DE_ANDROID_API}")
+set(ANDROID_STL c++_static)
+set(ANDROID_CPP_FEATURES "rtti exceptions")
+
+include(${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake)
+
+# The try_compile() used to verify the C/C++ compilers are sane tries to
+# generate an executable, but doesn't seem to use the right compiler/linker
+# options when cross-compiling, so it fails even when building an actual
+# shared library or executable succeeds.
+#
+# I don't know why this doesn't affect simpler projects that use the NDK
+# toolchain.
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+
+# Set variables used by other parts of dEQP's build scripts
+
+set(DE_OS "DE_OS_ANDROID")
+
+if (NOT DEFINED DE_COMPILER)
+ set(DE_COMPILER "DE_COMPILER_CLANG")
+endif ()
+
+if (ANDROID_ABI STREQUAL "x86")
+ set(DE_CPU "DE_CPU_X86")
+elseif (ANDROID_ABI STREQUAL "armeabi" OR
+ ANDROID_ABI STREQUAL "armeabi-v7a")
+ set(DE_CPU "DE_CPU_ARM")
+elseif (ANDROID_ABI STREQUAL "arm64-v8a")
+ set(DE_CPU "DE_CPU_ARM_64")
+elseif (ANDROID_ABI STREQUAL "x86_64")
+ set(DE_CPU "DE_CPU_X86_64")
+else ()
+ message(FATAL_ERROR "Unknown ABI \"${ANDROID_ABI}\"")
+endif ()
+++ /dev/null
-#-------------------------------------------------------------------------
-# drawElements CMake utilities
-# ----------------------------
-#
-# Copyright 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#-------------------------------------------------------------------------
-
-# CMake 3.2 fixed a bug [1] that prevents using different --sysroot arguments
-# for compile and link steps in the built-in try_compile() that cmake does.
-# Since NDK r15 has separate header and library sysroots, that's necessary.
-# We could use -isysroot for headers and --sysroot= for libs, except that
-# clang's -isysroot appears to be broken (Google internal b/64158294).
-#
-# [1] https://cmake.org/cmake/help/v3.2/policy/CMP0056.html
-cmake_minimum_required(VERSION 3.2)
-
-# Platform defines.
-set(CMAKE_SYSTEM_NAME Linux)
-
-set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
-
-set(CMAKE_CROSSCOMPILING 1)
-
-# NDK installation path
-if (NOT DEFINED ANDROID_NDK_PATH)
- message(FATAL_ERROR "Please provide ANDROID_NDK_PATH")
-endif ()
-
-# Host os (for toolchain binaries)
-if (NOT DEFINED ANDROID_NDK_HOST_OS)
- message(FATAL_ERROR "Please provide ANDROID_NDK_HOST_OS")
-endif ()
-
-# Compile target
-set(ANDROID_ABI "armeabi-v7a" CACHE STRING "Android ABI")
-set(ANDROID_NDK_TARGET "android-${DE_ANDROID_API}")
-
-# dE defines
-set(DE_OS "DE_OS_ANDROID")
-
-if (NOT DEFINED DE_COMPILER)
- set(DE_COMPILER "DE_COMPILER_CLANG")
-endif ()
-
-if (NOT DEFINED DE_ANDROID_API)
- set(DE_ANDROID_API 9)
-endif ()
-
-# ABI-dependent bits
-if (ANDROID_ABI STREQUAL "x86")
- set(DE_CPU "DE_CPU_X86")
- set(CMAKE_SYSTEM_PROCESSOR i686-linux-android)
-
- set(ANDROID_CC_PATH "${ANDROID_NDK_PATH}/toolchains/x86-4.9/prebuilt/${ANDROID_NDK_HOST_OS}/")
- set(CROSS_COMPILE "${ANDROID_CC_PATH}bin/i686-linux-android-")
- set(ANDROID_LIB_SYSROOT "${ANDROID_NDK_PATH}/platforms/${ANDROID_NDK_TARGET}/arch-x86")
-
- set(CMAKE_FIND_ROOT_PATH
- "${ANDROID_CC_PATH}i686-linux-android"
- "${ANDROID_CC_PATH}lib/gcc/i686-linux-android/4.9"
- )
-
- set(TARGET_C_FLAGS "-march=i686 -msse3 -mstackrealign -mfpmath=sse")
- set(TARGET_LINKER_FLAGS "")
- set(LLVM_TRIPLE "i686-none-linux-android")
-
-elseif (ANDROID_ABI STREQUAL "armeabi" OR
- ANDROID_ABI STREQUAL "armeabi-v7a")
- set(DE_CPU "DE_CPU_ARM")
- set(CMAKE_SYSTEM_PROCESSOR arm-linux-androideabi)
-
- set(ANDROID_CC_PATH "${ANDROID_NDK_PATH}/toolchains/arm-linux-androideabi-4.9/prebuilt/${ANDROID_NDK_HOST_OS}/")
- set(CROSS_COMPILE "${ANDROID_CC_PATH}bin/arm-linux-androideabi-")
- set(ANDROID_LIB_SYSROOT "${ANDROID_NDK_PATH}/platforms/${ANDROID_NDK_TARGET}/arch-arm")
- set(ARM_C_FLAGS "-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ ")
-
- if (ANDROID_ABI STREQUAL "armeabi-v7a")
- set(TARGET_C_FLAGS "${ARM_C_FLAGS} -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp")
- set(TARGET_LINKER_FLAGS "-Wl,--fix-cortex-a8 -march=armv7-a")
- set(LLVM_TRIPLE "armv7-none-linux-androideabi")
-
- else () # armeabi
- set(TARGET_C_FLAGS "${ARM_C_FLAGS} -march=armv5te -mfloat-abi=softfp")
- set(TARGET_LINKER_FLAGS "-Wl,--fix-cortex-a8 -march=armv5te")
- set(LLVM_TRIPLE "armv5te-none-linux-androideabi")
- endif ()
-
- set(CMAKE_FIND_ROOT_PATH
- "${ANDROID_CC_PATH}arm-linux-androideabi"
- )
-
-elseif (ANDROID_ABI STREQUAL "arm64-v8a")
- set(DE_CPU "DE_CPU_ARM_64")
- set(CMAKE_SYSTEM_PROCESSOR aarch64-linux-android)
- set(CMAKE_SIZEOF_VOID_P 8)
-
- set(ANDROID_CC_PATH "${ANDROID_NDK_PATH}/toolchains/aarch64-linux-android-4.9/prebuilt/${ANDROID_NDK_HOST_OS}/")
- set(CROSS_COMPILE "${ANDROID_CC_PATH}bin/aarch64-linux-android-")
- set(ANDROID_LIB_SYSROOT "${ANDROID_NDK_PATH}/platforms/${ANDROID_NDK_TARGET}/arch-arm64")
-
- set(CMAKE_FIND_ROOT_PATH
- "${ANDROID_CC_PATH}arm-linux-androideabi"
- )
-
- set(TARGET_C_FLAGS "-march=armv8-a")
- set(TARGET_LINKER_FLAGS "-Wl,--fix-cortex-a53-835769 -Wl,--fix-cortex-a53-835769 -march=armv8-a")
- set(LLVM_TRIPLE "aarch64-none-linux-android")
-
- if (DE_COMPILER STREQUAL "DE_COMPILER_GCC")
- set(TARGET_C_FLAGS "${TARGET_C_FLAGS} -mabi=lp64")
- endif ()
-
-elseif (ANDROID_ABI STREQUAL "x86_64")
- set(DE_CPU "DE_CPU_X86_64")
- set(CMAKE_SYSTEM_PROCESSOR x86_64-linux-android)
- set(CMAKE_SIZEOF_VOID_P 8)
-
- set(CMAKE_LIBRARY_PATH "/usr/lib64")
-
- set(ANDROID_CC_PATH "${ANDROID_NDK_PATH}/toolchains/x86_64-4.9/prebuilt/${ANDROID_NDK_HOST_OS}/")
- set(CROSS_COMPILE "${ANDROID_CC_PATH}bin/x86_64-linux-android-")
- set(ANDROID_LIB_SYSROOT "${ANDROID_NDK_PATH}/platforms/${ANDROID_NDK_TARGET}/arch-x86_64")
-
- set(CMAKE_FIND_ROOT_PATH
- "${ANDROID_CC_PATH}x86_64-linux-android"
- )
-
- set(LLVM_TRIPLE "x86_64-none-linux-android")
-
-else ()
- message(FATAL_ERROR "Unknown ABI \"${ANDROID_ABI}\"")
-endif ()
-
-set(ANDROID_HEADER_SYSROOT "${ANDROID_NDK_PATH}/sysroot")
-
-set(COMMON_C_FLAGS "-D__STDC_INT64__ -D__ANDROID_API__=${DE_ANDROID_API} -isystem ${ANDROID_HEADER_SYSROOT}/usr/include/${CMAKE_SYSTEM_PROCESSOR} --sysroot=${ANDROID_HEADER_SYSROOT}")
-set(COMMON_CXX_FLAGS "${COMMON_C_FLAGS} -frtti -fexceptions")
-set(COMMON_LINKER_FLAGS "--sysroot=${ANDROID_LIB_SYSROOT}")
-
-# Use LLVM libc++ for full C++11 support
-set(ANDROID_CXX_PATH "${ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++")
-set(ANDROID_CXX_LIBRARY "-L${ANDROID_CXX_PATH}/libs/${ANDROID_ABI} ${ANDROID_CXX_PATH}/libs/${ANDROID_ABI}/libc++_static.a" "${ANDROID_CXX_PATH}/libs/${ANDROID_ABI}/libc++abi.a" "${ANDROID_CXX_PATH}/libs/${ANDROID_ABI}/libandroid_support.a")
-set(CXX_INCLUDES "-I${ANDROID_CXX_PATH}/include")
-
-set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${ANDROID_HEADER_SYSROOT} ${ANDROID_LIB_SYSROOT})
-
-include(CMakeForceCompiler)
-
-if (ANDROID_NDK_HOST_OS STREQUAL "windows" OR
- ANDROID_NDK_HOST_OS STREQUAL "windows-x86_64")
- set(BIN_EXT ".exe")
-else ()
- set(BIN_EXT "")
-endif ()
-
-if (DE_COMPILER STREQUAL "DE_COMPILER_GCC")
- set(CMAKE_C_COMPILER "${CROSS_COMPILE}gcc${BIN_EXT}" CACHE FILEPATH "C Compiler")
- set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++${BIN_EXT}" CACHE FILEPATH "C++ Compiler")
-
- set(TARGET_C_FLAGS "-mandroid ${TARGET_C_FLAGS}")
-
-elseif (DE_COMPILER STREQUAL "DE_COMPILER_CLANG")
- set(LLVM_PATH "${ANDROID_NDK_PATH}/toolchains/llvm/prebuilt/${ANDROID_NDK_HOST_OS}/")
-
- set(CMAKE_C_COMPILER "${LLVM_PATH}bin/clang${BIN_EXT}" CACHE FILEPATH "C Compiler")
- set(CMAKE_CXX_COMPILER "${LLVM_PATH}bin/clang++${BIN_EXT}" CACHE FILEPATH "C++ Compiler")
- set(CMAKE_AR "${CROSS_COMPILE}ar${BIN_EXT}" CACHE FILEPATH "Archiver")
- set(CMAKE_RANLIB "${CROSS_COMPILE}ranlib${BIN_EXT}" CACHE FILEPATH "Indexer")
-
- set(TARGET_C_FLAGS "-target ${LLVM_TRIPLE} -gcc-toolchain ${ANDROID_CC_PATH} ${TARGET_C_FLAGS}")
- set(TARGET_LINKER_FLAGS "-target ${LLVM_TRIPLE} -gcc-toolchain ${ANDROID_CC_PATH} ${TARGET_LINKER_FLAGS}")
-
-endif ()
-
-set(CMAKE_SHARED_LIBRARY_C_FLAGS "")
-set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
-
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-
-# \note Without CACHE STRING FORCE cmake ignores these.
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_C_FLAGS} ${TARGET_C_FLAGS}" CACHE STRING "" FORCE)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_CXX_FLAGS} ${TARGET_C_FLAGS} ${CXX_INCLUDES} -I${ANDROID_NDK_PATH}/sources/android/support/include" CACHE STRING "" FORCE)
-set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-shared,-Bsymbolic -Wl,--no-undefined ${COMMON_LINKER_FLAGS} ${TARGET_LINKER_FLAGS}" CACHE STRING "" FORCE)
-set(CMAKE_EXE_LINKER_FLAGS "${COMMON_LINKER_FLAGS} ${TARGET_LINKER_FLAGS}" CACHE STRING "" FORCE)