1#!/bin/bash -eu 2# Copyright 2016 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 18: ${LD:="${CXX}"} 19: ${LDFLAGS:="${CXXFLAGS}"} # to make sure we link with sanitizer runtime 20 21cmake_args=( 22 # Specific to Expat 23 -DEXPAT_BUILD_FUZZERS=ON 24 -DEXPAT_OSSFUZZ_BUILD=ON 25 -DEXPAT_SHARED_LIBS=OFF 26 27 # C compiler 28 -DCMAKE_C_COMPILER="${CC}" 29 -DCMAKE_C_FLAGS="${CFLAGS}" 30 31 # C++ compiler 32 -DCMAKE_CXX_COMPILER="${CXX}" 33 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" 34 35 # Linker 36 -DCMAKE_LINKER="${LD}" 37 -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" 38 -DCMAKE_MODULE_LINKER_FLAGS="${LDFLAGS}" 39 -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" 40) 41 42mkdir -p build 43cd build 44cmake ../expat "${cmake_args[@]}" 45make -j$(nproc) 46 47for fuzzer in fuzz/*; 48do 49 cp $fuzzer $OUT 50 fuzzer_name=$(basename $fuzzer) 51 if [[ ${fuzzer_name} =~ ^.*UTF-16$ ]]; 52 then 53 cp $SRC/xml_UTF_16.dict $OUT/${fuzzer_name}.dict 54 elif [[ ${fuzzer_name} =~ ^.*UTF-16LE$ ]]; 55 then 56 cp $SRC/xml_UTF_16LE.dict $OUT/${fuzzer_name}.dict 57 elif [[ ${fuzzer_name} =~ ^.*UTF-16BE$ ]]; 58 then 59 cp $SRC/xml_UTF_16BE.dict $OUT/${fuzzer_name}.dict 60 else 61 cp $SRC/xml.dict $OUT/${fuzzer_name}.dict 62 fi 63done 64