install_prereqs.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #!/usr/bin/env bash
  2. # Copyright 2018 Google LLC
  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. # Within Travis, installs prerequisites for a build.
  16. # Examines the following configured environment variables that should be
  17. # specified in an env: block
  18. # - PROJECT - Firebase or Firestore
  19. # - METHOD - xcodebuild or cmake; default is xcodebuild
  20. set -euo pipefail
  21. # apt_install program package
  22. #
  23. # Installs the given package if the given command is missing
  24. function apt_install() {
  25. local program="$1"
  26. local package="$2"
  27. which "$program" >& /dev/null || sudo apt-get install "$package"
  28. }
  29. function install_xcpretty() {
  30. gem install xcpretty
  31. if [[ -n "${TRAVIS:-}" ]]; then
  32. gem install xcpretty-travis-formatter
  33. fi
  34. }
  35. # Default values, if not supplied on the command line or environment
  36. platform="iOS"
  37. method="xcodebuild"
  38. if [[ $# -eq 0 ]]; then
  39. # Take arguments from the environment
  40. project=$PROJECT
  41. platform=${PLATFORM:-${platform}}
  42. method=${METHOD:-${method}}
  43. else
  44. project="$1"
  45. if [[ $# -gt 1 ]]; then
  46. platform="$2"
  47. fi
  48. if [[ $# -gt 2 ]]; then
  49. method="$3"
  50. fi
  51. fi
  52. echo "Installing prerequisites for $project for $platform using $method"
  53. if [[ "$method" != "cmake" ]]; then
  54. scripts/setup_bundler.sh
  55. fi
  56. case "$project-$platform-$method" in
  57. FirebasePod-iOS-*)
  58. install_xcpretty
  59. bundle exec pod install --project-directory=CoreOnly/Tests/FirebasePodTest --repo-update
  60. ;;
  61. Auth-*)
  62. # Install the workspace for integration testing.
  63. install_xcpretty
  64. bundle exec pod install --project-directory=FirebaseAuth/Tests/Sample --repo-update
  65. ;;
  66. Crashlytics-*)
  67. ;;
  68. Database-*)
  69. ;;
  70. Functions-*)
  71. # Start server for Functions integration tests.
  72. ./Functions/Backend/start.sh synchronous
  73. ;;
  74. Storage-*)
  75. ;;
  76. InAppMessaging-*-xcodebuild)
  77. install_xcpretty
  78. bundle exec pod install --project-directory=FirebaseInAppMessaging/Tests/Integration/DefaultUITestApp --no-repo-update
  79. ;;
  80. Firestore-*-xcodebuild | Firestore-*-fuzz)
  81. install_xcpretty
  82. # The Firestore Podfile is multi-platform by default, but this doesn't work
  83. # with command-line builds using xcodebuild. The PLATFORM environment
  84. # variable forces the project to be set for just that single platform.
  85. export PLATFORM="$platform"
  86. bundle exec pod install --project-directory=Firestore/Example --repo-update
  87. ;;
  88. Firestore-iOS-cmake | Firestore-tvOS-cmake | Firestore-macOS-cmake)
  89. brew outdated cmake || brew upgrade cmake
  90. brew outdated go || brew upgrade go # Somehow the build for Abseil requires this.
  91. brew install ccache
  92. brew install ninja
  93. # Install python packages required to generate proto sources
  94. pip install six
  95. ;;
  96. Firestore-Linux-cmake)
  97. apt_install ccache ccache
  98. apt_install cmake cmake
  99. apt_install go golang-go
  100. apt_install ninja ninja-build
  101. # Install python packages required to generate proto sources
  102. pip install six
  103. ;;
  104. SymbolCollision-*-*)
  105. install_xcpretty
  106. bundle exec pod install --project-directory=SymbolCollisionTest --repo-update
  107. ;;
  108. MessagingSample-*)
  109. install_xcpretty
  110. bundle exec pod install --project-directory=FirebaseMessaging/Apps/Sample --repo-update
  111. ;;
  112. GoogleDataTransport-watchOS-xcodebuild)
  113. install_xcpretty
  114. bundle exec pod install --project-directory=GoogleDataTransport/GDTWatchOSTestApp/ --repo-update
  115. ;;
  116. GoogleDataTransportCCTSupport-watchOS-xcodebuild)
  117. install_xcpretty
  118. bundle exec pod install --project-directory=GoogleDataTransportCCTSupport/GDTCCTWatchOSTestApp/ --repo-update
  119. ;;
  120. *-pod-lib-lint)
  121. ;;
  122. *)
  123. echo "Unknown project-platform-method combo" 1>&2
  124. echo " PROJECT=$project" 1>&2
  125. echo " PLATFORM=$platform" 1>&2
  126. echo " METHOD=$method" 1>&2
  127. exit 1
  128. ;;
  129. esac