bump product version to 7.2.5.1
[LibreOffice.git] / bin / oss-fuzz-build.sh
blobf5fa83cab88bc864340b85f844441041b0646f74
1 #!/bin/bash -e
3 if [ -z "${OUT}" ] || [ -z "${SRC}" ] || [ -z "${WORK}" ]; then
4 echo "OUT, SRC or WORK not set - script expects to be called inside oss-fuzz build env"
5 exit 1
6 fi
8 #shuffle CXXFLAGS -stdlib=libc++ arg into CXX as well because we use
9 #the CXX as the linker and need to pass -stdlib=libc++ to build
10 export CXX="$CXX -stdlib=libc++ -fsanitize-blacklist=$SRC/libreoffice/bin/sanitize-excludelist.txt"
11 #similarly force the -fsanitize etc args in as well as pthread to get
12 #things to link successfully during the build
13 export LDFLAGS="$CFLAGS -Wl,--compress-debug-sections,zlib -lpthread"
15 df -h $OUT $WORK
17 cd $WORK
18 $SRC/libreoffice/autogen.sh --with-distro=LibreOfficeOssFuzz --with-external-tar=$SRC
20 make clean
22 #build-time rsc tool leaks a titch
23 export ASAN_OPTIONS="detect_leaks=0"
25 make fuzzers
27 pushd instdir/program
28 head -c -14 services.rdb > templateservices.rdb
29 tail -c +85 ./services/services.rdb >> templateservices.rdb
30 for a in *fuzzer; do
31 #some minimal fonts required
32 mv $a $OUT
33 mkdir -p $OUT/$a.fonts
34 cp $SRC/f543e6e2d7275557a839a164941c0a86e5f2c3f2a0042bfc434c88c6dde9e140-opens___.ttf ../share/fonts/truetype/Liberation* $OUT/$a.fonts
35 #minimal runtime requirements
36 cp templateservices.rdb $OUT/$a.services.rdb
37 cp types.rdb $OUT/$a.types.rdb
38 cp types/offapi.rdb $OUT/$a.moretypes.rdb
39 cat > $OUT/$a.unorc << EOF
40 [Bootstrap]
41 URE_INTERNAL_LIB_DIR=\${ORIGIN}
42 UNO_TYPES=\${ORIGIN}/$a.types.rdb \${ORIGIN}/$a.moretypes.rdb
43 UNO_SERVICES=\${ORIGIN}/$a.services.rdb
44 EOF
45 done
46 popd
48 df -h $OUT $WORK
50 #starting corpuses
51 for zip_file in $SRC/*_seed_corpus.zip; do
52 cp $zip_file $OUT
53 done
54 #fuzzing dictionaries
55 cp $SRC/*.dict $OUT
56 #options files
57 cp $SRC/libreoffice/vcl/workben/*.options $OUT