merge.sh 1.9 KB

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