aboutsummaryrefslogtreecommitdiffhomepage
path: root/projects/grpc/build.sh
blob: b7ffe78d908b936d7cc43f516a39db1a04410069 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash -eu
# Copyright 2016 Google Inc.
#
# 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.
#
################################################################################

FUZZER_FILES="\
test/core/end2end/fuzzers/api_fuzzer.c \
test/core/json/fuzzer.c \
test/core/client_channel/uri_fuzzer_test.c \
test/core/http/request_fuzzer.c \
test/core/http/response_fuzzer.c \
test/core/nanopb/fuzzer_response.c \
test/core/nanopb/fuzzer_serverlist.c \
test/core/slice/percent_decode_fuzzer.c \
test/core/slice/percent_encode_fuzzer.c \
test/core/transport/chttp2/hpack_parser_fuzzer_test.c \
test/core/end2end/fuzzers/client_fuzzer.c \
test/core/end2end/fuzzers/server_fuzzer.c \
test/core/security/ssl_server_fuzzer.c \
"

FUZZER_LIBRARIES="\
bazel-bin/*.a \
bazel-bin/test/core/util/*.a \
bazel-bin/test/core/end2end/*.a \
bazel-bin/third_party/boringssl-with-bazel/libssl.a \
bazel-bin/third_party/boringssl-with-bazel/libcrypto.a \
bazel-bin/external/submodule_zlib/_objs/z/external/submodule_zlib/*.o \
bazel-bin/third_party/nanopb/*.a \
bazel-bin/*.a \
"

# build grpc
# Temporary hack, see https://github.com/google/oss-fuzz/issues/383
NO_VPTR="--copt=-fno-sanitize=vptr --linkopt=-fno-sanitize=vptr"
EXTERA_BAZEL_FLAGS="--strip=never  $(for f in $CXXFLAGS; do if [ $f != "-stdlib=libc++" ] ; then echo --copt=$f --linkopt=$f; fi; done)"
bazel build --dynamic_mode=off --spawn_strategy=standalone --genrule_strategy=standalone \
  $EXTERA_BAZEL_FLAGS \
  $NO_VPTR \
	:all test/... third_party/boringssl-with-bazel/... third_party/nanopb/...

CFLAGS="${CFLAGS} -Iinclude -I."
CXXFLAGS="${CXXFLAGS} -Iinclude -I. -stdlib=libc++"

for file in $FUZZER_FILES; do
  fuzzer_name=$(basename $file .c)
  fuzzer_object="${file::-1}o"
  echo "Building fuzzer $fuzzer_name"
  $CC $CFLAGS \
    $file -c -o $fuzzer_object 
  $CXX $CXXFLAGS \
    $fuzzer_object -o $OUT/$fuzzer_name \
    -lFuzzingEngine ${FUZZER_LIBRARIES}
done