install_prereqs.sh 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. Crashlytics-*)
  59. ;;
  60. CombineSwift-*)
  61. ;;
  62. Database-*)
  63. ;;
  64. Functions-*)
  65. # Start server for Functions integration tests.
  66. ./FirebaseFunctions/Backend/start.sh synchronous
  67. ;;
  68. Storage-*)
  69. ;;
  70. InAppMessaging-*-xcodebuild)
  71. install_xcpretty
  72. bundle exec pod install --project-directory=FirebaseInAppMessaging/Tests/Integration/DefaultUITestApp --no-repo-update
  73. ;;
  74. Firestore-*-xcodebuild | Firestore-*-fuzz)
  75. install_xcpretty
  76. # The Firestore Podfile is multi-platform by default, but this doesn't work
  77. # with command-line builds using xcodebuild. The PLATFORM environment
  78. # variable forces the project to be set for just that single platform.
  79. export PLATFORM="$platform"
  80. bundle exec pod install --project-directory=Firestore/Example --repo-update
  81. ;;
  82. Firestore-iOS-cmake | Firestore-tvOS-cmake | Firestore-macOS-cmake)
  83. brew outdated cmake || brew upgrade cmake
  84. brew outdated go || brew upgrade go # Somehow the build for Abseil requires this.
  85. brew install ccache
  86. brew install ninja
  87. # Install python packages required to generate proto sources
  88. pip install six
  89. ;;
  90. Firestore-Linux-cmake)
  91. apt_install ccache ccache
  92. apt_install cmake cmake
  93. apt_install go golang-go
  94. apt_install ninja ninja-build
  95. # Install python packages required to generate proto sources
  96. pip install six
  97. ;;
  98. SymbolCollision-*-*)
  99. install_xcpretty
  100. bundle exec pod install --project-directory=SymbolCollisionTest --repo-update
  101. ;;
  102. MessagingSample-*)
  103. install_xcpretty
  104. bundle exec pod install --project-directory=FirebaseMessaging/Apps/Sample --repo-update
  105. ;;
  106. SwiftUISample-*)
  107. install_xcpretty
  108. bundle exec pod install --project-directory=FirebaseMessaging/Apps/SwiftUISample --repo-update
  109. ;;
  110. MessagingSampleStandaloneWatchApp-*)
  111. install_xcpretty
  112. bundle exec pod install --project-directory=FirebaseMessaging/Apps/SampleStandaloneWatchApp --repo-update
  113. ;;
  114. MLModelDownloaderSample-*)
  115. install_xcpretty
  116. bundle exec pod install --project-directory=FirebaseMLModelDownloader/Apps/Sample --repo-update
  117. ;;
  118. RemoteConfigSample-*)
  119. install_xcpretty
  120. bundle exec pod install --project-directory=FirebaseRemoteConfig/Tests/Sample --repo-update
  121. ;;
  122. WatchOSSample-*)
  123. install_xcpretty
  124. bundle exec pod install --project-directory=Example/watchOSSample --repo-update
  125. ;;
  126. GoogleDataTransport-watchOS-xcodebuild)
  127. install_xcpretty
  128. bundle exec pod install --project-directory=GoogleDataTransport/GDTWatchOSTestApp/ --repo-update
  129. bundle exec pod install --project-directory=GoogleDataTransport/GDTCCTWatchOSTestApp/
  130. ;;
  131. ClientApp-iOS-xcodebuild)
  132. install_xcpretty
  133. bundle exec pod install --project-directory=IntegrationTesting/ClientApp/ --repo-update
  134. ;;
  135. *-pod-lib-lint)
  136. ;;
  137. *)
  138. echo "Unknown project-platform-method combo" 1>&2
  139. echo " PROJECT=$project" 1>&2
  140. echo " PLATFORM=$platform" 1>&2
  141. echo " METHOD=$method" 1>&2
  142. exit 1
  143. ;;
  144. esac