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