| 349 | } |
| 350 | |
| 351 | static void write_ossfuzz_makefile(std::vector<std::string> libfiles_prio, std::vector<std::string> extfiles) |
| 352 | { |
| 353 | for (auto& l : libfiles_prio) |
| 354 | { |
| 355 | l = "../" + l; |
| 356 | } |
| 357 | |
| 358 | for (auto& e : extfiles) |
| 359 | { |
| 360 | e = "../" + e; |
| 361 | } |
| 362 | |
| 363 | std::ofstream fout("oss-fuzz/Makefile"); |
| 364 | |
| 365 | fout << "# This file is generated by dmake, do not edit.\n"; |
| 366 | fout << '\n'; |
| 367 | fout << "# make CXX=clang++ MATCHCOMPILER=yes CXXOPTS=\"-O1 -fno-omit-frame-pointer -gline-tables-only -fsanitize=address -fsanitize-address-use-after-scope\" CPPOPTS=\"-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -DHAVE_BOOST\" LIB_FUZZING_ENGINE=\"-fsanitize=fuzzer\" oss-fuzz-client\n"; |
| 368 | fout << '\n'; |
| 369 | fout << "MATCHCOMPILER=yes\n"; // always need to enable the matchcompiler so the library files are being copied |
| 370 | makeMatchcompiler(fout, "../", "--read-dir ../lib"); |
| 371 | |
| 372 | fout << "INCS=-I../lib -isystem../externals/simplecpp -isystem../externals/tinyxml2 -isystem../externals/picojson\n"; |
| 373 | fout << '\n'; |
| 374 | fout << "override CXXFLAGS+=-std=c++11 -g -w\n"; |
| 375 | fout << "override CPPFLAGS+=$(INCS)\n"; |
| 376 | fout << '\n'; |
| 377 | fout << "override CXXFLAGS += $(CXXOPTS)\n"; |
| 378 | fout << "override CPPFLAGS += $(CPPOPTS)\n"; |
| 379 | fout << "override LDFLAGS += $(LDOPTS)\n"; |
| 380 | fout << '\n'; |
| 381 | fout << "LIBOBJ = " << objfiles(libfiles_prio) << "\n"; |
| 382 | fout << '\n'; |
| 383 | fout << "EXTOBJ = " << objfiles(extfiles) << "\n"; |
| 384 | fout << '\n'; |
| 385 | fout << "oss-fuzz-client: $(EXTOBJ) $(LIBOBJ) main.o type2.o\n"; |
| 386 | fout << "\t${CXX} ${CXXFLAGS} -o $@ $^ ${LIB_FUZZING_ENGINE}\n"; |
| 387 | fout << '\n'; |
| 388 | fout << "no-fuzz: $(EXTOBJ) $(LIBOBJ) main_nofuzz.o type2.o\n"; |
| 389 | fout << "\t${CXX} ${CXXFLAGS} -o $@ $^\n"; |
| 390 | fout << '\n'; |
| 391 | fout << "translate: translate.o type2.o\n"; |
| 392 | fout << "\t${CXX} -std=c++11 -g ${CXXFLAGS} -o $@ type2.cpp translate.cpp\n"; |
| 393 | fout << '\n'; |
| 394 | fout << "clean:\n"; |
| 395 | fout << "\trm -f *.o build/*.o oss-fuzz-client no-fuzz translate\n"; |
| 396 | fout << '\n'; |
| 397 | fout << "preprare-samples:\n"; |
| 398 | fout << "\trm -rf samples\n"; |
| 399 | fout << "\tmkdir -p samples\n"; |
| 400 | fout << "\tcp -R ../samples .\n"; |
| 401 | fout << "\tfind ./samples -type f -name '*.txt' -exec rm -vf {} \\;\n"; |
| 402 | fout << '\n'; |
| 403 | fout << "do-fuzz: oss-fuzz-client preprare-samples\n"; |
| 404 | fout << "\tmkdir -p corpus\n"; |
| 405 | fout << "\t./oss-fuzz-client -only_ascii=1 -timeout=5 -detect_leaks=0 corpus samples ../test/cli/fuzz-crash ../test/cli/fuzz-crash_c ../test/cli/fuzz-timeout\n"; |
| 406 | fout << '\n'; |
| 407 | fout << "dedup-corpus: oss-fuzz-client preprare-samples\n"; |
| 408 | fout << "\tmv corpus corpus_\n"; |
no test coverage detected