generate_protos.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # Copyright 2021 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. # Example usage:
  17. # ./generate_protos.sh <path to nanopb>
  18. # Dependencies: git, protobuf, python-protobuf, pyinstaller
  19. readonly DIR="$( git rev-parse --show-toplevel )"
  20. # Current release of nanopb being used to build the CCT protos
  21. readonly NANOPB_VERSION="0.3.9.8"
  22. readonly NANOPB_TEMPDIR="${DIR}/FirebasePerformance/nanopb_temp"
  23. readonly LIBRARY_DIR="${DIR}/FirebasePerformance/Sources/"
  24. readonly PROTO_DIR="${DIR}/FirebasePerformance/ProtoSupport/Protos/"
  25. readonly PROTOGEN_DIR="${LIBRARY_DIR}/Protogen/"
  26. rm -rf "${NANOPB_TEMPDIR}"
  27. echo "Downloading nanopb..."
  28. git clone --branch "${NANOPB_VERSION}" https://github.com/nanopb/nanopb.git "${NANOPB_TEMPDIR}"
  29. echo "Building nanopb..."
  30. pushd "${NANOPB_TEMPDIR}"
  31. ./tools/make_mac_package.sh
  32. GIT_DESCRIPTION=`git describe --always`-macosx-x86
  33. NANOPB_BIN_DIR="dist/${GIT_DESCRIPTION}"
  34. popd
  35. echo "Removing existing generated proto files..."
  36. rm -rf "${PROTOGEN_DIR}/*"
  37. echo "Generating Perf_metric protos..."
  38. python "${DIR}/FirebasePerformance/ProtoSupport/proto_generator.py" \
  39. --nanopb \
  40. --protos_dir="${PROTO_DIR}" \
  41. --pythonpath="${NANOPB_TEMPDIR}/${NANOPB_BIN_DIR}/generator" \
  42. --output_dir="${PROTOGEN_DIR}" \
  43. --include="${PROTO_DIR}"
  44. rm -rf "${NANOPB_TEMPDIR}"