You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.sh 1.6 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash -eu
  2. # Copyright 2018 Google Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. ################################################################################
  17. # This should be run from the top of the json-c source tree.
  18. mkdir build
  19. cd build
  20. cmake -DBUILD_SHARED_LIBS=OFF ..
  21. make -j$(nproc)
  22. LIB=$(pwd)/libjson-c.a
  23. cd ..
  24. # These seem to be set externally, but let's assign defaults to
  25. # make it possible to at least partially test this standalone.
  26. : ${SRC:=$(dirname "$0")}
  27. : ${OUT:=$SRC/out}
  28. : ${CXX:=gcc}
  29. : ${CXXFLAGS:=}
  30. [ -d "$OUT" ] || mkdir "$OUT"
  31. cp $SRC/*.dict $OUT/.
  32. # XXX this doesn't seem to make much sense, since $SRC is presumably
  33. # the "fuzz" directory, which is _inside_ the json-c repo, rather than
  34. # the other way around, but I'm just preserving existing behavior. -erh
  35. INCS=$SRC/json-c
  36. # Compat when testing standalone
  37. [ -e "${INCS}" ] || ln -s .. "${INCS}"
  38. set -x
  39. set -v
  40. for f in $SRC/*_fuzzer.cc; do
  41. fuzzer=$(basename "$f" _fuzzer.cc)
  42. $CXX $CXXFLAGS -std=c++11 -I$INCS \
  43. $SRC/${fuzzer}_fuzzer.cc -o $OUT/${fuzzer}_fuzzer \
  44. -lFuzzingEngine $LIB
  45. done