android: update toolchain for docker images

This commit is contained in:
Sebastian Krzyszkowiak 2019-01-24 04:11:13 +01:00
parent cb080f027b
commit a411819d5a
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
2 changed files with 28 additions and 57 deletions

View file

@ -10,8 +10,8 @@ buildscript {
allprojects {
repositories {
flatDir { dirs 'libs' }
google()
jcenter()
flatDir { dirs 'libs' }
}
}

View file

@ -1,4 +1,3 @@
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
@ -13,20 +12,20 @@ if(NOT EXISTS "${ANDROID_ALLEGRO_ROOT}")
message( FATAL_ERROR "Invalid ANDROID_ALLEGRO_ROOT! Point it to the build directory of Allegro 5 (>=5.2.2) for Android.")
endif()
set(ANDROID_NDK_TOOLCHAIN_ROOT "$ENV{ANDROID_NDK_TOOLCHAIN_ROOT}" CACHE PATH "Path to the Android NDK Standalone Toolchain" )
set(ANDROID_TOOLCHAIN "$ENV{ANDROID_TOOLCHAIN}" CACHE PATH "Path to the Android NDK Standalone Toolchain" )
message( STATUS "Selected Android toolchain: ${ANDROID_NDK_TOOLCHAIN_ROOT}" )
if(NOT EXISTS ${ANDROID_NDK_TOOLCHAIN_ROOT})
set(ANDROID_NDK_TOOLCHAIN_ROOT "/opt/android-toolchain" CACHE PATH "Path to the Android NDK Standalone Toolchain" )
message( STATUS "Using default path for toolchain ${ANDROID_NDK_TOOLCHAIN_ROOT}")
message( STATUS "If you prefer to use a different location, please set the ANDROID_NDK_TOOLCHAIN_ROOT cmake variable.")
message( STATUS "Selected Android toolchain: ${ANDROID_TOOLCHAIN}" )
if(NOT EXISTS ${ANDROID_TOOLCHAIN})
set(ANDROID_TOOLCHAIN "/opt/android-toolchain" CACHE PATH "Path to the Android NDK Standalone Toolchain" )
message( STATUS "Using default path for toolchain ${ANDROID_TOOLCHAIN}")
message( STATUS "If you prefer to use a different location, please set the ANDROID_TOOLCHAIN cmake variable.")
endif()
if(NOT EXISTS ${ANDROID_NDK_TOOLCHAIN_ROOT})
if(NOT EXISTS ${ANDROID_TOOLCHAIN})
message(FATAL_ERROR
"${ANDROID_NDK_TOOLCHAIN_ROOT} does not exist!
"${ANDROID_TOOLCHAIN} does not exist!
You should either set an environment variable:
export ANDROID_NDK_TOOLCHAIN_ROOT=~/my-toolchain
export ANDROID_TOOLCHAIN=~/my-toolchain
or put the toolchain in the default path:
sudo ln -s ~/android-toolchain /opt/android-toolchain
")
@ -73,24 +72,24 @@ endif()
# specify the cross compiler
SET(CMAKE_C_COMPILER
${ANDROID_NDK_TOOLCHAIN_ROOT}/bin/${ANDROID_ARCH}-clang${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "C compiler" FORCE)
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-clang${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "C compiler" FORCE)
SET(CMAKE_CXX_COMPILER
${ANDROID_NDK_TOOLCHAIN_ROOT}/bin/${ANDROID_ARCH}-clang++${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "C++ compiler" FORCE)
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-clang++${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "C++ compiler" FORCE)
#there may be a way to make cmake deduce these TODO deduce the rest of the tools
set(CMAKE_AR
${ANDROID_NDK_TOOLCHAIN_ROOT}/bin/${ANDROID_ARCH}-ar${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "archive" FORCE)
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-ar${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "archive" FORCE)
set(CMAKE_LINKER
${ANDROID_NDK_TOOLCHAIN_ROOT}/bin/${ANDROID_ARCH}-ld${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "linker" FORCE)
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-ld${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "linker" FORCE)
set(CMAKE_NM
${ANDROID_NDK_TOOLCHAIN_ROOT}/bin/${ANDROID_ARCH}-nm${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "nm" FORCE)
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-nm${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "nm" FORCE)
set(CMAKE_OBJCOPY
${ANDROID_NDK_TOOLCHAIN_ROOT}/bin/${ANDROID_ARCH}-objcopy${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "objcopy" FORCE)
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-objcopy${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "objcopy" FORCE)
set(CMAKE_OBJDUMP
${ANDROID_NDK_TOOLCHAIN_ROOT}/bin/${ANDROID_ARCH}-objdump${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "objdump" FORCE)
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-objdump${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "objdump" FORCE)
set(CMAKE_STRIP
${ANDROID_NDK_TOOLCHAIN_ROOT}/bin/${ANDROID_ARCH}-strip${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "strip" FORCE)
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-strip${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "strip" FORCE)
set(CMAKE_RANLIB
${ANDROID_NDK_TOOLCHAIN_ROOT}/bin/${ANDROID_ARCH}-ranlib${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "ranlib" FORCE)
${ANDROID_TOOLCHAIN}/bin/${ANDROID_ARCH}-ranlib${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "ranlib" FORCE)
set_property(CACHE ARM_TARGETS PROPERTY STRINGS ${PossibleArmTargets} )
@ -101,56 +100,28 @@ set(LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR}/android/app CACHE PATH
#set these flags for client use
set(LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ARM_TARGETS}
CACHE PATH "path for android libs" FORCE)
set(CMAKE_INSTALL_PREFIX ${ANDROID_NDK_TOOLCHAIN_ROOT}/user/${ARM_TARGETS}
set(CMAKE_INSTALL_PREFIX ${ANDROID_TOOLCHAIN}/user/${ARM_TARGETS}
CACHE STRING "path for installing" FORCE)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH ${ANDROID_NDK_TOOLCHAIN_ROOT}/bin ${ANDROID_NDK_TOOLCHAIN_ROOT}/arm-linux-androideabi ${ANDROID_NDK_TOOLCHAIN_ROOT}/sysroot ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_PREFIX}/share)
SET(CMAKE_FIND_ROOT_PATH ${ANDROID_TOOLCHAIN}/bin ${ANDROID_TOOLCHAIN}/arm-linux-androideabi ${ANDROID_TOOLCHAIN}/sysroot ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_PREFIX}/share)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
# only search for libraries and includes in the ndk toolchain
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_CXX_FLAGS "-DGL_GLEXT_PROTOTYPES -fPIC -DANDROID")
SET(CMAKE_C_FLAGS "-DGL_GLEXT_PROTOTYPES -fPIC -DANDROID")
if (ARMEABI)
#Setup arm specific stuff
#It is recommended to use the -mthumb compiler flag to force the generation
#of 16-bit Thumb-1 instructions (the default being 32-bit ARM ones).
SET(CMAKE_CXX_FLAGS "-DGL_GLEXT_PROTOTYPES -fPIC -DANDROID -mthumb")
SET(CMAKE_C_FLAGS "-DGL_GLEXT_PROTOTYPES -fPIC -DANDROID -mthumb")
#these are required flags for android armv7-a
if(WANT_ANDROID_LEGACY)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv6")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv6")
SET(ALLEGRO_CFG_ANDROID_LEGACY 1)
else(WANT_ANDROID_LEGACY)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mfloat-abi=softfp")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfloat-abi=softfp")
if(NEON)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon")
endif()
endif(WANT_ANDROID_LEGACY)
#-Wl,-L${LIBCPP_LINK_DIR},-lstdc++,-lsupc++
#-L${LIBCPP_LINK_DIR} -lstdc++ -lsupc++
#Also, this is *required* to use the following linker flags that routes around
#a CPU bug in some Cortex-A8 implementations:
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fix-cortex-a8 -L${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "linker flags" FORCE)
SET(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fix-cortex-a8 -L${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "linker flags" FORCE)
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags")
#set these global flags for cmake client scripts to change behavior
set(ANDROID True)
set(BUILD_ANDROID True)
#make use of ANDROID_CFLAGS, ANDROID_LDFLAGS and ANDROID_CXXFLAGS
set(CMAKE_C_FLAGS "$ENV{ANDROID_CFLAGS} $ENV{CFLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "$ENV{ANDROID_CXXFLAGS} $ENV{CXXFLAGS}" CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "$ENV{ANDROID_LDFLAGS} $ENV{LDFLAGS}" CACHE STRING "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "$ENV{ANDROID_LDFLAGS} $ENV{LDFLAGS}" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-pie $ENV{ANDROID_LDFLAGS} $ENV{LDFLAGS}" CACHE STRING "" FORCE)
# Do a no-op access on the CMAKE_TOOLCHAIN_FILE variable so that CMake will not issue a warning on it being unused.
if (CMAKE_TOOLCHAIN_FILE)
endif()