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