vendor-grpc.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh
  2. # Copyright 2019, gRPC Authors All rights reserved.
  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. # This script vendors the gRPC Core library into the
  16. # CgRPC module in a form suitable for building with
  17. # the Swift Package Manager.
  18. #
  19. # For usage, see `vendor-all.sh`.
  20. source ./tmp/grpc/swift-vendoring.sh
  21. TMP_DIR=./tmp
  22. DSTROOT=../Sources
  23. DSTASSETS=../Assets
  24. #
  25. # Remove previously-vendored code.
  26. #
  27. echo "REMOVING any previously-vendored gRPC code"
  28. rm -rf $DSTROOT/CgRPC/src
  29. rm -rf $DSTROOT/CgRPC/grpc
  30. rm -rf $DSTROOT/CgRPC/third_party
  31. rm -rf $DSTROOT/CgRPC/include/grpc
  32. #
  33. # Copy grpc headers and source files
  34. #
  35. echo "COPYING public gRPC headers"
  36. for src in "${public_headers[@]}"
  37. do
  38. dest="$DSTROOT/CgRPC/$src"
  39. dest_dir=$(dirname $dest)
  40. mkdir -pv $dest_dir
  41. cp $TMP_DIR/grpc/$src $dest
  42. done
  43. echo "COPYING private gRPC headers"
  44. for src in "${private_headers[@]}"
  45. do
  46. dest="$DSTROOT/CgRPC/$src"
  47. dest_dir=$(dirname $dest)
  48. mkdir -pv $dest_dir
  49. cp $TMP_DIR/grpc/$src $dest
  50. done
  51. echo "COPYING gRPC source files"
  52. for src in "${source_files[@]}"
  53. do
  54. dest="$DSTROOT/CgRPC/$src"
  55. dest_dir=$(dirname $dest)
  56. mkdir -pv $dest_dir
  57. cp $TMP_DIR/grpc/$src $dest
  58. done
  59. echo "ADDING additional compiler flags to nanopb/pb.h"
  60. perl -pi -e 's/\/\* #define PB_FIELD_16BIT 1 \*\//#define PB_FIELD_16BIT 1/' $DSTROOT/CgRPC/third_party/nanopb/pb.h
  61. echo "MOVING nanopb headers to CgRPC/include"
  62. mv $DSTROOT/CgRPC/third_party/nanopb/*.h $DSTROOT/CgRPC/include/
  63. echo "ADDING additional compiler flags to tsi/ssl_transport_security.cc"
  64. perl -pi -e 's/#define TSI_OPENSSL_ALPN_SUPPORT 1/#define TSI_OPENSSL_ALPN_SUPPORT 0/' $DSTROOT/CgRPC/src/core/tsi/ssl_transport_security.cc
  65. echo "DISABLING ARES"
  66. perl -pi -e 's/#define GRPC_ARES 1/#define GRPC_ARES 0/' $DSTROOT/CgRPC/include/grpc/impl/codegen/port_platform.h
  67. echo "COPYING roots.pem"
  68. echo "Please run 'swift run RootsEncoder > Sources/SwiftGRPC/Core/Roots.swift' to import the updated certificates."
  69. cp $TMP_DIR/grpc/etc/roots.pem $DSTASSETS/roots.pem