Home | History | Annotate | Line # | Download | only in fuzz
      1  1.1.1.2  christos #!/bin/sh -eux
      2  1.1.1.2  christos 
      3      1.1  christos # Copyright (c) 2019 Yubico AB. All rights reserved.
      4      1.1  christos # Use of this source code is governed by a BSD-style
      5      1.1  christos # license that can be found in the LICENSE file.
      6  1.1.1.4  christos # SPDX-License-Identifier: BSD-2-Clause
      7      1.1  christos 
      8  1.1.1.2  christos LIBCBOR="$1"
      9  1.1.1.2  christos LIBFIDO2="$2"
     10      1.1  christos 
     11  1.1.1.2  christos CC="${CC:-clang}"
     12  1.1.1.2  christos CXX="${CXX:-clang++}"
     13  1.1.1.2  christos PKG_CONFIG_PATH="${PKG_CONFIG_PATH:-${LIBCBOR}/install/lib/pkgconfig}"
     14      1.1  christos export CC PKG_CONFIG_PATH
     15      1.1  christos 
     16      1.1  christos # Clean up.
     17  1.1.1.2  christos rm -rf "${LIBCBOR}/build" "${LIBCBOR}/install" "${LIBFIDO2}/build"
     18      1.1  christos 
     19      1.1  christos # Patch, build, and install libcbor.
     20  1.1.1.2  christos (cd "${LIBCBOR}" && patch -N -l -s -p0 < "${LIBFIDO2}/fuzz/README") || true
     21  1.1.1.2  christos mkdir "${LIBCBOR}/build" "${LIBCBOR}/install"
     22  1.1.1.3  christos (cd "${LIBCBOR}/build" && cmake -DBUILD_SHARED_LIBS=ON \
     23  1.1.1.3  christos 	-DCMAKE_INSTALL_PREFIX="${LIBCBOR}/install" ..)
     24  1.1.1.3  christos make -C "${LIBCBOR}/build" VERBOSE=1 all install
     25      1.1  christos 
     26      1.1  christos # Build libfido2.
     27  1.1.1.2  christos mkdir -p "${LIBFIDO2}/build"
     28  1.1.1.2  christos export CFLAGS="-fprofile-instr-generate -fcoverage-mapping"
     29  1.1.1.4  christos export CFLAGS="${CFLAGS} -fsanitize=fuzzer-no-link"
     30  1.1.1.2  christos export LDFLAGS="${CFLAGS}"
     31  1.1.1.4  christos export FUZZ_LDFLAGS="${LDFLAGS} -fsanitize=fuzzer"
     32  1.1.1.4  christos (cd "${LIBFIDO2}/build" && cmake -DFUZZ=ON -DFUZZ_LDFLAGS="${FUZZ_LDFLAGS}" \
     33  1.1.1.4  christos 	-DCMAKE_BUILD_TYPE=Debug ..)
     34  1.1.1.2  christos make -C "${LIBFIDO2}/build"
     35