vendor-grpc.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. source third_party/grpc/swift-vendoring.sh
  22. rm -rf Sources/CgRPC/src
  23. rm -rf Sources/CgRPC/grpc
  24. rm -rf Sources/CgRPC/third_party
  25. rm Sources/CgRPC/include/grpc
  26. for src in "${public_headers[@]}"
  27. do
  28. dest="Sources/CgRPC/$src"
  29. dest_dir=$(dirname $dest)
  30. mkdir -pv $dest_dir
  31. cp third_party/grpc/$src $dest
  32. done
  33. mv Sources/CgRPC/include/grpc Sources/CgRPC/grpc
  34. for src in "${source_files[@]}"
  35. do
  36. dest="Sources/CgRPC/$src"
  37. dest_dir=$(dirname $dest)
  38. mkdir -pv $dest_dir
  39. cp third_party/grpc/$src $dest
  40. done
  41. for src in "${private_headers[@]}"
  42. do
  43. dest="Sources/CgRPC/$src"
  44. dest_dir=$(dirname $dest)
  45. mkdir -pv $dest_dir
  46. cp third_party/grpc/$src $dest
  47. done
  48. echo "TODO:"
  49. echo "link the grpc headers"
  50. cd Sources/CgRPC/include; ln -s ../grpc; cd ../../..
  51. echo "get the nanopb headers"
  52. cp third_party/grpc/third_party/nanopb/*.h Sources/CgRPC/third_party/nanopb/
  53. echo "#define GRPC_ARES 0 in grpc/impl/codegen/port_platform.h"
  54. perl -pi -e 's/#define GRPC_ARES 1/#define GRPC_ARES 0/' Sources/CgRPC/grpc/impl/codegen/port_platform.h
  55. echo "ok"