vendor-boringssl.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/*.cc'
  39. 'crypto/*.h'
  40. 'crypto/*.c'
  41. 'crypto/*/*.h'
  42. 'crypto/*/*.c'
  43. 'crypto/*/*/*.h'
  44. 'crypto/*/*/*.c'
  45. 'third_party/fiat/*.h'
  46. 'third_party/fiat/*.c'
  47. )
  48. EXCLUDES=(
  49. '*_test.*'
  50. 'test_*.*'
  51. 'test'
  52. 'example_*.c'
  53. )
  54. for pattern in "${PATTERNS[@]}"
  55. do
  56. for i in $SRCROOT/$pattern; do
  57. path=${i#$SRCROOT}
  58. dest="$DSTROOT$path"
  59. dest_dir=$(dirname $dest)
  60. mkdir -p $dest_dir
  61. cp $SRCROOT/$path $dest
  62. done
  63. done
  64. echo "COPYING err_data.c from gRPC project"
  65. cp ./third_party/grpc/src/boringssl/err_data.c $DSTROOT
  66. for exclude in "${EXCLUDES[@]}"
  67. do
  68. echo "EXCLUDING $exclude"
  69. find $DSTROOT -d -name "$exclude" -exec rm -rf {} \;
  70. done
  71. echo "GENERATING err_data.c"
  72. go run $SRCROOT/crypto/err/err_data_generate.go > $DSTROOT/crypto/err/err_data.c
  73. echo "DELETING crypto/fipsmodule/bcm.c"
  74. rm -f $DSTROOT/crypto/fipsmodule/bcm.c
  75. #
  76. # edit the BoringSSL headers to disable dependency on assembly language helpers.
  77. #
  78. perl -pi -e '$_ .= qq(\n#define OPENSSL_NO_ASM\n) if /#define OPENSSL_HEADER_BASE_H/' Sources/BoringSSL/include/openssl/base.h