tools/fuzzing/libfuzzer/clone_libfuzzer.sh
author Thomas P. <pdknsk+mozilla@gmail.com>
Wed, 15 Aug 2018 22:01:25 +0000
changeset 431869 f578ca2a361ec09d98582dc9428345d9c57096ec
parent 412478 470ed9163d2219a5dfd9b26f8fce4842ecbeab9d
child 470001 f4de96f2d275f0bff16042ef322a69366b79cb81
permissions -rwxr-xr-x
Bug 1481237 - Automate updating internal libFuzzer code. r=decoder

#!/bin/bash

# Optionally get revision from cmd line
# Changelog: https://reviews.llvm.org/source/compiler-rt/history/compiler-rt/trunk/lib/fuzzer/
[ $1 ] && REVISION=$1 || REVISION=329438

mkdir tmp
svn co -qr $REVISION http://llvm.org/svn/llvm-project/compiler-rt/trunk tmp || exit

if [ $1 ]; then
  # libFuzzer source files
  CPPS=($(ls -rv tmp/lib/fuzzer/*.cpp))
  CPPS=(${CPPS[@]##*/})
  CPPS=(${CPPS[@]##FuzzerMain*}) # ignored

  # Update SOURCES entries
  sed -e "/^SOURCES/,/^]/ {/'/d}" -i moz.build
  for CPP in ${CPPS[@]}; do sed -e "/^SOURCES/ a \\\t'${CPP}'," -i moz.build; done

  # Remove previous files
  rm *.{cpp,h,def}
fi

# Copy files
cp tmp/lib/fuzzer/*.{cpp,h,def} .

# Remove the temporary directory
rm -Rf tmp/

[ $1 ] && echo "Updated libFuzzer to ${REVISION}"