Skip to content

Commit 0c60125

Browse files
committed
Update the oss-fuzz build script to try to get it to work with cmake.
1 parent 95737df commit 0c60125

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

fuzz/build.sh

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,38 @@
1515
#
1616
################################################################################
1717

18-
./autogen.sh
19-
./configure --enable-static --disable-shared
20-
make -j$(nproc) all
21-
ar rc json_c.a *.o
18+
# This should be run from the top of the json-c source tree.
2219

23-
cp $SRC/*.dict $OUT/
20+
mkdir build
21+
cd build
22+
cmake -DBUILD_SHARED_LIBS=OFF ..
23+
make -j$(nproc)
2424

25+
LIB=$(pwd)/libjson-c.a
26+
cd ..
27+
28+
# These seem to be set externally, but let's assign defaults to
29+
# make it possible to at least partially test this standalone.
30+
: ${SRC:=$(dirname "$0")}
31+
: ${OUT:=$SRC/out}
32+
: ${CXX:=gcc}
33+
: ${CXXFLAGS:=}
34+
35+
[ -d "$OUT" ] || mkdir "$OUT"
36+
cp $SRC/*.dict $OUT/.
37+
38+
# XXX this doesn't seem to make much sense, since $SRC is presumably
39+
# the "fuzz" directory, which is _inside_ the json-c repo, rather than
40+
# the other way around, but I'm just preserving existing behavior. -erh
41+
INCS=$SRC/json-c
42+
# Compat when testing standalone
43+
[ -e "${INCS}" ] || ln -s .. "${INCS}"
44+
45+
set -x
46+
set -v
2547
for f in $SRC/*_fuzzer.cc; do
2648
fuzzer=$(basename "$f" _fuzzer.cc)
27-
$CXX $CXXFLAGS -std=c++11 -I$SRC/json-c \
49+
$CXX $CXXFLAGS -std=c++11 -I$INCS \
2850
$SRC/${fuzzer}_fuzzer.cc -o $OUT/${fuzzer}_fuzzer \
29-
-lFuzzingEngine $SRC/json-c/json_c.a
51+
-lFuzzingEngine $LIB
3052
done

0 commit comments

Comments
 (0)