generate_project.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. # Copyright 2020 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. #
  16. # From https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
  17. # USAGE: generate_project.sh
  18. helpFunction()
  19. {
  20. echo ""
  21. echo "Usage: $0 -e (prod/autopush*) -p (platform)"
  22. echo -e "\tEvent upload environment - prod (or) autopush. Default: autopush"
  23. echo -c "\tRecreate the Xcode project from scratch. Default: Reuse same XCode project"
  24. exit 1 # Exit script after printing help
  25. }
  26. while getopts "e:p:c" opt
  27. do
  28. case "$opt" in
  29. e ) env="$OPTARG" ;;
  30. c ) clean="clean" ;;
  31. p ) platform="$OPTARG" ;;
  32. ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent
  33. esac
  34. done
  35. if [ -z "$env" ] || [ "prod" != "$env" ]
  36. then
  37. env="autopush"
  38. fi
  39. if [ -z "$platform" ]
  40. then
  41. platform="ios"
  42. fi
  43. readonly DIR="$(git rev-parse --show-toplevel)"
  44. # Enable Unswizzling in the development time (This is for unit test purposes).
  45. export FPR_UNSWIZZLE_AVAILABLE="1"
  46. # Enable AUTOPUSH to enable test App sending data to Autopush.
  47. # To enable sending data to Prod, remove the following line and regenerate the project.
  48. if [ "autopush" == "$env" ]
  49. then
  50. export FPR_AUTOPUSH_ENV="1"
  51. else
  52. export FPR_AUTOPUSH_ENV="0"
  53. fi
  54. echo "\nGenerating Fireperf Xcode project for $env environment..."
  55. if [ -z "$clean" ]
  56. then
  57. pod gen "$DIR/FirebasePerformance.podspec" --local-sources="$DIR/" --auto-open --gen-directory="$DIR/gen" --platforms="$platform"
  58. else
  59. echo "\nCreating a fresh Fireperf XCode project."
  60. rm -f "$DIR/FirebasePerformance/ProtoSupport/*.[hm]"
  61. protoc --proto_path="$DIR/FirebasePerformance/ProtoSupport/" --objc_out="$DIR/FirebasePerformance/ProtoSupport/" "$DIR/FirebasePerformance/ProtoSupport/perf_metric.proto"
  62. pod gen "$DIR/FirebasePerformance.podspec" --local-sources="$DIR/" --auto-open --gen-directory="$DIR/gen" --platforms="$platform" --clean
  63. fi