install_prereqs.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. }
  32. # Default values, if not supplied on the command line or environment
  33. platform="iOS"
  34. method="xcodebuild"
  35. if [[ $# -eq 0 ]]; then
  36. # Take arguments from the environment
  37. project=$PROJECT
  38. platform=${PLATFORM:-${platform}}
  39. method=${METHOD:-${method}}
  40. else
  41. project="$1"
  42. if [[ $# -gt 1 ]]; then
  43. platform="$2"
  44. fi
  45. if [[ $# -gt 2 ]]; then
  46. method="$3"
  47. fi
  48. fi
  49. echo "Installing prerequisites for $project for $platform using $method"
  50. if [[ "$method" != "cmake" ]]; then
  51. scripts/setup_bundler.sh
  52. fi
  53. case "$project-$platform-$method" in
  54. FirebasePod-iOS-*)
  55. install_xcpretty
  56. bundle exec pod install --project-directory=CoreOnly/Tests/FirebasePodTest --repo-update
  57. ;;
  58. Auth-*)
  59. # Install the workspace for integration testing.
  60. install_xcpretty
  61. bundle exec pod install --project-directory=FirebaseAuth/Tests/SampleSwift --repo-update
  62. ;;
  63. Crashlytics-*)
  64. ;;
  65. CombineSwift-*)
  66. ;;
  67. Database-*)
  68. ;;
  69. Functions-*)
  70. # Start server for Functions integration tests.
  71. ./FirebaseFunctions/Backend/start.sh synchronous
  72. ;;
  73. Storage-*)
  74. ;;
  75. InAppMessaging-*-xcodebuild)
  76. install_xcpretty
  77. bundle exec pod install --project-directory=FirebaseInAppMessaging/Tests/Integration/DefaultUITestApp --no-repo-update
  78. ;;
  79. Firestore-*-xcodebuild | Firestore-*-fuzz)
  80. install_xcpretty
  81. # The Firestore Podfile is multi-platform by default, but this doesn't work
  82. # with command-line builds using xcodebuild. The PLATFORM environment
  83. # variable forces the project to be set for just that single platform.
  84. export PLATFORM="$platform"
  85. bundle exec pod install --project-directory=Firestore/Example --repo-update
  86. ;;
  87. Firestore-iOS-cmake | Firestore-tvOS-cmake | Firestore-macOS-cmake)
  88. brew outdated cmake || brew upgrade cmake
  89. brew outdated go || brew upgrade go # Somehow the build for Abseil requires this.
  90. brew install ccache
  91. brew install ninja
  92. # Install python packages required to generate proto sources
  93. pip install six
  94. ;;
  95. Firestore-Linux-cmake)
  96. apt_install ccache ccache
  97. apt_install cmake cmake
  98. apt_install go golang-go
  99. apt_install ninja ninja-build
  100. # Install python packages required to generate proto sources
  101. pip install six
  102. ;;
  103. SymbolCollision-*-*)
  104. install_xcpretty
  105. bundle exec pod install --project-directory=SymbolCollisionTest --repo-update
  106. ;;
  107. MessagingSample-*)
  108. install_xcpretty
  109. bundle exec pod install --project-directory=FirebaseMessaging/Apps/Sample --repo-update
  110. ;;
  111. SwiftUISample-*)
  112. install_xcpretty
  113. bundle exec pod install --project-directory=FirebaseMessaging/Apps/SwiftUISample --repo-update
  114. ;;
  115. MessagingSampleStandaloneWatchApp-*)
  116. install_xcpretty
  117. bundle exec pod install --project-directory=FirebaseMessaging/Apps/SampleStandaloneWatchApp --repo-update
  118. ;;
  119. MLModelDownloaderSample-*)
  120. install_xcpretty
  121. bundle exec pod install --project-directory=FirebaseMLModelDownloader/Apps/Sample --repo-update
  122. ;;
  123. RemoteConfigSample-*)
  124. install_xcpretty
  125. bundle exec pod install --project-directory=FirebaseRemoteConfig/Tests/Sample --repo-update
  126. ;;
  127. WatchOSSample-*)
  128. install_xcpretty
  129. bundle exec pod install --project-directory=Example/watchOSSample --repo-update
  130. ;;
  131. GoogleDataTransport-watchOS-xcodebuild)
  132. install_xcpretty
  133. bundle exec pod install --project-directory=GoogleDataTransport/GDTWatchOSTestApp/ --repo-update
  134. bundle exec pod install --project-directory=GoogleDataTransport/GDTCCTWatchOSTestApp/
  135. ;;
  136. ClientApp-iOS-xcodebuild)
  137. install_xcpretty
  138. bundle exec pod install --project-directory=IntegrationTesting/ClientApp/ --repo-update
  139. ;;
  140. *-pod-lib-lint)
  141. ;;
  142. *)
  143. echo "Unknown project-platform-method combo" 1>&2
  144. echo " PROJECT=$project" 1>&2
  145. echo " PLATFORM=$platform" 1>&2
  146. echo " METHOD=$method" 1>&2
  147. exit 1
  148. ;;
  149. esac