generate_boringssl_prefix_header.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. # Copyright 2018 gRPC authors.
  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. # Generate the list of boringssl symbols that need to be renamed based on the
  16. # current boringssl submodule. The script should be run after a boringssl
  17. # upgrade in third_party/boringssl-with-bazel. Note that after the script is
  18. # run, you will typically need to manually upgrade the BoringSSL-GRPC podspec
  19. # (templates/src/objective-c/BoringSSL-GRPC.podspec.template) version and the
  20. # corresponding version number in gRPC-Core podspec
  21. # (templates/gRPC-Core.podspec.template).
  22. set -ev
  23. BORINGSSL_ROOT=third_party/boringssl-with-bazel/src
  24. cd "$(dirname $0)"
  25. cd ../../$BORINGSSL_ROOT
  26. BORINGSSL_COMMIT=$(git rev-parse HEAD)
  27. BORINGSSL_PREFIX_HEADERS_DIR=src/boringssl
  28. rm -rf build
  29. mkdir -p build
  30. cd build
  31. cmake ..
  32. make -j
  33. [ -f ssl/libssl.a ] || { echo "Failed to build libssl.a" ; exit 1 ; }
  34. [ -f crypto/libcrypto.a ] || { echo "Failed to build libcrypto.a" ; exit 1 ; }
  35. # Generates boringssl_prefix_symbols.h. The prefix header is generated by
  36. # BoringSSL's build system as instructed by BoringSSL build guide (see
  37. # https://github.com/google/boringssl/blob/367d64f84c3c1d01381c18c5a239b85eef47633c/BUILDING.md#building-with-prefixed-symbols).
  38. go run ../util/read_symbols.go ssl/libssl.a > ./symbols.txt
  39. go run ../util/read_symbols.go crypto/libcrypto.a >> ./symbols.txt
  40. cmake .. -DBORINGSSL_PREFIX=GRPC -DBORINGSSL_PREFIX_SYMBOLS=symbols.txt
  41. make boringssl_prefix_symbols
  42. [ -f symbol_prefix_include/boringssl_prefix_symbols.h ] || { echo "Failed to build boringssl_prefix_symbols.sh" ; exit 1 ; }
  43. cd ../../../..
  44. mkdir -p $BORINGSSL_PREFIX_HEADERS_DIR
  45. echo "// generated by generate_boringssl_prefix_header.sh on BoringSSL commit: $BORINGSSL_COMMIT" > $BORINGSSL_PREFIX_HEADERS_DIR/boringssl_prefix_symbols.h
  46. echo "" >> $BORINGSSL_PREFIX_HEADERS_DIR/boringssl_prefix_symbols.h
  47. cat "$BORINGSSL_ROOT/build/symbol_prefix_include/boringssl_prefix_symbols.h" >> $BORINGSSL_PREFIX_HEADERS_DIR/boringssl_prefix_symbols.h
  48. # Regenerated the project
  49. tools/buildgen/generate_projects.sh
  50. exit 0