Home | History | Annotate | Line # | Download | only in fuzz
build-coverage revision 1.1.1.2
      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  christos 
      7  1.1.1.2  christos LIBCBOR="$1"
      8  1.1.1.2  christos LIBFIDO2="$2"
      9      1.1  christos 
     10  1.1.1.2  christos CC="${CC:-clang}"
     11  1.1.1.2  christos CXX="${CXX:-clang++}"
     12  1.1.1.2  christos PKG_CONFIG_PATH="${PKG_CONFIG_PATH:-${LIBCBOR}/install/lib/pkgconfig}"
     13      1.1  christos export CC PKG_CONFIG_PATH
     14      1.1  christos 
     15      1.1  christos # Clean up.
     16  1.1.1.2  christos rm -rf "${LIBCBOR}/build" "${LIBCBOR}/install" "${LIBFIDO2}/build"
     17      1.1  christos 
     18      1.1  christos # Patch, build, and install libcbor.
     19  1.1.1.2  christos (cd "${LIBCBOR}" && patch -N -l -s -p0 < "${LIBFIDO2}/fuzz/README") || true
     20  1.1.1.2  christos mkdir "${LIBCBOR}/build" "${LIBCBOR}/install"
     21  1.1.1.2  christos (cd "${LIBCBOR}/build" && cmake -DCMAKE_INSTALL_PREFIX="${LIBCBOR}/install" ..)
     22  1.1.1.2  christos make -C "${LIBCBOR}/build" all install
     23      1.1  christos 
     24      1.1  christos # Build libfido2.
     25  1.1.1.2  christos mkdir -p "${LIBFIDO2}/build"
     26  1.1.1.2  christos export CFLAGS="-fprofile-instr-generate -fcoverage-mapping"
     27  1.1.1.2  christos export LDFLAGS="${CFLAGS}"
     28  1.1.1.2  christos (cd "${LIBFIDO2}/build" && cmake -DFUZZ=1 -DLIBFUZZER=1 \
     29  1.1.1.2  christos     -DCMAKE_BUILD_TYPE=Debug ..)
     30  1.1.1.2  christos make -C "${LIBFIDO2}/build"
     31