xref: /freebsd/contrib/libcbor/oss-fuzz/build.sh (revision 3332f1b444d4a73238e9f59cca27bfc95fe936bd)
1#!/bin/bash -eu
2# Copyright 2019 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 build
19cd build
20# We disable libcbor's default sanitizers since we'll be configuring them ourselves via CFLAGS.
21cmake -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX="$WORK" -D CBOR_CUSTOM_ALLOC=ON -D SANITIZE=OFF ..
22make "-j$(nproc)"
23make install
24
25$CXX $CXXFLAGS -std=c++11 "-I$WORK/include" \
26    ../oss-fuzz/cbor_load_fuzzer.cc -o "$OUT/cbor_load_fuzzer" \
27    $LIB_FUZZING_ENGINE src/libcbor.a
28
29