aboutsummaryrefslogtreecommitdiffstats
path: root/fuzz/oss-fuzz-build
blob: ae03292ee3b4a40b30474a5622dc06e797ef0944 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash -ex

# This is used invoked from
# https://github.com/google/oss-fuzz/blob/master/projects/qpdf/build.sh

# It should be run from the top level directory of a clean checkout of
# qpdf. It is also exercised in ../build-scripts/build-fuzzer

if [[ $GITHUB_FORK != "" ]]; then
    git remote add fork https://github.com/$GITHUB_FORK/qpdf
    git fetch fork --depth=1
    CUR_BRANCH=$(git rev-parse --abbrev-ref @)
    if [[ $GITHUB_BRANCH == "" ]]; then
        GITHUB_BRANCH=$CUR_BRANCH
    fi
    if [[ $GITHUB_BRANCH == $CUR_BRANCH ]]; then
        git reset --hard fork/$CUR_BRANCH
    else
        git branch -f $GITHUB_BRANCH fork/$GITHUB_BRANCH
        git checkout $GITHUB_BRANCH
    fi
fi

env CMAKE_PREFIX_PATH=$WORK LDFLAGS="-L$WORK/lib -lpthread" \
    cmake -S . -B build \
    -DOSS_FUZZ=1 -DBUILD_SHARED_LIBS=0 -DCMAKE_BUILD_TYPE=Debug \
    -DUSE_IMPLICIT_CRYPTO=0 -DREQUIRE_CRYPTO_NATIVE=1
cmake --build build -j$(nproc) --target fuzzers
cmake --install build --component fuzz