vendor-grpc.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. #
  3. # Copyright 2016, gRPC Authors All rights reserved.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. # This script vendors the gRPC Core library into the
  18. # CgRPC module in a form suitable for building with
  19. # the Swift Package Manager.
  20. #
  21. #
  22. # Read the list of files to vendor from the gRPC project.
  23. #
  24. # The file that is included here is a generated file.
  25. # To generate it, copy swift-vendoring.sh.template from
  26. # the grpc-swift directory to grpc/templates and then
  27. # run tools/buildgen/generate_projects.sh in the grpc
  28. # directory.
  29. #
  30. source third_party/grpc/swift-vendoring.sh
  31. #
  32. # Remove previously-vendored code.
  33. #
  34. echo "REMOVING any previously-vendored gRPC code"
  35. rm -rf Sources/CgRPC/src
  36. rm -rf Sources/CgRPC/grpc
  37. rm -rf Sources/CgRPC/third_party
  38. rm -rf Sources/CgRPC/include/grpc
  39. #
  40. # Copy grpc headers and source files
  41. #
  42. echo "COPYING public gRPC headers"
  43. for src in "${public_headers[@]}"
  44. do
  45. dest="Sources/CgRPC/$src"
  46. dest_dir=$(dirname $dest)
  47. mkdir -pv $dest_dir
  48. cp third_party/grpc/$src $dest
  49. done
  50. echo "COPYING private grpc headers"
  51. for src in "${private_headers[@]}"
  52. do
  53. dest="Sources/CgRPC/$src"
  54. dest_dir=$(dirname $dest)
  55. mkdir -pv $dest_dir
  56. cp third_party/grpc/$src $dest
  57. done
  58. echo "COPYING grpc source files"
  59. for src in "${source_files[@]}"
  60. do
  61. dest="Sources/CgRPC/$src"
  62. dest_dir=$(dirname $dest)
  63. mkdir -pv $dest_dir
  64. cp third_party/grpc/$src $dest
  65. done
  66. echo "COPYING additional nanopb headers"
  67. cp third_party/grpc/third_party/nanopb/*.h Sources/CgRPC/third_party/nanopb/
  68. echo "DISABLING ARES"
  69. perl -pi -e 's/#define GRPC_ARES 1/#define GRPC_ARES 0/' Sources/CgRPC/include/grpc/impl/codegen/port_platform.h
  70. echo "COPYING roots.pem"
  71. cp third_party/grpc/etc/roots.pem Assets/roots.pem