grpc_android.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env bash
  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. set -ex
  16. # Accept the Android SDK licences.
  17. yes | /opt/android-sdk/current/tools/bin/sdkmanager --licenses
  18. # change to grpc repo root
  19. cd $(dirname $0)/../../..
  20. REPO_ROOT="$(pwd)"
  21. git submodule update --init
  22. # Build protoc and grpc_cpp_plugin. Codegen is not cross-compiled to Android
  23. mkdir -p cmake/build
  24. pushd cmake/build
  25. cmake -DgRPC_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ../..
  26. make protoc grpc_cpp_plugin -j2
  27. popd
  28. PROTOC=${REPO_ROOT}/cmake/build/third_party/protobuf/protoc
  29. PLUGIN=${REPO_ROOT}/cmake/build/grpc_cpp_plugin
  30. # Build and run interop instrumentation tests on Firebase Test Lab
  31. cd "${REPO_ROOT}/src/android/test/interop/"
  32. ./gradlew assembleDebug \
  33. "-Pprotoc=${PROTOC}" \
  34. "-Pgrpc_cpp_plugin=${PLUGIN}"
  35. ./gradlew assembleDebugAndroidTest \
  36. "-Pprotoc=${PROTOC}" \
  37. "-Pgrpc_cpp_plugin=${PLUGIN}"
  38. gcloud firebase test android run \
  39. --type instrumentation \
  40. --app app/build/outputs/apk/debug/app-debug.apk \
  41. --test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
  42. --device model=Nexus6P,version=27,locale=en,orientation=portrait \
  43. --device model=Nexus6P,version=26,locale=en,orientation=portrait \
  44. --device model=Nexus6P,version=25,locale=en,orientation=portrait \
  45. --device model=Nexus6P,version=24,locale=en,orientation=portrait \
  46. --device model=Nexus6P,version=23,locale=en,orientation=portrait \
  47. --device model=Nexus6,version=22,locale=en,orientation=portrait \
  48. --device model=Nexus6,version=21,locale=en,orientation=portrait \
  49. --device model=walleye,version=28,locale=en,orientation=portrait
  50. # Build hello world example
  51. cd "${REPO_ROOT}/examples/android/helloworld"
  52. ./gradlew build \
  53. "-Pprotoc=${PROTOC}" \
  54. "-Pgrpc_cpp_plugin=${PLUGIN}"