vendor-boringssl.sh 2.1 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 creates a vendored copy of BoringSSL that is
  18. # suitable for building with the Swift Package Manager.
  19. #
  20. # Usage:
  21. # 1. Clone github.com/grpc/grpc into the third_party directory.
  22. # 2. Get gRPC submodules by running "git submodule update --init"
  23. # inside the gRPC directory.
  24. # 3. Run this script in the grpc-swift directory. It will place
  25. # a local copy of the BoringSSL sources in Sources/BoringSSL.
  26. # Any prior contents of Sources/BoringSSL will be deleted.
  27. #
  28. SRCROOT=third_party/grpc/third_party/boringssl
  29. DSTROOT=Sources/BoringSSL
  30. echo "REMOVING any previously-vendored BoringSSL code"
  31. rm -rf $DSTROOT/include
  32. rm -rf $DSTROOT/ssl
  33. rm -rf $DSTROOT/crypto
  34. rm -rf $DSTROOT/err_data.c
  35. PATTERNS=(
  36. 'include/openssl/*.h'
  37. 'ssl/*.h'
  38. 'ssl/*.c'
  39. 'crypto/*.h'
  40. 'crypto/*.c'
  41. 'crypto/**/*.h'
  42. 'crypto/**/*.c'
  43. )
  44. EXCLUDES=(
  45. '*_test.*'
  46. 'test_*.*'
  47. 'test'
  48. 'example_*.c'
  49. )
  50. for pattern in "${PATTERNS[@]}"
  51. do
  52. echo "COPYING $pattern"
  53. for i in $SRCROOT/$pattern; do
  54. path=${i#$SRCROOT}
  55. dest="$DSTROOT$path"
  56. dest_dir=$(dirname $dest)
  57. mkdir -p $dest_dir
  58. cp $SRCROOT/$path $dest
  59. done
  60. done
  61. echo "COPYING err_data.c from gRPC project"
  62. cp ./third_party/grpc/src/boringssl/err_data.c $DSTROOT
  63. for exclude in "${EXCLUDES[@]}"
  64. do
  65. echo "EXCLUDING $exclude"
  66. find $DSTROOT -d -name "$exclude" -exec rm -rf {} \;
  67. done
  68. #
  69. # edit the BoringSSL headers to disable dependency on assembly language helpers.
  70. #
  71. perl -pi -e '$_ .= qq(\n#define OPENSSL_NO_ASM\n) if /#define OPENSSL_HEADER_BASE_H/' Sources/BoringSSL/include/openssl/base.h