]> granicus.if.org Git - json-c/commitdiff
Update the oss-fuzz build script to try to get it to work with cmake.
authorEric Haszlakiewicz <erh+git@nimenees.com>
Thu, 9 Apr 2020 02:34:59 +0000 (02:34 +0000)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Thu, 9 Apr 2020 02:35:41 +0000 (02:35 +0000)
fuzz/build.sh

index 30c3f779e4c56ef7a8e1d52cecb84cb7c05cda16..b6a5cc75c9fa8cbab71e2cbb923711e9b4d51bf1 100755 (executable)
 #
 ################################################################################
 
-./autogen.sh
-./configure --enable-static --disable-shared
-make -j$(nproc) all
-ar rc json_c.a *.o
+# This should be run from the top of the json-c source tree.
 
-cp $SRC/*.dict $OUT/
+mkdir build
+cd build
+cmake -DBUILD_SHARED_LIBS=OFF ..
+make -j$(nproc)
 
+LIB=$(pwd)/libjson-c.a
+cd ..
+
+# These seem to be set externally, but let's assign defaults to
+# make it possible to at least partially test this standalone.
+: ${SRC:=$(dirname "$0")}
+: ${OUT:=$SRC/out}
+: ${CXX:=gcc}
+: ${CXXFLAGS:=}
+
+[ -d "$OUT" ] || mkdir "$OUT"
+cp $SRC/*.dict $OUT/.
+
+# XXX this doesn't seem to make much sense, since $SRC is presumably
+# the "fuzz" directory, which is _inside_ the json-c repo, rather than
+# the other way around, but I'm just preserving existing behavior. -erh
+INCS=$SRC/json-c
+# Compat when testing standalone
+[ -e "${INCS}" ] || ln -s .. "${INCS}"
+
+set -x
+set -v
 for f in $SRC/*_fuzzer.cc; do
     fuzzer=$(basename "$f" _fuzzer.cc)
-    $CXX $CXXFLAGS -std=c++11 -I$SRC/json-c \
+    $CXX $CXXFLAGS -std=c++11 -I$INCS \
          $SRC/${fuzzer}_fuzzer.cc -o $OUT/${fuzzer}_fuzzer \
-         -lFuzzingEngine $SRC/json-c/json_c.a
+         -lFuzzingEngine $LIB
 done