address comments

pull/21194/head
Muxi Yan 5 years ago
parent 65e24bcfc9
commit 056bd79091
  1. 466
      src/objective-c/BoringSSL-GRPC.podspec
  2. 32
      templates/src/objective-c/BoringSSL-GRPC.podspec.template
  3. 8
      tools/distrib/generate_boringssl_prefix_header.sh

File diff suppressed because one or more lines are too long

@ -7,14 +7,27 @@
import subprocess import subprocess
boringssl_commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd='third_party/boringssl-with-bazel').decode().strip() boringssl_commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd='third_party/boringssl-with-bazel').decode().strip()
import gzip, shutil, os, base64 # Compress src/boringssl/boringssl_prefix_symbols.h with gzip then encode
# with Base64. The result is put in variable prefix_gz_b64.
#
# Note that gRPC's template parser is still using Python 2, whose gzip
# module does not support directly compressing bytes into bytes. Instead,
# we have to write the compressed bytes into a intermediate file
# (src/boringssl/boringssl_prefix_symbols.h.gz), read the compressed
# bytes from this file, then delete the intermediate file.
#
# TODO(mxyan): move to python3 style gzip compression when possible # TODO(mxyan): move to python3 style gzip compression when possible
with open('src/boringssl/boringssl_prefix_symbols.h', 'rb') as f_in, gzip.GzipFile('src/boringssl/boringssl_prefix_symbols.h.gz', 'w', mtime=0.0) as f_out: def compress_boringssl_prefix_header():
shutil.copyfileobj(f_in, f_out) import gzip, shutil, os, base64
with open('src/boringssl/boringssl_prefix_symbols.h.gz', 'rb') as f_in: with open('src/boringssl/boringssl_prefix_symbols.h', 'rb') as f_in, gzip.GzipFile('src/boringssl/boringssl_prefix_symbols.h.gz', 'w', mtime=0.0) as f_out:
prefix_gz = f_in.read() shutil.copyfileobj(f_in, f_out)
os.remove('src/boringssl/boringssl_prefix_symbols.h.gz') with open('src/boringssl/boringssl_prefix_symbols.h.gz', 'rb') as f_in:
prefix_gz_b64 = base64.b64encode(prefix_gz) prefix_gz = f_in.read()
os.remove('src/boringssl/boringssl_prefix_symbols.h.gz')
prefix_gz_b64 = base64.b64encode(prefix_gz)
WRAP_LENGTH=80
prefix_gz_b64_wrapped = [prefix_gz_b64[i:i+WRAP_LENGTH] for i in range(0, len(prefix_gz_b64), WRAP_LENGTH)]
return prefix_gz_b64_wrapped
%> %>
# This file has been automatically generated from a template file. # This file has been automatically generated from a template file.
@ -230,12 +243,13 @@
# /src/boringssl/boringssl_prefix_symbols.h. Here we decode the content and inject the header to # /src/boringssl/boringssl_prefix_symbols.h. Here we decode the content and inject the header to
# the correct location in BoringSSL. # the correct location in BoringSSL.
base64 -D <<EOF | gunzip > src/include/openssl/boringssl_prefix_symbols.h base64 -D <<EOF | gunzip > src/include/openssl/boringssl_prefix_symbols.h
${prefix_gz_b64} % for line in compress_boringssl_prefix_header():
${line}
% endfor
EOF EOF
# We are renaming openssl to openssl_grpc so that there is no conflict with openssl if it exists # We are renaming openssl to openssl_grpc so that there is no conflict with openssl if it exists
find . -type f \\( -path '*.h' -or -path '*.cc' -or -path '*.c' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include <openssl/;#include <openssl_grpc/;g' find . -type f \\( -path '*.h' -or -path '*.cc' -or -path '*.c' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include <openssl/;#include <openssl_grpc/;g'
# BoringSSL include boringssl_prefix_symbols.h without any prefix, which does not match the
# Include of boringssl_prefix_symbols.h does not follow Xcode import style. We add the package # Include of boringssl_prefix_symbols.h does not follow Xcode import style. We add the package
# name here so that Xcode knows where to find it. # name here so that Xcode knows where to find it.

@ -31,23 +31,21 @@ cd ../../$BORINGSSL_ROOT
BORINGSSL_COMMIT=$(git rev-parse HEAD) BORINGSSL_COMMIT=$(git rev-parse HEAD)
BORINGSSL_PREFIX_HEADERS_DIR=src/boringssl BORINGSSL_PREFIX_HEADERS_DIR=src/boringssl
# generate the prefix header
rm -rf build rm -rf build
mkdir -p build mkdir -p build
cd build cd build
cmake .. cmake ..
make -j make -j
[ -f ssl/libssl.a ] || { echo "Failed to build libssl.a" ; exit 1 ; } [ -f ssl/libssl.a ] || { echo "Failed to build libssl.a" ; exit 1 ; }
[ -f crypto/libcrypto.a ] || { echo "Failed to build libcrypto.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 ssl/libssl.a > ./symbols.txt
go run ../util/read_symbols.go crypto/libcrypto.a >> ./symbols.txt go run ../util/read_symbols.go crypto/libcrypto.a >> ./symbols.txt
# generates boringssl_prefix_symbols.h
cmake .. -DBORINGSSL_PREFIX=GRPC -DBORINGSSL_PREFIX_SYMBOLS=symbols.txt cmake .. -DBORINGSSL_PREFIX=GRPC -DBORINGSSL_PREFIX_SYMBOLS=symbols.txt
make boringssl_prefix_symbols make boringssl_prefix_symbols
[ -f symbol_prefix_include/boringssl_prefix_symbols.h ] || { echo "Failed to build boringssl_prefix_symbols.sh" ; exit 1 ; } [ -f symbol_prefix_include/boringssl_prefix_symbols.h ] || { echo "Failed to build boringssl_prefix_symbols.sh" ; exit 1 ; }
cd ../../../.. cd ../../../..

Loading…
Cancel
Save