summaryrefslogtreecommitdiffstats
path: root/llgo/update_third_party.sh
blob: 29b13e902a14ceb90b28867e0559c4d6db7a0321 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/sh -e

scriptpath=$(readlink -f "$0")
llgosrcdir=$(dirname "$scriptpath")
cd $llgosrcdir

gofrontendrepo=https://code.google.com/p/gofrontend
gofrontendrev=15a24202fa42

gccrepo=svn://gcc.gnu.org/svn/gcc/trunk
gccrev=219477

gotoolsrepo=https://go.googlesource.com/tools
gotoolsrev=d4e70101500b43ffe705d4c45e50dd4f1c8e3b2e

linerrepo=https://github.com/peterh/liner.git
linerrev=1bb0d1c1a25ed393d8feb09bab039b2b1b1fbced

tempdir=$(mktemp -d /tmp/update_third_party.XXXXXX)
gofrontenddir=$tempdir/gofrontend
gotoolsdir=$tempdir/go.tools
linerdir=third_party/liner

rm -rf third_party
mkdir -p third_party/gofrontend third_party/gotools

# --------------------- gofrontend ---------------------

hg clone -r $gofrontendrev $gofrontendrepo $gofrontenddir

cp -r $gofrontenddir/LICENSE $gofrontenddir/libgo third_party/gofrontend

# Apply a diff that eliminates use of the unnamed struct extension beyond what
# -fms-extensions supports.
(cd third_party/gofrontend && patch -p1) < libgo-noext.diff
# Apply a diff that disables testing of packages known to fail.
(cd third_party/gofrontend && patch -p1) < libgo-check-failures.diff
find third_party/gofrontend -name '*.orig' -exec rm \{\} \;

# Remove GPL licensed files.
rm \
  third_party/gofrontend/libgo/testsuite/libgo.testmain/testmain.exp \
  third_party/gofrontend/libgo/testsuite/lib/libgo.exp \
  third_party/gofrontend/libgo/testsuite/config/default.exp

# --------------------- gcc ---------------------

# Some dependencies are stored in the gcc repository.
# TODO(pcc): Ask iant about mirroring these dependencies into gofrontend.

for f in config-ml.in depcomp install-sh ltmain.sh missing ; do
  svn cat -r $gccrev $gccrepo/$f > third_party/gofrontend/$f
done

mkdir -p third_party/gofrontend/include third_party/gofrontend/libgcc

# Copy in our versions of GCC files.
cp include/dwarf2.h third_party/gofrontend/include/
cp include/filenames.h third_party/gofrontend/include/
cp include/unwind-pe.h third_party/gofrontend/libgcc/

# Note: this expects the llgo source tree to be located at llvm/tools/llgo.
cp ../../autoconf/config.guess third_party/gofrontend/
cp ../../autoconf/config.sub third_party/gofrontend/

for d in libbacktrace libffi ; do
  svn export -r $gccrev $gccrepo/$d third_party/gofrontend/$d
done

# Remove GPL licensed files, and files that confuse our license check.
rm \
  third_party/gofrontend/libffi/ChangeLog \
  third_party/gofrontend/libffi/doc/libffi.texi \
  third_party/gofrontend/libffi/msvcc.sh \
  third_party/gofrontend/libffi/testsuite/config/default.exp \
  third_party/gofrontend/libffi/testsuite/libffi.call/call.exp \
  third_party/gofrontend/libffi/testsuite/libffi.complex/complex.exp \
  third_party/gofrontend/libffi/testsuite/libffi.go/go.exp \
  third_party/gofrontend/libffi/testsuite/libffi.special/special.exp \
  third_party/gofrontend/libffi/testsuite/lib/libffi.exp \
  third_party/gofrontend/libffi/testsuite/lib/target-libpath.exp \
  third_party/gofrontend/libffi/testsuite/lib/wrapper.exp

# The build requires these files to exist.
touch \
  third_party/gofrontend/include/dwarf2.def \
  third_party/gofrontend/libffi/doc/libffi.texi

# --------------------- go.tools ---------------------

git clone $gotoolsrepo $gotoolsdir
(cd $gotoolsdir && git checkout $gotoolsrev)

cp -r $gotoolsdir/LICENSE $gotoolsdir/go third_party/gotools

# Vendor the go.tools repository.
find third_party/gotools -name '*.go' | xargs sed -i -e \
  's,"golang.org/x/tools/,"llvm.org/llgo/third_party/gotools/,g'

# --------------------- peterh/liner -----------------

git clone $linerrepo $linerdir
(cd $linerdir && git checkout $linerrev && rm -rf .git)

# --------------------- license check ---------------------

# We don't want any GPL licensed code without an autoconf/libtool
# exception, or any GPLv3 licensed code.

for i in `grep -lr 'General Public License' third_party` ; do
  if grep -q 'configuration script generated by Autoconf, you may include it under' $i || \
     grep -q 'is built using GNU Libtool, you may include this file under the' $i ; then
    :
  else
    echo "$i: license check failed"
    exit 1
  fi
done

if grep -qr GPLv3 third_party ; then
  echo "`grep -lr GPLv3 third_party`: license check failed"
  exit 1
fi

rm -rf $tempdir
OpenPOWER on IntegriCloud