111
|
1 #!/bin/bash
|
|
2
|
|
3 # FIXME: do we need a license (or whatever else) header here?
|
|
4
|
|
5 # This script merges libsanitizer sources from upstream.
|
|
6
|
|
7 get_upstream() {
|
|
8 rm -rf upstream
|
|
9 #cp -rf orig upstream
|
|
10 svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk upstream
|
|
11 }
|
|
12
|
|
13 get_current_rev() {
|
|
14 cd upstream
|
|
15 svn info | grep Revision | grep -o '[0-9]*'
|
|
16 }
|
|
17
|
|
18 list_files() {
|
|
19 (cd $1; ls *.{cc,h,inc,S} 2> /dev/null)
|
|
20
|
|
21 }
|
|
22
|
|
23 change_comment_headers() {
|
|
24 for f in $(list_files $1); do
|
|
25 sed -n 3p $1/$f | grep -q 'The LLVM Compiler Infrastructure' || continue
|
|
26 changed=$(awk 'NR != 2 && NR != 3' < $1/$f)
|
|
27 echo "$changed" > $1/$f
|
|
28 done
|
|
29 }
|
|
30
|
|
31 # ARGUMENTS: upstream_path local_path
|
|
32 # This function merges changes from the directory upstream_path to
|
|
33 # the directory local_path.
|
|
34 merge() {
|
|
35 upstream_path=upstream/$1
|
|
36 local_path=$2
|
|
37 change_comment_headers $upstream_path
|
|
38 echo MERGE: $upstream_path
|
|
39 all=$( (list_files $upstream_path; list_files $local_path) | sort | uniq)
|
|
40 #echo $all
|
|
41 for f in $all; do
|
|
42 if [ -f $upstream_path/$f -a -f $local_path/$f ]; then
|
|
43 echo "FOUND IN BOTH :" $f
|
|
44 # diff -u $local_path/$f $upstream_path/$f
|
|
45 cp -v $upstream_path/$f $local_path
|
|
46 elif [ -f $upstream_path/$f ]; then
|
|
47 echo "FOUND IN UPSTREAM :" $f
|
|
48 cp -v $upstream_path/$f $local_path
|
|
49 svn add $local_path/$f
|
|
50 elif [ -f $local_path/$f ]; then
|
|
51 echo "FOUND IN LOCAL :" $f
|
|
52 svn remove $local_path/$f
|
|
53 fi
|
|
54 done
|
|
55
|
|
56 }
|
|
57
|
|
58 fatal() {
|
|
59 echo "$1"
|
|
60 exit 1;
|
|
61 }
|
|
62
|
|
63 pwd | grep 'libsanitizer$' || \
|
|
64 fatal "Run this script from libsanitizer dir"
|
|
65 get_upstream
|
|
66 CUR_REV=$(get_current_rev)
|
|
67 echo Current upstream revision: $CUR_REV
|
|
68 merge include/sanitizer include/sanitizer
|
|
69 merge lib/asan asan
|
|
70 merge lib/lsan lsan
|
|
71 merge lib/tsan/rtl tsan
|
|
72 merge lib/sanitizer_common sanitizer_common
|
|
73 merge lib/interception interception
|
|
74 merge lib/ubsan ubsan
|
|
75
|
|
76 # Need to merge lib/builtins/assembly.h file:
|
|
77 mkdir -p builtins
|
|
78 cp -v upstream/lib/builtins/assembly.h builtins/assembly.h
|
|
79
|
|
80 rm -rf upstream
|
|
81
|
|
82 # Update the MERGE file.
|
|
83 cat << EOF > MERGE
|
|
84 $CUR_REV
|
|
85
|
|
86 The first line of this file holds the svn revision number of the
|
|
87 last merge done from the master library sources.
|
|
88 EOF
|