vendor-boringssl.sh 1.9 KB

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