mirror of https://github.com/grpc/grpc.git
Merge pull request #21194 from muxi/boringssl-prefix-header
Revamp how BoringSSL generate prefix header on ObjCpull/22737/head
commit
e3c57771c2
33 changed files with 3888 additions and 10114 deletions
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,40 +0,0 @@ |
||||
%YAML 1.2 |
||||
--- | |
||||
<%! |
||||
def expand_symbol_list(symbol_list): |
||||
return '\n'.join('#define %s GRPC_SHADOW_%s' % (symbol, symbol) for symbol in symbol_list) |
||||
%> |
||||
/* |
||||
* |
||||
* Copyright 2018 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
// This file is autogenerated from a template file. Please make |
||||
// modifications to |
||||
// `templates/src/objective-c/tsi/grpc_shadow_boringssl.h.template` |
||||
// instead. This file can be regenerated from the template by running |
||||
// `tools/buildgen/generate_projects.sh`. |
||||
|
||||
#ifndef GRPC_CORE_TSI_GRPC_SHADOW_BORINGSSL_H |
||||
#define GRPC_CORE_TSI_GRPC_SHADOW_BORINGSSL_H |
||||
|
||||
#ifdef GRPC_SHADOW_BORINGSSL_SYMBOLS |
||||
|
||||
${expand_symbol_list(settings.grpc_shadow_boringssl_symbols)} |
||||
|
||||
#endif /* GRPC_SHADOW_BORINGSSL_SYMBOLS */ |
||||
|
||||
#endif /* GRPC_CORE_TSI_GRPC_SHADOW_BORINGSSL_H */ |
@ -1,32 +0,0 @@ |
||||
# Copyright 2018 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
"""Buildgen generate grpc_shadow_boringssl headers |
||||
This script takes the list of symbols from |
||||
src/objective-c/grpc_shadow_boringssl_symbols and populate them in |
||||
settings.grpc_shadow_boringssl_symbols |
||||
""" |
||||
|
||||
|
||||
def mako_plugin(dictionary): |
||||
with open('src/objective-c/grpc_shadow_boringssl_symbol_list') as f: |
||||
symbols = f.readlines() |
||||
# Remove trailing '\n' |
||||
symbols = [s.strip() for s in symbols] |
||||
# Remove comments |
||||
symbols = [s for s in symbols if len(s) > 0 and s[0] != '#'] |
||||
# Remove the commit number |
||||
del symbols[0] |
||||
|
||||
settings = dictionary['settings'] |
||||
settings['grpc_shadow_boringssl_symbols'] = symbols |
@ -0,0 +1,27 @@ |
||||
#!/bin/bash |
||||
# Copyright 2018 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
# Check if the current BoringSSL prefix symbols is up to date |
||||
set -e |
||||
|
||||
cd "$(dirname $0)" |
||||
cd ../../third_party/boringssl-with-bazel |
||||
|
||||
BORINGSSL_COMMIT=$(git rev-parse HEAD) |
||||
PREFIX_SYMBOLS_COMMIT=$(cat ../../src/boringssl/boringssl_prefix_symbols.h | head -n1 | awk '{print $NF}') |
||||
|
||||
[ $BORINGSSL_COMMIT == $PREFIX_SYMBOLS_COMMIT ] || { echo "The BoringSSL commit does not match the commit of the prefix symbols (src/boringssl/boringssl_prefix_symbols.h). Run tools/distrib/regenerate_boringssl_prefix_symbols.sh to update the prefix symbols." ; exit 1 ; } |
||||
|
||||
exit 0 |
@ -1,32 +0,0 @@ |
||||
#!/bin/bash |
||||
# Copyright 2018 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
|
||||
# Check if the commit version of BoringSSL podspec, BoringSSL submodule, and |
||||
# the shadowed symbol list are all based on the same BoringSSL commit. |
||||
set -e |
||||
|
||||
cd $(dirname $0) |
||||
|
||||
boringssl_podspec_original="../../src/objective-c/BoringSSL-GRPC.podspec" |
||||
symbol_list="../../src/objective-c/grpc_shadow_boringssl_symbol_list" |
||||
|
||||
# Check BoringSSL version matches |
||||
ver1=$(git submodule | grep "boringssl-with-bazel " | awk '{print $1}' | head -n 1) |
||||
ver2=$(cat $boringssl_podspec_original | grep ':commit =>' | sed -E 's/.*"(.*)".*/\1/g') |
||||
ver3=$(cat $symbol_list | sed -n '2 p') |
||||
[ $ver1 == $ver2 ] && [ $ver1 == $ver3 ] || { echo "BoringSSL submodule (third_party/boringssl-with-bazel), BoringSSL podspec (src/objective-c/BoringSSL.podspec), and BoringSSL symbol list (src/objective-c/grpc_shadow_boringssl_symbol_list) commit do not match." ; echo "BoringSSL submodule: $ver1" ; echo "BoringSSL podspec: $ver2" ; echo "BoringSSL symbol list: $ver3" ; exit 1 ; } |
||||
|
||||
exit 0 |
@ -0,0 +1,60 @@ |
||||
#!/bin/bash |
||||
# Copyright 2018 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
# Generate the list of boringssl symbols that need to be renamed based on the |
||||
# current boringssl submodule. The script should be run after a boringssl |
||||
# upgrade in third_party/boringssl-with-bazel. Note that after the script is |
||||
# run, you will typically need to manually upgrade the BoringSSL-GRPC podspec |
||||
# (templates/src/objective-c/BoringSSL-GRPC.podspec.template) version and the |
||||
# corresponding version number in gRPC-Core podspec |
||||
# (templates/gRPC-Core.podspec.template). |
||||
|
||||
set -ev |
||||
|
||||
BORINGSSL_ROOT=third_party/boringssl-with-bazel/src |
||||
|
||||
cd "$(dirname $0)" |
||||
cd ../../$BORINGSSL_ROOT |
||||
|
||||
BORINGSSL_COMMIT=$(git rev-parse HEAD) |
||||
BORINGSSL_PREFIX_HEADERS_DIR=src/boringssl |
||||
|
||||
rm -rf build |
||||
mkdir -p build |
||||
cd build |
||||
cmake .. |
||||
make -j |
||||
[ -f ssl/libssl.a ] || { echo "Failed to build libssl.a" ; exit 1 ; } |
||||
[ -f crypto/libcrypto.a ] || { echo "Failed to build libcrypto.a" ; exit 1 ; } |
||||
|
||||
# Generates boringssl_prefix_symbols.h. The prefix header is generated by |
||||
# BoringSSL's build system as instructed by BoringSSL build guide (see |
||||
# https://github.com/google/boringssl/blob/367d64f84c3c1d01381c18c5a239b85eef47633c/BUILDING.md#building-with-prefixed-symbols). |
||||
go run ../util/read_symbols.go ssl/libssl.a > ./symbols.txt |
||||
go run ../util/read_symbols.go crypto/libcrypto.a >> ./symbols.txt |
||||
cmake .. -DBORINGSSL_PREFIX=GRPC -DBORINGSSL_PREFIX_SYMBOLS=symbols.txt |
||||
make boringssl_prefix_symbols |
||||
[ -f symbol_prefix_include/boringssl_prefix_symbols.h ] || { echo "Failed to build boringssl_prefix_symbols.sh" ; exit 1 ; } |
||||
|
||||
cd ../../../.. |
||||
mkdir -p $BORINGSSL_PREFIX_HEADERS_DIR |
||||
echo "// generated by generate_boringssl_prefix_header.sh on BoringSSL commit: $BORINGSSL_COMMIT" > $BORINGSSL_PREFIX_HEADERS_DIR/boringssl_prefix_symbols.h |
||||
echo "" >> $BORINGSSL_PREFIX_HEADERS_DIR/boringssl_prefix_symbols.h |
||||
cat "$BORINGSSL_ROOT/build/symbol_prefix_include/boringssl_prefix_symbols.h" >> $BORINGSSL_PREFIX_HEADERS_DIR/boringssl_prefix_symbols.h |
||||
|
||||
# Regenerated the project |
||||
tools/buildgen/generate_projects.sh |
||||
|
||||
exit 0 |
@ -1,63 +0,0 @@ |
||||
#!/bin/bash |
||||
# Copyright 2018 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
# Generate the list of boringssl symbols that need to be shadowed based on the |
||||
# current boringssl submodule. Requires local toolchain to build boringssl. |
||||
set -e |
||||
|
||||
cd $(dirname $0) |
||||
|
||||
symbol_list="../../src/objective-c/grpc_shadow_boringssl_symbol_list" |
||||
|
||||
ssl_lib='../../third_party/boringssl-with-bazel/build/libssl.a' |
||||
crypto_lib='../../third_party/boringssl-with-bazel/build/libcrypto.a' |
||||
|
||||
# Generate boringssl archives |
||||
( cd ../../third_party/boringssl-with-bazel ; mkdir -p build ; cd build ; cmake .. ; make -j ssl crypto ) |
||||
|
||||
# Generate shadow_boringssl.h |
||||
unameOut="$(uname -s)" |
||||
case "${unameOut}" in |
||||
Linux*) |
||||
outputs="$(nm $ssl_lib)"$'\n'"$(nm $crypto_lib)" |
||||
symbols=$(echo "$outputs" | |
||||
grep '^[0-9a-f]* [A-Z] ' | # Only public symbols |
||||
grep -v '^[0-9a-f]* [A-Z] _' | # Remove all symbols which look like for C++ |
||||
sed 's/[0-9a-f]* [A-Z] \(.*\)/\1/g' | # Extract the symbol names |
||||
sort) # Sort symbol names |
||||
;; |
||||
Darwin*) |
||||
outputs="$(nm -C $ssl_lib)"$'\n'"$(nm -C $crypto_lib)" |
||||
symbols=$(echo "$outputs" | |
||||
grep '^[0-9a-f]* [A-Z] ' | # Only public symbols |
||||
grep -v ' bssl::' | # Filter BoringSSL symbols since they are already namespaced |
||||
sed 's/(.*//g' | # Remove parenthesis from C++ symbols |
||||
grep '^[0-9a-f]* [A-Z] _' | # Filter symbols that is not prefixed with '_' |
||||
sed 's/[0-9a-f]* [A-Z] _\(.*\)/\1/g' | # Extract the symbol names |
||||
sort) # Sort symbol names |
||||
;; |
||||
*) |
||||
echo "Supports only Linux and Darwin but this system is $unameOut" |
||||
exit 1 |
||||
;; |
||||
esac |
||||
|
||||
commit=$(git submodule | grep "boringssl-with-bazel " | awk '{print $1}' | head -n 1) |
||||
|
||||
echo "# Automatically generated by tools/distrib/generate_grpc_shadow_boringssl_symbol_list.sh" > $symbol_list |
||||
echo $commit >> $symbol_list |
||||
echo "$symbols" >> $symbol_list |
||||
|
||||
exit 0 |
Loading…
Reference in new issue