-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathswiftbuild-centos7.sh
executable file
·270 lines (227 loc) · 10.3 KB
/
swiftbuild-centos7.sh
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#!/bin/sh
BUILDROOT=~/tmp/swiftbuild
declare -a SWIFTREPOS=(\
"https://github.com/apple/swift.git swift" \
"https://github.com/apple/swift-llvm.git llvm" \
"https://github.com/apple/swift-clang.git clang" \
"https://github.com/apple/swift-lldb.git lldb" \
"https://github.com/apple/swift-cmark.git cmark" \
"https://github.com/apple/swift-llbuild.git llbuild" \
"https://github.com/apple/swift-package-manager.git swiftpm" \
"https://github.com/apple/swift-corelibs-xctest.git swift-corelibs-xctest" \
"https://github.com/apple/swift-corelibs-foundation.git swift-corelibs-foundation"\
"https://github.com/apple/swift-corelibs-libdispatch.git swift-corelibs-libdispatch"\
)
BUILDTHREADS=2
NOW=`date +%Y-%m-%d--%H:%M:%S`
THISDIR="`dirname \"$0\"`" # relative
THISDIR="`( pushd \"$THISDIR\" >/dev/null && pwd )`" # absolutized and normalized
if [ -z "$THISDIR" ] ; then
# error; for some reason, the path is not accessible
# to the script (e.g. permissions re-evaled after suid)
exit 1 # fail
fi
if [ $# -lt 1 ]
then
echo "Usage : $0 [reset|clean|setup|update|build]"
exit
fi
case "$1" in
"reset" ) echo "reset build enviroment"
rm -rf $BUILDROOT
mkdir -p $BUILDROOT
mkdir -p $BUILDROOT/package
mkdir -p $BUILDROOT/symroot
mkdir -p $BUILDROOT/build
echo "reset done"
;;
"setup" ) echo "Setup build enviroment"
#install epel-release, wget
sudo yum -y install epel-release wget
#get updated packages from Fedora
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/b/binutils-2.26-18.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/c/clang-3.8.0-1.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/c/clang-devel-3.8.0-1.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/c/clang-libs-3.8.0-1.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/c/cpp-6.1.1-2.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/g/gcc-6.1.1-2.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/g/gcc-c++-6.1.1-2.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/g/glibc-2.23.1-7.fc24.i686.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/g/glibc-2.23.1-7.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/g/glibc-all-langpacks-2.23.1-7.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/g/glibc-common-2.23.1-7.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/g/glibc-devel-2.23.1-7.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/g/glibc-headers-2.23.1-7.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/i/isl-0.14-5.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/l/libgcc-6.1.1-2.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/l/libgomp-6.1.1-2.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/l/libmpc-1.0.2-5.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/l/libstdc++-6.1.1-2.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/l/libstdc++-devel-6.1.1-2.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/l/llvm-3.8.0-1.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/l/llvm-devel-3.8.0-1.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/l/llvm-libs-3.8.0-1.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/m/mpfr-3.1.4-1.fc24.x86_64.rpm
wget https://dl.fedoraproject.org/pub/fedora/linux/releases/24/Everything/x86_64/os/Packages/l/libtool-2.4.6-11.fc24.x86_64.rpm
wget https://copr-be.cloud.fedoraproject.org/results/lebauce/Darling/fedora-22-x86_64/libkqueue-2.0.1-1/libkqueue-2.0.1-1.x86_64.rpm
wget https://copr-be.cloud.fedoraproject.org/results/lebauce/Darling/fedora-22-x86_64/libkqueue-2.0.1-1/libkqueue-devel-2.0.1-1.x86_64.rpm
#install binutils
sudo yum install -y binutils-2.26-18.fc24.x86_64.rpm
#install development tools
sudo yum install -y clang-3.8.0-1.fc24.x86_64.rpm \
clang-devel-3.8.0-1.fc24.x86_64.rpm \
clang-libs-3.8.0-1.fc24.x86_64.rpm \
cpp-6.1.1-2.fc24.x86_64.rpm \
gcc-6.1.1-2.fc24.x86_64.rpm \
gcc-c++-6.1.1-2.fc24.x86_64.rpm \
glibc-2.23.1-7.fc24.i686.rpm \
glibc-2.23.1-7.fc24.x86_64.rpm \
glibc-all-langpacks-2.23.1-7.fc24.x86_64.rpm \
glibc-common-2.23.1-7.fc24.x86_64.rpm \
glibc-devel-2.23.1-7.fc24.x86_64.rpm \
glibc-headers-2.23.1-7.fc24.x86_64.rpm \
isl-0.14-5.fc24.x86_64.rpm \
libgcc-6.1.1-2.fc24.x86_64.rpm \
libgomp-6.1.1-2.fc24.x86_64.rpm \
libmpc-1.0.2-5.fc24.x86_64.rpm \
libstdc++-6.1.1-2.fc24.x86_64.rpm \
libstdc++-devel-6.1.1-2.fc24.x86_64.rpm \
llvm-3.8.0-1.fc24.x86_64.rpm \
llvm-devel-3.8.0-1.fc24.x86_64.rpm \
llvm-libs-3.8.0-1.fc24.x86_64.rpm \
mpfr-3.1.4-1.fc24.x86_64.rpm \
libtool-2.4.6-11.fc24.x86_64.rpm \
libkqueue-2.0.1-1.x86_64.rpm
libkqueue-devel-2.0.1-1.x86_64.rpm
#install other required packages
sudo yum install -y \
git \
cmake \
cmake3 \
ninja-build \
re2c \
uuid-devel \
libuuid-devel \
icu \
libicu \
libicu-devel \
libbsd-devel \
libedit-devel \
libxml2-devel \
sqlite-devel \
swig \
python-libs \
ncurses-devel \
python-devel \
pkgconfig \
autoconf \
automake
#substitute cmake3 for cmake
sudo mv /usr/bin/cmake /usr/bin/cmake2
sudo ln -s /usr/bin/cmake3 /usr/bin/cmake
#substitute ld.gold for ld
sudo rm /etc/alternatives/ld
sudo ln -s /usr/bin/ld.gold /etc/alternatives/ld
#fix the missing libc6 references
#pushd /usr/include
# sudo ln -s . x86_64-linux-gnu
#popd
# Make sure the build root directory is present.
mkdir -p $BUILDROOT
mkdir -p $BUILDROOT/package
mkdir -p $BUILDROOT/symroot
mkdir -p $BUILDROOT/build
pushd $BUILDROOT
for repo in "${SWIFTREPOS[@]}"; do
repodir=$BUILDROOT/`echo $repo | cut -d " " -f 2`
if [ ! -d "$repodir" ] ; then
git clone $repo
fi
done
if [ ! -d ~/tmp/swiftbuild/ninja ] ; then
git clone https://github.com/martine/ninja.git
fi
if [ ! -f /usr/bin/ninja ] ; then
if [ -f /usr/bin/ninja-build ] ; then
sudo ln -s /usr/bin/ninja-build /usr/bin/ninja
fi
fi
popd
;;
"update" ) echo "updating repositories"
mkdir -p $BUILDROOT
mkdir -p $BUILDROOT/package
mkdir -p $BUILDROOT/symroot
mkdir -p $BUILDROOT/build
for repo in "${SWIFTREPOS[@]}"; do
repodir=$BUILDROOT/`echo $repo | cut -d " " -f 2`
if [ -d "$repodir" ] ; then
pushd $repodir
git pull
popd
fi
done
if [ -d ~/tmp/swiftbuild/ninja ] ; then
pushd ~/tmp/swiftbuild/ninja
git pull
popd
fi
mkdir -p $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib
mkdir -p $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib64/python2.7
if [ ! -d $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib/python2.7 ] ; then
if [ -d $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib64/python2.7 ] ; then
ln -s $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib64/python2.7 $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib/python2.7
fi
fi
;;
"clean" ) echo "clean build"
mkdir -p $BUILDROOT
mkdir -p $BUILDROOT/package
mkdir -p $BUILDROOT/symroot
mkdir -p $BUILDROOT/build
rm -rf $BUILDROOT/build/*
rm -rf $BUILDROOT/package/*
rm -rf $BUILDROOT/symroot/*
;;
"build" ) echo "build"
mkdir -p $BUILDROOT
mkdir -p $BUILDROOT/package
mkdir -p $BUILDROOT/symroot
if [ -f "$BUILDROOT/package/swift-linux-x86_64-fedora-$NOW.tgz" ] ; then
rm "$BUILDROOT/package/swift-linux-x86_64-fedora-$NOW.tgz"
fi
mkdir -p $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib
mkdir -p $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib64/python2.7
if [ ! -d $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib/python2.7 ] ; then
if [ -d $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib64/python2.7 ] ; then
ln -s $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib64/python2.7 $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib/python2.7
fi
fi
pushd $BUILDROOT/swift
utils/build-script --preset-file=$THISDIR/linuxpreset.ini \
--preset=buildbot_linux_build_fedora23 \
install_destdir="$BUILDROOT/package" \
install_symroot="$BUILDROOT/symroot" \
installable_package="$BUILDROOT/package/swift-linux-x86_64-fedora-$NOW.tgz" \
build_threads=$BUILDTHREADS
popd
;;
"patch" ) echo "patch"
mkdir -p $BUILDROOT
mkdir -p $BUILDROOT/package
mkdir -p $BUILDROOT/symroot
if [ -f "$BUILDROOT/package/swift-linux-x86_64-fedora-$NOW.tgz" ] ; then
rm "$BUILDROOT/package/swift-linux-x86_64-fedora-$NOW.tgz"
fi
mkdir -p $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib
mkdir -p $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib64/python2.7
if [ ! -d $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib/python2.7 ] ; then
if [ -d $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib64/python2.7 ] ; then
ln -s $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib64/python2.7 $BUILDROOT/build/buildbot_linux/lldb-linux-x86_64/lib/python2.7
fi
fi
echo "patched ";
;;
*) echo "Unrecognised command: $1"
;;
esac