blob: 3429b895fc0e708e1c5db8304a2c8624deb6895d (
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
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
271
272
273
274
275
276
277
278
279
|
#!/usr/bin/env bash
# This script keeps track of all projects that are linked to the llvm src
# directory. It can detect, enable, disable and map to specific projects,
# so different builds get to see the source dir as they saw originally.
. llvm-common
safe_run verify_env
prog=`basename $0`
syntax() {
echo "Syntax: $prog [clang|lldb|lld|rt|libs|all|none] {+/-}[c|x|r|k|d|l|a|u|t]"
echo " no args: List linked projects"
echo " clang: Clang + Clang Tools Extra"
echo " lldb: Clang + lldb"
echo " lld: Clang + lld"
echo " rt: Clang + compiler-rt"
echo " libs: Clang + libcxx + libcxxabi + libunwind"
echo " all: Link all projects"
echo " none: Unlink all projects"
echo " {+/-}: link / unlink projects (default: link)"
echo " c Clang"
echo " x Clang Tools Extra"
echo " r Compiler-rt"
echo " k lld"
echo " d lldb"
echo " l libcxx"
echo " a libcxxabi"
echo " u libunwind"
echo " t test-suite"
echo " Long options unlink everything before proceeding. Use the short options for fine-tuning"
}
# Dirs and links into LLVM
clang_dir=clang
clang_link=tools/clang
clang_extra_dir=clang-tools-extra
clang_extra_link=tools/clang/tools/extra
rt_dir=compiler-rt
rt_link=projects/compiler-rt
libcxx_dir=libcxx
libcxx_link=projects/libcxx
libcxxabi_dir=libcxxabi
libcxxabi_link=projects/libcxxabi
libunwind_dir=libunwind
libunwind_link=projects/libunwind
lld_dir=lld
lld_link=tools/lld
lldb_dir=lldb
lldb_link=tools/lldb
tests_dir=test-suite
tests_link=projects/test-suite
# Check if link exists
has_link() {
link=$1
[ -d "$LLVM_SRC/$link" ]
}
# Initialise status
init() {
link=$1
if has_link $link; then
echo "ON";
else
echo "OFF"
fi
}
# Link/Unlink upon need
update() {
dir=$1
link=$2
need=$3
if [ "$need" = ON ]; then
if ! has_link $link; then
pushdq $LLVM_SRC
branch=`get_branch`
popdq
safe_run add_worktree $LLVM_ROOT/repos/$dir $LLVM_SRC/$link $branch
fi
else
safe_run remove_worktree $LLVM_ROOT/repos/$dir $LLVM_SRC/$link
fi
}
# Enable/disable projects in the CMake cache
update_build_dirs() {
if [ -d $LLVM_BLD/../build ]; then
safe_run cmake $* $LLVM_BLD/../build
fi
if [ -d $LLVM_BLD/../debug ]; then
safe_run cmake $* $LLVM_BLD/../debug
fi
}
# Lists linked projects
list_all() {
echo "Projects linked:"
has_link $clang_link && echo " + Clang"
has_link $clang_extra_link && echo " + Clang Tools Extra"
has_link $rt_link && echo " + Compiler-RT"
has_link $libcxx_link && echo " + LibC++"
has_link $libcxxabi_link && echo " + LibC++abi"
has_link $libunwind_link && echo " + LibUnwind"
has_link $lld_link && echo " + LLD"
has_link $lldb_link && echo " + LLDB"
has_link $tests_link && echo " + Test-Suite"
echo
}
need_all() {
need=$1
clang=$need
clang_extra=$need
rt=$need
libcxx=$need
libcxxabi=$need
libunwind=$need
lld=$need
lldb=$need
tests=$need
}
# No args, list
if [ "$1" = "" ]; then
echo "Use $prog -h for options"
echo
list_all
exit
fi
# Need/not need
clang=`init $clang_link`
clang_extra=`init $clang_extra_link`
rt=`init $rt_link`
libcxx=`init $libcxx_link`
libcxxabi=`init $libcxxabi_link`
libunwind=`init $libunwind_link`
lld=`init $lld_link`
lldb=`init $lldb_link`
tests=`init $tests_link`
# See if the first option is one of the long options
opt=$1
case $opt in
clang)
need_all OFF
clang=ON
clang_extra=ON
shift
;;
lldb)
need_all OFF
clang=ON
lldb=ON
shift
;;
lld)
need_all OFF
clang=ON
lld=ON
shift
;;
rt)
need_all OFF
clang=ON
rt=ON
shift
;;
libs)
need_all OFF
clang=ON
libcxx=ON
libcxxabi=ON
libunwind=ON
shift
;;
all)
need_all ON
shift
;;
none)
need_all OFF
shift
;;
list)
list_all
exit
;;
-h)
syntax
exit
;;
esac
# Parse short options, if any
while ! test -z $1; do
opt=$1
sign=${opt:0:1}
flag=ON
if [ "$sign" = "-" ]; then
flag=OFF
opt=${opt:1}
elif [ "$sign" = "+" ]; then
opt=${opt:1}
else
# Doesn't look like one of our short options
syntax
exit
fi
case $opt in
c)
clang=$flag
;;
x)
clang_extra=$flag
;;
r)
rt=$flag
;;
k)
lld=$flag
;;
d)
lldb=$flag
;;
l)
libcxx=$flag
;;
a)
libcxxabi=$flag
;;
u)
libunwind=$flag
;;
t)
tests=$flag
;;
*)
syntax
exit
esac
shift
done
# clang and clang-tools-extra have a special relationship: we can't enable
# clang-tools-extra without enabling clang, and we also can't disable clang
# without also disabling clang-tools-extra
if [ "$clang_extra" = ON -a "$clang" = OFF ]; then
echo "Can't have Clang Tools Extra without Clang! Try to add +c or -x"
exit
fi
# Update links
update $tests_dir $tests_link $tests
update $lldb_dir $lldb_link $lldb
update $lld_dir $lld_link $lld
update $libunwind_dir $libunwind_link $libunwind
update $libcxxabi_dir $libcxxabi_link $libcxxabi
update $libcxx_dir $libcxx_link $libcxx
update $rt_dir $rt_link $rt
update $clang_dir $clang_link $clang
update $clang_extra_dir $clang_extra_link $clang_extra
update_build_dirs -DLLVM_TOOL_LLDB_BUILD=$lldb \
-DLLVM_TOOL_LLD_BUILD=$lld \
-DLLVM_TOOL_LIBUNWIND_BUILD=$libunwind \
-DLLVM_TOOL_LIBCXXABI_BUILD=$libcxxabi \
-DLLVM_TOOL_LIBCXX_BUILD=$libcxx \
-DLLVM_TOOL_COMPILER_RT_BUILD=$rt \
-DLLVM_TOOL_CLANG_BUILD=$clang \
-DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=$clang_extra
list_all
|