Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # This script checks out both LLVM and Clang on the same revision number. |
| 4 | # It can also revert a commit in the past to check for hidden failures. |
| 5 | |
| 6 | validate () { |
| 7 | echo $1 | grep -q "^[0-9]\+$" |
| 8 | } |
| 9 | |
| 10 | checkout () { |
| 11 | name=$1 |
| 12 | dir=$2 |
| 13 | to=$3 |
| 14 | echo $name |
| 15 | if [ -d $dir ]; then |
| 16 | cd $dir |
| 17 | svn revert . |
| 18 | svn up -r $to |
| 19 | cd .. |
| 20 | else |
| 21 | svn co -r $to http://llvm.org/svn/llvm-project/$dir/trunk $dir |
| 22 | fi |
| 23 | } |
| 24 | |
| 25 | revert () { |
| 26 | dir=$1 |
| 27 | minus=$2 |
| 28 | cd $dir |
| 29 | svn merge -c -$minus . |
| 30 | cd .. |
| 31 | } |
| 32 | |
| 33 | if [ "$1" = "" ]; then |
| 34 | echo "Syntax: $0 <revision-to> [<revision-minus>]" |
| 35 | exit 1 |
| 36 | fi |
| 37 | if ! validate $1; then |
| 38 | echo "Invalid SVN revision to $1" |
| 39 | exit 1 |
| 40 | fi |
| 41 | if [ "$2" != "" ] && ! validate $2; then |
| 42 | echo "Invalid SVN revision minus $2" |
| 43 | exit 1 |
| 44 | fi |
| 45 | |
| 46 | checkout "LLVM" llvm $1 |
| 47 | if [ "$2" != "" ]; then |
| 48 | revert llvm $2 |
| 49 | fi |
| 50 | |
| 51 | checkout "Clang" cfe $1 |
| 52 | ln -sf `pwd`/cfe `pwd`/llvm/tools/clang |
| 53 | if [ "$2" != "" ]; then |
| 54 | revert cfe $2 |
| 55 | fi |
| 56 | |
| 57 | checkout "Compiler-RT" compiler-rt $1 |
| 58 | ln -sf `pwd`/compiler-rt `pwd`/llvm/projects/compiler-rt |
| 59 | if [ "$2" != "" ]; then |
| 60 | revert compiler-rt $2 |
| 61 | fi |