blob: d256d98f6f3d3541cafe093d39b7fdf4bf90d198 [file] [log] [blame]
Reid Spencer35d958c2006-11-18 18:02:30 +00001#!/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
7function error {
8 retcode="$?"
9 echo "mkpatch: error: $1 ($retcode)"
10 exit 1
11}
12
13if [ ! -e llvm.spec.in ] ; then
14 error "Please change directory to the LLVM top source directory"
15fi
16if [ "$#" -ne 1 ] ; then
17 error "usage: utils/mkpatch [PATCH_NAME]"
18fi
19NAME="$1"
20echo "mkpatch: Generating differences on top level files"
Chandler Carruthef3d0162007-07-20 17:21:54 +000021svn diff -N -x -u > "$NAME".patch.raw 2>&1
Reid Spencer35d958c2006-11-18 18:02:30 +000022echo "mkpatch: Generating differences on all directories"
Reid Spencer0793b362007-07-09 07:41:11 +000023svn diff -x -u >> "$NAME".patch.raw 2>&1 \
Reid Spencer35d958c2006-11-18 18:02:30 +000024 autoconf docs utils include lib/System lib/Support lib/VMCore lib/AsmParser \
Chandler Carruthef3d0162007-07-20 17:21:54 +000025 lib/Bitcode lib/Analysis lib/Transforms lib/CodeGen lib/Target \
Reid Spencer35d958c2006-11-18 18:02:30 +000026 lib/ExecutionEngine lib/Debugger lib/Linker \
Misha Brukman8fb520e2009-01-01 02:24:48 +000027 tools test unittests runtime projects examples win32 Xcode
Reid Spencer35d958c2006-11-18 18:02:30 +000028
29echo "mkpatch: Removing cruft from the patch file"
Reid Spencer2c13f662007-01-17 03:38:22 +000030sed -e '/^[?] .*/d' -e '/^cvs diff: Diffing/d' "$NAME".patch.raw | awk '\
Reid Spencer35d958c2006-11-18 18:02:30 +000031BEGIN { deleting = 0; } \
Reid Spencer40beb402007-01-11 06:51:56 +000032/^Index: .*[.]cvs$/ { deleting = 1; fname=substr($0,7); \
Reid Spencer161a2fb2006-11-18 18:30:18 +000033 print "Skipping: ", fname > "/dev/stderr"; } \
Reid Spencer35d958c2006-11-18 18:02:30 +000034/^Index:.*/ && !/^Index: .*[.]cvs$/ { deleting = 0; } \
Reid Spencerea92a102007-01-16 22:41:12 +000035{ if (! deleting) { print; } } ' > "$NAME".patch || \
36 error "sed/awk cleanup failed"
Reid Spencer35d958c2006-11-18 18:02:30 +000037