-
Notifications
You must be signed in to change notification settings - Fork 10
/
swiftbuild.sh
executable file
·197 lines (161 loc) · 5.53 KB
/
swiftbuild.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
#!/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"
sudo dnf install -y --best --allowerasing \
git \
cmake \
ninja-build \
clang \
re2c \
uuid-devel \
libuuid-devel \
icu \
libicu \
libicu-devel \
libbsd-devel \
libedit-devel \
libxml2-devel \
libsqlite3x-devel \
swig \
python-libs \
ncurses-devel \
python-devel \
python-pkgconfig
#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