1#!/bin/bash -eu 2# Copyright 2020 Google Inc. 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################################################################################ 17 18mkdir -p build 19cd build 20cmake -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ 21 -DBUILD_SHARED_LIBS=OFF -G "Unix Makefiles" .. 22make 23 24# Compile fuzzer. 25$CXX $CXXFLAGS -I../include $LIB_FUZZING_ENGINE \ 26 ../src/test_lib_json/fuzz.cpp -o $OUT/jsoncpp_fuzzer \ 27 lib/libjsoncpp.a 28 29# Add dictionary. 30cp $SRC/jsoncpp/src/test_lib_json/fuzz.dict $OUT/jsoncpp_fuzzer.dict 31 32if [[ $CFLAGS != *sanitize=memory* ]]; then 33# Compile json proto. 34rm -rf genfiles && mkdir genfiles && ../LPM/external.protobuf/bin/protoc json.proto --cpp_out=genfiles --proto_path=$SRC 35 36# Compile LPM fuzzer. 37$CXX $CXXFLAGS -I genfiles -I .. -I ../libprotobuf-mutator/ -I ../LPM/external.protobuf/include -I ../include $LIB_FUZZING_ENGINE \ 38 $SRC/jsoncpp_fuzz_proto.cc genfiles/json.pb.cc $SRC/json_proto_converter.cc \ 39 ../LPM/src/libfuzzer/libprotobuf-mutator-libfuzzer.a \ 40 ../LPM/src/libprotobuf-mutator.a \ 41 ../LPM/external.protobuf/lib/libprotobuf.a \ 42 -o $OUT/jsoncpp_proto_fuzzer \ 43 lib/libjsoncpp.a 44fi