• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
18# temporary hack to make the build honor CFLAGS. Needs proper fix upstream.
19sed -i 's/^CFLAGS.*//g' Makefile
20# build project
21make -j$(nproc) all
22
23# build fuzzers
24$CC $CFLAGS -c -std=c99 -Isrc \
25    "$SRC/hoextdown/test/hoedown_fuzzer.c" -o $WORK/hoedown_fuzzer.o
26$CXX $CXXFLAGS -std=c++11 -Isrc \
27    $WORK/hoedown_fuzzer.o -o $OUT/hoedown_fuzzer \
28    $LIB_FUZZING_ENGINE "$SRC/hoextdown/libhoedown.a"
29
30cp $SRC/*.options $OUT/
31cp $SRC/*.dict $OUT/
32
33# build corpus
34mkdir -p corpus
35find $SRC/hoextdown/test -type f -name '*.text' | while read in_file
36do
37  # Genreate unique name for each input...
38  out_file=$(sha1sum "$in_file" | cut -c 1-32)
39  cat "$in_file" >> "corpus/$out_file"
40done
41
42zip -j $OUT/hoextdown_fuzzer_corpus.zip corpus/*
43