1#!/bin/bash
2
3set -ex
4
5# Clone the oss-fuzz repository
6git clone https://github.com/google/oss-fuzz.git /tmp/ossfuzz
7
8if [[ ! -d /tmp/ossfuzz/projects/lz4 ]]
9then
10    echo "Could not find the lz4 project in ossfuzz"
11    exit 1
12fi
13
14# Modify the oss-fuzz Dockerfile so that we're checking out the current branch on travis.
15if [ "x${TRAVIS_PULL_REQUEST}" = "xfalse" ]
16then
17    sed -i "s@https://github.com/lz4/lz4.git@-b ${TRAVIS_BRANCH} https://github.com/lz4/lz4.git@" /tmp/ossfuzz/projects/lz4/Dockerfile
18else
19    sed -i "s@https://github.com/lz4/lz4.git@-b ${TRAVIS_PULL_REQUEST_BRANCH} https://github.com/${TRAVIS_PULL_REQUEST_SLUG}.git@" /tmp/ossfuzz/projects/lz4/Dockerfile
20fi
21
22# Try and build the fuzzers
23pushd /tmp/ossfuzz
24python infra/helper.py build_image --pull lz4
25python infra/helper.py build_fuzzers lz4
26popd
27