File indexing completed on 2024-04-21 05:50:25
0001 #!/bin/sh 0002 # 0003 # SPDX-License-Identifier: BSD-2-Clause 0004 # SPDX-FileCopyrightText: 2020-2021 Johan Ouwerkerk <jm.ouwerkerk@gmail.com> 0005 # 0006 0007 set -e 0008 0009 cat << INTRO 0010 Running android-export.sh wrapper script: $0 0011 Build info 0012 0013 == target: 0014 0015 - api : @CMAKE_ANDROID_API@ 0016 - arch : @CMAKE_ANDROID_ARCH@ 0017 - abi : @CMAKE_ANDROID_ARCH_ABI@ 0018 - stl : @CMAKE_ANDROID_STL_TYPE@ 0019 0020 == build host: 0021 0022 - host: @CMAKE_HOST_SYSTEM_NAME@ 0023 - arch: @CMAKE_HOST_SYSTEM_PROCESSOR@ 0024 0025 == ndk: 0026 0027 - path : @CMAKE_ANDROID_NDK@ 0028 0029 INTRO 0030 0031 tool_prefix () 0032 { 0033 local binutils="$1" 0034 # see: https://developer.android.com/ndk/guides/other_build_systems 0035 case "@CMAKE_ANDROID_ARCH@" in 0036 arm) 0037 if [ -n "$binutils" ] 0038 then 0039 echo -n "arm-linux-androideabi" 0040 else 0041 echo -n "armv7a-linux-androideabi" 0042 fi 0043 ;; 0044 arm64) 0045 echo -n "aarch64-linux-android" 0046 ;; 0047 x86) 0048 echo -n "i686-linux-android" 0049 ;; 0050 x86-64|x86_64) # not sure which will be passed, accept both 0051 echo -n "x86_64-linux-android" 0052 ;; 0053 *) 0054 echo "Unable to continue: unknown/undefined/unsupported Android architecture: '@CMAKE_ANDROID_ARCH@'" >&2 0055 exit 254 0056 ;; 0057 esac 0058 } 0059 0060 clang_toolname_prefix () 0061 { 0062 echo -n "$(tool_prefix)@CMAKE_ANDROID_API@" 0063 } 0064 0065 toolchain_host () 0066 { 0067 echo -n "@CMAKE_HOST_SYSTEM_NAME@-@CMAKE_HOST_SYSTEM_PROCESSOR@" | tr [:upper:] [:lower:] 0068 } 0069 0070 toolchain_path () 0071 { 0072 echo -n "@CMAKE_ANDROID_NDK@/toolchains/llvm/prebuilt/$(toolchain_host)" 0073 } 0074 0075 get_stl () 0076 { 0077 case "@CMAKE_ANDROID_STL_TYPE@" in 0078 c++_shared) 0079 echo -n "libc++" 0080 ;; 0081 *) 0082 echo "Unable to continue: unknown/undefined/unsupported STL: '@CMAKE_ANDROID_STL_TYPE@'" >&2 0083 exit 254 0084 ;; 0085 esac 0086 } 0087 0088 get_cxx_flags () 0089 { 0090 case "$CXXFLAGS" in 0091 *"--stl"*) 0092 echo -n "$CXXFLAGS" 0093 ;; 0094 *) 0095 echo -n "$CXXFLAGS --stl=$(get_stl)" 0096 ;; 0097 esac 0098 } 0099 0100 0101 # see: https://developer.android.com/ndk/guides/other_build_systems 0102 BINUTILS_PREFIX="$(tool_prefix "true")" 0103 CLANG_PREFIX="$(clang_toolname_prefix)" 0104 TOOLCHAIN_BINDIR="$(toolchain_path)/bin" 0105 CXXFLAGS="$(get_cxx_flags)" 0106 0107 AR="$TOOLCHAIN_BINDIR/$BINUTILS_PREFIX-ar" 0108 AS="$TOOLCHAIN_BINDIR/$BINUTILS_PREFIX-as" 0109 CC="$TOOLCHAIN_BINDIR/$CLANG_PREFIX-clang" 0110 LD="$TOOLCHAIN_BINDIR/$BINUTILS_PREFIX-ld" 0111 CXX="$TOOLCHAIN_BINDIR/$CLANG_PREFIX-clang++" 0112 STRIP="$TOOLCHAIN_BINDIR/$BINUTILS_PREFIX-strip" 0113 RANLIB="$TOOLCHAIN_BINDIR/$BINUTILS_PREFIX-ranlib" 0114 0115 if [ ! -d "$TOOLCHAIN_BINDIR" ] 0116 then 0117 echo "Unable to continue: tools directory not found: $TOOLCHAIN_BINDIR" >&2 0118 echo "Android NDK root directory is supposed to be: @CMAKE_ANDROID_NDK@" >&2 0119 exit 1 0120 fi 0121 0122 set -x 0123 0124 export PATH="$TOOLCHAIN_BINDIR:$PATH" \ 0125 CXXFLAGS="$CXXFLAGS" \ 0126 AR="$AR" \ 0127 AS="$AS" \ 0128 CC="$CC" \ 0129 LD="$LD" \ 0130 CXX="$CXX" \ 0131 STRIP="$STRIP" \ 0132 RANLIB="$RANLIB" 0133 0134 "$@"