[Piglit] [PATCH 3/6] cmake: Add an Android platform and toolchain

groleo at gmail.com groleo at gmail.com
Wed Oct 24 06:11:29 PDT 2012


From: Adrian Marius Negreanu <adrian.m.negreanu at intel.com>

Signed-off-by: Adrian Marius Negreanu <adrian.m.negreanu at intel.com>
---
:000000 100644 0000000... 9dd8b3c... A	cmake/Modules/Compiler/Android.cmake
:000000 100644 0000000... 2298263... A	cmake/Modules/Platform/Android.cmake
 cmake/Modules/Compiler/Android.cmake | 70 ++++++++++++++++++++++++++++++++++++
 cmake/Modules/Platform/Android.cmake | 35 ++++++++++++++++++
 2 files changed, 105 insertions(+)

diff --git a/cmake/Modules/Compiler/Android.cmake b/cmake/Modules/Compiler/Android.cmake
new file mode 100644
index 0000000..9dd8b3c
--- /dev/null
+++ b/cmake/Modules/Compiler/Android.cmake
@@ -0,0 +1,70 @@
+# Copyright 2012 Intel Corporation
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# - Redistributions of source code must retain the above copyright notice, this
+#   list of conditions and the following disclaimer.
+#
+# - Redistributions in binary form must reproduce the above copyright notice,
+#   this list of conditions and the following disclaimer in the documentation
+#   and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#
+# Set Android toolchain specifics
+
+SET(CMAKE_SYSTEM_NAME Android)
+SET(CMAKE_SYSTEM_VERSION 1)
+SET(UNIX True)
+SET(ANDROID True)
+
+IF($ENV{PLATFORM_ANDROID})
+    return()
+ENDIF()
+
+SET(ENV{PLATFORM_ANDROID} 1)
+
+# needed by get_build_var
+SET(ENV{CALLED_FROM_SETUP} true)
+SET(ENV{BUILD_SYSTEM} build/core)
+
+MACRO(get_build_var arg1 _output)
+    EXECUTE_PROCESS(COMMAND make --no-print-directory -C $ENV{ANDROID_BUILD_TOP} -f build/core/config.mk dumpvar-${arg1}
+    OUTPUT_VARIABLE ${_output}
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+ENDMACRO()
+
+get_build_var(TARGET_ARCH __TARGET_ARCH)
+get_build_var(TARGET_GLOBAL_CFLAGS  __TARGET_GLOBAL_CFLAGS)
+get_build_var(TARGET_GLOBAL_LDFLAGS __TARGET_GLOBAL_LDFLAGS)
+get_build_var(TARGET_CC   CMAKE_C_COMPILER)
+get_build_var(TARGET_CXX  CMAKE_CXX_COMPILER)
+
+SET(CMAKE_C_COMPILER   $ENV{ANDROID_BUILD_TOP}/${CMAKE_C_COMPILER} CACHE STRING "")
+SET(CMAKE_CXX_COMPILER $ENV{ANDROID_BUILD_TOP}/${CMAKE_CXX_COMPILER} CACHE STRING "")
+
+SET(__NDK_SYSROOT   $ENV{ANDROID_BUILD_TOP}/prebuilts/ndk/android-ndk-r8/platforms/android-14/arch-${__TARGET_ARCH})
+SET(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} ${__TARGET_GLOBAL_CFLAGS} -I$ENV{ANDROID_BUILD_TOP} --sysroot=${__NDK_SYSROOT} -Wno-error=return-type " CACHE STRING "c flags")
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${__TARGET_GLOBAL_CFLAGS} -I$ENV{ANDROID_BUILD_TOP} --sysroot=${__NDK_SYSROOT} -Wno-error=return-type " CACHE STRING "c flags")
+
+SET(CMAKE_LD_FLAGS  "${CMAKE_LD_FLAGS} -Wl,--allow-shlib-undefined ${__TARGET_GLOBAL_LDFLAGS} --sysroot=${__NDK_SYSROOT}" CACHE STRING "linker flags")
+SET(CMAKE_EXE_LINKER_FLAGS ${CMAKE_LD_FLAGS} CACHE STRING "executable linker flags")
+
+# search only inside sdk, not the remainder of the host filesystem
+SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
+SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/cmake/Modules/Platform/Android.cmake b/cmake/Modules/Platform/Android.cmake
new file mode 100644
index 0000000..2298263
--- /dev/null
+++ b/cmake/Modules/Platform/Android.cmake
@@ -0,0 +1,35 @@
+# Copyright 2012 Intel Corporation
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# - Redistributions of source code must retain the above copyright notice, this
+#   list of conditions and the following disclaimer.
+#
+# - Redistributions in binary form must reproduce the above copyright notice,
+#   this list of conditions and the following disclaimer in the documentation
+#   and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#
+# Set Android specific paths
+
+LIST(APPEND CMAKE_PREFIX_PATH $ENV{ANDROID_PRODUCT_OUT}/system)
+LIST(APPEND CMAKE_PREFIX_PATH $ENV{ANDROID_BUILD_TOP}/external/waffle/include/waffle)
+LIST(APPEND CMAKE_PREFIX_PATH $ENV{ANDROID_BUILD_TOP}/external/zlib)
+
+LIST(APPEND CMAKE_SYSTEM_INCLUDE_PATH
+  $ENV{ANDROID_BUILD_TOP}/external/mesa/include
+  )
-- 
1.8.0



More information about the Piglit mailing list