xref: /netbsd-src/external/mit/libcbor/dist/oss-fuzz/build.sh (revision 5dd36a3bc8bf2a9dec29ceb6349550414570c447)
1*5dd36a3bSchristos#!/bin/bash -eu
2*5dd36a3bSchristos# Copyright 2019 Google Inc.
3*5dd36a3bSchristos#
4*5dd36a3bSchristos# Licensed under the Apache License, Version 2.0 (the "License");
5*5dd36a3bSchristos# you may not use this file except in compliance with the License.
6*5dd36a3bSchristos# You may obtain a copy of the License at
7*5dd36a3bSchristos#
8*5dd36a3bSchristos#      http://www.apache.org/licenses/LICENSE-2.0
9*5dd36a3bSchristos#
10*5dd36a3bSchristos# Unless required by applicable law or agreed to in writing, software
11*5dd36a3bSchristos# distributed under the License is distributed on an "AS IS" BASIS,
12*5dd36a3bSchristos# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*5dd36a3bSchristos# See the License for the specific language governing permissions and
14*5dd36a3bSchristos# limitations under the License.
15*5dd36a3bSchristos#
16*5dd36a3bSchristos################################################################################
17*5dd36a3bSchristos
18*5dd36a3bSchristosmkdir build
19*5dd36a3bSchristoscd build
20*5dd36a3bSchristos# We disable libcbor's default sanitizers since we'll be configuring them ourselves via CFLAGS.
21*5dd36a3bSchristoscmake -D CMAKE_BUILD_TYPE=Debug -D CMAKE_INSTALL_PREFIX="$WORK" -D CBOR_CUSTOM_ALLOC=ON -D SANITIZE=OFF ..
22*5dd36a3bSchristosmake "-j$(nproc)"
23*5dd36a3bSchristosmake install
24*5dd36a3bSchristos
25*5dd36a3bSchristos$CXX $CXXFLAGS -std=c++11 "-I$WORK/include" \
26*5dd36a3bSchristos    ../oss-fuzz/cbor_load_fuzzer.cc -o "$OUT/cbor_load_fuzzer" \
27*5dd36a3bSchristos    $LIB_FUZZING_ENGINE src/libcbor.a
28*5dd36a3bSchristos
29