• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# Copyright 2018 gRPC authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# Helper script to crosscompile grpc_csharp_ext native extension for Android.
17
18set -ex
19
20cd "$(dirname "$0")/../../../cmake"
21
22mkdir -p build
23cd build
24
25# set to the location where Android SDK is installed
26# e.g. ANDROID_SDK_PATH="$HOME/Android/Sdk"
27
28# set to location where Android NDK is installed, usually a subfolder of Android SDK
29# to install the Android NKD, use the "sdkmanager" tool
30# e.g. ANDROID_NDK_PATH=${ANDROID_SDK_PATH}/ndk-bundle
31
32# set to location of the cmake executable from the Android SDK
33# to install cmake, use the "sdkmanager" tool
34# e.g. ANDROID_SDK_CMAKE=${ANDROID_SDK_PATH}/cmake/3.6.4111459/bin/cmake
35
36# ANDROID_ABI in ('arm64-v8a', 'armeabi-v7a')
37# e.g. ANDROID_ABI=armeabi-v7a
38
39# android-19 corresponds to Kitkat 4.4
40${ANDROID_SDK_CMAKE} ../.. \
41  -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake" \
42  -DCMAKE_ANDROID_NDK="${ANDROID_NDK_PATH}" \
43  -DCMAKE_ANDROID_STL_TYPE=c++_static \
44  -DRUN_HAVE_POSIX_REGEX=0 \
45  -DRUN_HAVE_STD_REGEX=0 \
46  -DRUN_HAVE_STEADY_CLOCK=0 \
47  -DCMAKE_BUILD_TYPE=Release \
48  -DANDROID_PLATFORM=android-19 \
49  -DANDROID_ABI="${ANDROID_ABI}" \
50  -DANDROID_NDK="${ANDROID_NDK_PATH}"
51
52make -j4 grpc_csharp_ext
53