Debian Codegraph @

tools/distrib/generate_boringssl_prefix_header.sh

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