-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
66 lines (55 loc) · 1.21 KB
/
build.sh
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
if [ -z $WORKDIR ]; then
WORKDIR=./workspace
fi
# | workspace
# | src (required)
# | cJSON (repo)
# | build
# | lib (required)
# | libcjson.a
# | include (optional)
# | cJSON.h
# | corpus (optional)
# | dict (optional)
# | json.dict
mkdir -p $WORKDIR
# to absolute path
WORKDIR=`realpath $WORKDIR`
pushd $WORKDIR
SRCDIR=$WORKDIR/src
mkdir -p $SRCDIR && pushd $SRCDIR
# clone the project
git clone https://github.com/DaveGamble/cJSON
# specify the version
pushd cJSON
git checkout v1.7.18
BUILDIR=$WORKDIR/build
mkdir -p $BUILDIR && pushd $BUILDIR
# build
FLAGS="-g -fprofile-instr-generate -fcoverage-mapping -fsanitize=fuzzer-no-link -fno-sanitize=undefined,address"
export CC=clang
export CXX=clang++
export CFLAGS="$CFLAGS $FLAGS"
export CXXFLAGS="$CXXFLAGS $FLAGS"
cmake -DBUILD_SHARED_AND_STATIC_LIBS=ON -DENABLE_CJSON_TEST=OFF $SRCDIR/cJSON
make -j 4
mkdir -p $WORKDIR/lib
cp libcjson.a $WORKDIR/lib
# $SRCDIR/cJSON
popd
pwd
# copy header files
mkdir -p $WORKDIR/include
cp cJSON.h $WORKDIR/include
# copy corpus
mkdir -p $WORKDIR/corpus
cp fuzzing/inputs/* $WORKDIR/corpus
# copy dict
mkdir -p $WORKDIR/dict
cp fuzzing/json.dict $WORKDIR/dict
# $SRCDIR
popd
# $WORKDIR
popd
popd