generate_nanopb_protos.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. # Copyright 2019 Google
  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. # ./build_protos <path to nanopb>
  18. # Dependencies: git, protobuf, python-protobuf, pyinstaller
  19. readonly REPO_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="$(mktemp -d)"
  23. readonly PROTO_DIR="${REPO_DIR}/FirebaseInAppMessaging/ProtoSupport/Protos"
  24. readonly PROTOGEN_DIR="${REPO_DIR}/FirebaseInAppMessaging/Analytics/Protogen"
  25. rm -rf "${NANOPB_TEMPDIR}"
  26. echo "Downloading nanopb..."
  27. git clone --branch "${NANOPB_VERSION}" https://github.com/nanopb/nanopb.git "${NANOPB_TEMPDIR}"
  28. echo "Building nanopb..."
  29. pushd "${NANOPB_TEMPDIR}"
  30. ./tools/make_mac_package.sh
  31. GIT_DESCRIPTION=`git describe --always`-macosx-x86
  32. NANOPB_BIN_DIR="dist/${GIT_DESCRIPTION}"
  33. popd
  34. echo "Removing existing generated protos..."
  35. rm -rf "${PROTOGEN_DIR}/*"
  36. echo "Generating nanopb protos..."
  37. python "${REPO_DIR}/FirebaseInAppMessaging/ProtoSupport/nanopb_build_protos.py" \
  38. --nanopb \
  39. --protos_dir="${PROTO_DIR}" \
  40. --pythonpath="${NANOPB_TEMPDIR}/${NANOPB_BIN_DIR}/generator" \
  41. --output_dir="${PROTOGEN_DIR}" \
  42. --include="${PROTO_DIR}"
  43. rm -rf "${NANOPB_TEMPDIR}"