vendor-boringssl.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 creates a vendored copy of BoringSSL that is
  16. # suitable for building with the Swift Package Manager.
  17. #
  18. # For usage, see `vendor-all.sh`.
  19. SRCROOT=./tmp/grpc/third_party/boringssl
  20. DSTROOT=../Sources/BoringSSL
  21. echo "REMOVING any previously-vendored BoringSSL code"
  22. rm -rf $DSTROOT/include
  23. rm -rf $DSTROOT/ssl
  24. rm -rf $DSTROOT/crypto
  25. rm -rf $DSTROOT/err_data.c
  26. PATTERNS=(
  27. 'include/openssl/*.h'
  28. 'ssl/*.h'
  29. 'ssl/*.cc'
  30. 'crypto/*.h'
  31. 'crypto/*.c'
  32. 'crypto/*/*.h'
  33. 'crypto/*/*.c'
  34. 'crypto/*/*/*.h'
  35. 'crypto/*/*/*.c'
  36. 'third_party/fiat/*.h'
  37. 'third_party/fiat/*.c'
  38. )
  39. EXCLUDES=(
  40. '*_test.*'
  41. 'test_*.*'
  42. 'test'
  43. 'example_*.c'
  44. )
  45. for pattern in "${PATTERNS[@]}"
  46. do
  47. for i in $SRCROOT/$pattern; do
  48. path=${i#$SRCROOT}
  49. dest="$DSTROOT$path"
  50. dest_dir=$(dirname $dest)
  51. mkdir -p $dest_dir
  52. cp $SRCROOT/$path $dest
  53. done
  54. done
  55. echo "COPYING err_data.c from gRPC project"
  56. cp ./third_party/grpc/src/boringssl/err_data.c $DSTROOT
  57. for exclude in "${EXCLUDES[@]}"
  58. do
  59. echo "EXCLUDING $exclude"
  60. find $DSTROOT -d -name "$exclude" -exec rm -rf {} \;
  61. done
  62. echo "GENERATING err_data.c"
  63. go run $SRCROOT/crypto/err/err_data_generate.go > $DSTROOT/crypto/err/err_data.c
  64. echo "DELETING crypto/fipsmodule/bcm.c"
  65. rm -f $DSTROOT/crypto/fipsmodule/bcm.c
  66. #
  67. # edit the BoringSSL headers to disable dependency on assembly language helpers.
  68. #
  69. perl -pi -e '$_ .= qq(\n#define OPENSSL_NO_ASM\n) if /#define OPENSSL_HEADER_BASE_H/' Sources/BoringSSL/include/openssl/base.h