Commit 87db567e1f094cbc9118f7c8d215df157b1601b5

Authored by Jay Berkenbilt
Committed by Jay Berkenbilt
1 parent 5ee21c67

Convert oss-fuzz-build to use cmake

README-maintainer
@@ -80,11 +80,8 @@ GOOGLE OSS-FUZZ @@ -80,11 +80,8 @@ GOOGLE OSS-FUZZ
80 80
81 Clone the oss-fuzz project. From the root directory of the repository: 81 Clone the oss-fuzz project. From the root directory of the repository:
82 82
83 - Add `-e GITHUB_FORK=fork -e GITHUB_BRANCH=branch` to build_fuzzers  
84 - from a qpdf fork/branch rather than qpdf/main.  
85 -  
86 python3 infra/helper.py build_image --pull qpdf 83 python3 infra/helper.py build_image --pull qpdf
87 - python3 infra/helper.py build_fuzzers [ --sanitizer memory|undefined|address ] qpdf 84 + python3 infra/helper.py build_fuzzers [ --sanitizer memory|undefined|address ] qpdf [path-to-qpdf-source]
88 python3 infra/helper.py check_build qpdf 85 python3 infra/helper.py check_build qpdf
89 python3 infra/helper.py build_fuzzers --sanitizer coverage qpdf 86 python3 infra/helper.py build_fuzzers --sanitizer coverage qpdf
90 python3 infra/helper.py coverage qpdf 87 python3 infra/helper.py coverage qpdf
build-scripts/build-fuzzer
@@ -4,8 +4,12 @@ export WORK=$PWD/work @@ -4,8 +4,12 @@ export WORK=$PWD/work
4 export OUT=$PWD/out 4 export OUT=$PWD/out
5 mkdir -p $WORK $OUT 5 mkdir -p $WORK $OUT
6 sudo apt-get update 6 sudo apt-get update
7 -sudo apt-get -y install \  
8 - autoconf build-essential zlib1g-dev libjpeg-dev 7 +sudo apt-get -y install build-essential cmake zlib1g-dev libjpeg-dev
9 ./fuzz/oss-fuzz-build 8 ./fuzz/oss-fuzz-build
10 -ls -l out/qpdf*fuzzer 9 +ls -l out/qpdf_fuzzer
11 ls -l out/ 10 ls -l out/
  11 +if ldd out/qpdf_fuzzer | egrep 'libjpeg|libz|libqpdf'; then
  12 + echo 1>&2 "*** Fuzzers linked dynamically with some dependent libraries."
  13 + ldd out/qpdf_fuzzer
  14 + exit 2
  15 +fi
fuzz/oss-fuzz-build
@@ -21,15 +21,9 @@ if [[ $GITHUB_FORK != "" ]]; then @@ -21,15 +21,9 @@ if [[ $GITHUB_FORK != "" ]]; then
21 fi 21 fi
22 fi 22 fi
23 23
24 -./configure \  
25 - --enable-oss-fuzz \  
26 - --enable-static \  
27 - --disable-shared \  
28 - --enable-crypto-native \  
29 - --disable-implicit-crypto \  
30 - --prefix="$WORK" \  
31 - LDFLAGS="-L$WORK/lib" \  
32 - CPPFLAGS="-I$WORK/include" \  
33 - LIBS="-pthread"  
34 -make -j$(nproc) install  
35 -make install_fuzz 24 +env CMAKE_PREFIX_PATH=$WORK LDFLAGS="-L$WORK/lib -lpthread" \
  25 + cmake -S . -B build \
  26 + -DOSS_FUZZ=1 -DBUILD_SHARED_LIBS=0 -DCMAKE_BUILD_TYPE=Debug \
  27 + -DUSE_IMPLICIT_CRYPTO=0 -DREQUIRE_CRYPTO_NATIVE=1
  28 +cmake --build build -j$(nproc) --target fuzzers
  29 +cmake --install build --component fuzz