libbacktrace: change PC variables from uint64_t to uintptr_t
[official-gcc.git] / libgo / merge.sh
blobcd2510bb76c189f675ad2eb29331e2f063829cc4
1 #!/bin/sh
3 # Copyright 2009 The Go Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style
5 # license that can be found in the LICENSE file.
7 # This script merges changes from the master copy of the Go library
8 # into the libgo library. This does the easy stuff; the hard stuff is
9 # left to the user.
11 # The file MERGE should hold the Git revision number of the last
12 # revision which was merged into these sources. Given that, and given
13 # the current sources, we can run the usual diff3 algorithm to merge
14 # all changes into our sources.
16 set -e
18 TMPDIR=${TMPDIR:-/tmp}
20 OLDDIR=${TMPDIR}/libgo-merge-old
21 NEWDIR=${TMPDIR}/libgo-merge-new
23 if ! test -f MERGE; then
24 echo 1>&2 "merge.sh: must be run in libgo source directory"
25 exit 1
28 rev=weekly
29 case $# in
30 1) ;;
31 2) rev=$2 ;;
33 echo 1>&2 "merge.sh: Usage: merge.sh git-repository [revision]"
34 exit 1
36 esac
38 repository=$1
40 old_rev=`sed 1q MERGE`
42 rm -rf ${OLDDIR}
43 git clone ${repository} ${OLDDIR}
44 (cd ${OLDDIR} && git checkout ${old_rev})
46 rm -rf ${NEWDIR}
47 git clone ${repository} ${NEWDIR}
48 (cd ${NEWDIR} && git checkout ${rev})
50 new_rev=`cd ${NEWDIR} && git log | sed 1q | sed -e 's/commit //'`
52 merge() {
53 name=$1
54 old=$2
55 new=$3
56 libgo=$4
57 if test -d ${new}; then
58 if ! test -d ${old}; then
59 if test -f ${old}; then
60 echo 1>&2 "merge.sh: ${name}: FILE BECAME DIRECTORY"
63 elif ! test -f ${new}; then
64 # The file does not exist in the new version.
65 if ! test -f ${old}; then
66 echo 1>&2 "merge.sh internal error no files $old $new"
67 exit 1
69 if ! test -f ${libgo}; then
70 # File removed in new version and libgo.
72 else
73 echo "merge.sh: ${name}: REMOVED"
74 rm -f ${libgo}
76 elif test -f ${old}; then
77 # The file exists in the old version.
78 if ! test -f ${libgo}; then
79 if ! cmp -s ${old} ${new}; then
80 echo "merge.sh: $name: skipping: exists in old and new git, but not in libgo"
82 return
84 if cmp -s ${old} ${libgo}; then
85 # The libgo file is unchanged from the old version.
86 if cmp -s ${new} ${libgo}; then
87 # File is unchanged from old to new version.
88 return
90 # Update file in libgo.
91 echo "merge.sh: $name: updating"
92 cp ${new} ${libgo}
93 else
94 # The libgo file has local changes.
95 set +e
96 diff3 -m -E ${libgo} ${old} ${new} > ${libgo}.tmp
97 status=$?
98 set -e
99 case $status in
101 echo "merge.sh: $name: updating"
102 mv ${libgo}.tmp ${libgo}
105 echo "merge.sh: $name: CONFLICTS"
106 mv ${libgo}.tmp ${libgo}
109 echo 1>&2 "merge.sh: $name: DIFF3 FAILURE"
111 esac
113 else
114 # The file does not exist in the old version.
115 if test -f ${libgo}; then
116 if ! cmp -s ${new} ${libgo}; then
117 echo 1>&2 "merge.sh: $name: IN NEW AND LIBGO BUT NOT OLD"
119 else
120 echo "merge.sh: $name: NEW"
121 dir=`dirname ${libgo}`
122 if ! test -d ${dir}; then
123 mkdir -p ${dir}
125 cp ${new} ${libgo}
130 echo ${rev} > VERSION
132 (cd ${NEWDIR}/src && find . -name '*.go' -print) | while read f; do
133 skip=false
134 case "$f" in
135 ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/test2json/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/codesign/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/quoted/* | ./cmd/internal/test2json/* | ./cmd/internal/sys/* | ./cmd/internal/traceviewer/* | ./cmd/vendor/golang.org/x/tools/* | ./cmd/vendor/golang.org/x/mod/* | ./cmd/vendor/golang.org/x/xerrors/* | ./cmd/vendor/golang.org/x/crypto/ed25519 | ./cmd/vendor/golang.org/x/sync/semaphore)
137 ./cmd/*)
138 skip=true
140 ./runtime/race/*)
141 skip=true
143 esac
144 if test "$skip" = "true"; then
145 continue
148 oldfile=${OLDDIR}/src/$f
149 newfile=${NEWDIR}/src/$f
150 libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
151 merge $f ${oldfile} ${newfile} ${libgofile}
152 done
154 (cd ${NEWDIR}/src && find . -name 'go.mod' -print) | while read f; do
155 oldfile=${OLDDIR}/src/$f
156 newfile=${NEWDIR}/src/$f
157 libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
158 merge $f ${oldfile} ${newfile} ${libgofile}
159 done
161 (cd ${NEWDIR}/src && find . -name 'modules.txt' -print) | while read f; do
162 oldfile=${OLDDIR}/src/$f
163 newfile=${NEWDIR}/src/$f
164 libgofile=go/$f
165 merge $f ${oldfile} ${newfile} ${libgofile}
166 done
168 (cd ${NEWDIR}/src && find . -name testdata -print) | while read d; do
169 skip=false
170 case "$d" in
171 ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/test2json/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/codesign/* | ./cmd/internal/diff/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/test2json/* | ./cmd/internal/sys/* | ./cmd/internal/traceviewer/* | ./cmd/vendor/golang.org/x/tools/*)
173 ./cmd/*)
174 skip=true
176 ./runtime/race/* | ./runtime/cgo/*)
177 skip=true
179 esac
180 if test "$skip" = "true"; then
181 continue
184 oldtd=${OLDDIR}/src/$d
185 newtd=${NEWDIR}/src/$d
186 libgotd=go/`echo $d | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'`
187 if ! test -d ${oldtd}; then
188 echo "merge.sh: $d: NEWDIR"
189 continue
191 (cd ${oldtd} && git ls-files .) | while read f; do
192 if test "`basename -- $f`" = ".gitignore"; then
193 continue
195 name=$d/$f
196 oldfile=${oldtd}/$f
197 newfile=${newtd}/$f
198 libgofile=${libgotd}/$f
199 merge ${name} ${oldfile} ${newfile} ${libgofile}
200 done
201 (cd ${newtd} && git ls-files .) | while read f; do
202 if test "`basename -- $f`" = ".gitignore"; then
203 continue
205 oldfile=${oldtd}/$f
206 if ! test -f ${oldfile}; then
207 name=$d/$f
208 newfile=${newtd}/$f
209 libgofile=${libgotd}/$f
210 merge ${name} ${oldfile} ${newfile} ${libgofile}
212 done
213 done
215 (cd ${NEWDIR}/misc/cgo && find . -type f -print) | while read f; do
216 oldfile=${OLDDIR}/misc/cgo/$f
217 newfile=${NEWDIR}/misc/cgo/$f
218 libgofile=misc/cgo/$f
219 merge $f ${oldfile} ${newfile} ${libgofile}
220 done
222 (cd ${OLDDIR}/src && find . -name '*.go' -print) | while read f; do
223 oldfile=${OLDDIR}/src/$f
224 newfile=${NEWDIR}/src/$f
225 libgofile=go/$f
226 if test -f ${newfile}; then
227 continue
229 if ! test -f ${libgofile}; then
230 continue
232 echo "merge.sh: ${libgofile}: REMOVED"
233 rm -f ${libgofile}
234 done
236 (cd ${OLDDIR}/misc/cgo && find . -type f -print) | while read f; do
237 oldfile=${OLDDIR}/misc/cgo/$f
238 newfile=${NEWDIR}/misc/cgo/$f
239 libgofile=misc/cgo/$f
240 if test -f ${newfile}; then
241 continue
243 if ! test -f ${libgofile}; then
244 continue
246 echo "merge.sh: ${libgofile}: REMOVED"
247 rm -f ${libgofile}
248 done
250 (echo ${new_rev}; sed -ne '2,$p' MERGE) > MERGE.tmp
251 mv MERGE.tmp MERGE