| Reid Spencer | 35d958c | 2006-11-18 18:02:30 +0000 | [diff] [blame] | 1 | #!/bin/bash | 
 | 2 | # | 
 | 3 | # This script makes a patch for LLVM ensuring the correct diff options and | 
 | 4 | # putting the files in a standard review order. | 
 | 5 |  | 
 | 6 |  | 
 | 7 | function error { | 
 | 8 |   retcode="$?" | 
 | 9 |   echo "mkpatch: error: $1 ($retcode)" | 
 | 10 |   exit 1 | 
 | 11 | } | 
 | 12 |  | 
 | 13 | if [ ! -e llvm.spec.in ] ; then | 
 | 14 |   error "Please change directory to the LLVM top source directory" | 
 | 15 | fi | 
 | 16 | if [ "$#" -ne 1 ] ; then | 
 | 17 |   error "usage: utils/mkpatch [PATCH_NAME]" | 
 | 18 | fi | 
 | 19 | NAME="$1" | 
 | 20 | echo "mkpatch: Generating differences on top level files" | 
| Chandler Carruth | ef3d016 | 2007-07-20 17:21:54 +0000 | [diff] [blame] | 21 | svn diff -N -x -u > "$NAME".patch.raw 2>&1 | 
| Reid Spencer | 35d958c | 2006-11-18 18:02:30 +0000 | [diff] [blame] | 22 | echo "mkpatch: Generating differences on all directories" | 
| Reid Spencer | 0793b36 | 2007-07-09 07:41:11 +0000 | [diff] [blame] | 23 | svn diff -x -u  >> "$NAME".patch.raw 2>&1 \ | 
| Reid Spencer | 35d958c | 2006-11-18 18:02:30 +0000 | [diff] [blame] | 24 |   autoconf docs utils include lib/System lib/Support lib/VMCore lib/AsmParser \ | 
| Chandler Carruth | ef3d016 | 2007-07-20 17:21:54 +0000 | [diff] [blame] | 25 |   lib/Bitcode lib/Analysis lib/Transforms lib/CodeGen lib/Target \ | 
| Reid Spencer | 35d958c | 2006-11-18 18:02:30 +0000 | [diff] [blame] | 26 |   lib/ExecutionEngine lib/Debugger lib/Linker \ | 
 | 27 |   tools test runtime projects examples win32 Xcode | 
 | 28 |  | 
 | 29 | echo "mkpatch: Removing cruft from the patch file" | 
| Reid Spencer | 2c13f66 | 2007-01-17 03:38:22 +0000 | [diff] [blame] | 30 | sed -e '/^[?] .*/d' -e '/^cvs diff: Diffing/d' "$NAME".patch.raw | awk '\ | 
| Reid Spencer | 35d958c | 2006-11-18 18:02:30 +0000 | [diff] [blame] | 31 | BEGIN { deleting = 0; } \ | 
| Reid Spencer | 40beb40 | 2007-01-11 06:51:56 +0000 | [diff] [blame] | 32 | /^Index: .*[.]cvs$/ { deleting = 1; fname=substr($0,7); \ | 
| Reid Spencer | 161a2fb | 2006-11-18 18:30:18 +0000 | [diff] [blame] | 33 |   print "Skipping: ", fname > "/dev/stderr"; } \ | 
| Reid Spencer | 35d958c | 2006-11-18 18:02:30 +0000 | [diff] [blame] | 34 | /^Index:.*/ && !/^Index: .*[.]cvs$/ { deleting = 0; } \ | 
| Reid Spencer | ea92a10 | 2007-01-16 22:41:12 +0000 | [diff] [blame] | 35 | { if (! deleting) { print; } } '  > "$NAME".patch  || \ | 
 | 36 |   error "sed/awk cleanup failed" | 
| Reid Spencer | 35d958c | 2006-11-18 18:02:30 +0000 | [diff] [blame] | 37 |  |