Bug 1481237 - Automate updating internal libFuzzer code. r=decoder
authorThomas P. <pdknsk+mozilla@gmail.com>
Wed, 15 Aug 2018 22:01:25 +0000
changeset 431841 f578ca2a361e
parent 431840 7de9496d9640
child 431842 5928090fcb23
push id106566
push userryanvm@gmail.com
push dateThu, 16 Aug 2018 03:12:31 +0000
treeherdermozilla-inbound@f578ca2a361e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdecoder
bugs1481237
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1481237 - Automate updating internal libFuzzer code. r=decoder
tools/fuzzing/libfuzzer/clone_libfuzzer.sh
--- a/tools/fuzzing/libfuzzer/clone_libfuzzer.sh
+++ b/tools/fuzzing/libfuzzer/clone_libfuzzer.sh
@@ -1,11 +1,31 @@
-#!/bin/sh
+#!/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
 
-mkdir tmp/
-git clone --no-checkout --depth 1 https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer tmp/
-(cd tmp && git reset --hard c2b235ee789fd452ba37c57957cc280fb37f9c52)
+if [ $1 ]; then
+  # libFuzzer source files
+  CPPS=($(ls -rv tmp/lib/fuzzer/*.cpp))
+  CPPS=(${CPPS[@]##*/})
+  CPPS=(${CPPS[@]##FuzzerMain*}) # ignored
 
-# Copy only source code and includes
-cp tmp/*.cpp tmp/*.h tmp/*.def .
+  # 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}"
+