annotate libsanitizer/merge.sh @ 158:494b0b89df80 default tip

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