aboutsummaryrefslogtreecommitdiff
path: root/helpers/llvm-projs
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/llvm-projs')
-rwxr-xr-xhelpers/llvm-projs107
1 files changed, 67 insertions, 40 deletions
diff --git a/helpers/llvm-projs b/helpers/llvm-projs
index f9cc706..3429b89 100755
--- a/helpers/llvm-projs
+++ b/helpers/llvm-projs
@@ -6,6 +6,8 @@
. 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]"
@@ -51,18 +53,18 @@ tests_dir=test-suite
tests_link=projects/test-suite
# Check if link exists
-has() {
+has_link() {
link=$1
- [ -s "$LLVM_SRC/$link" ]
+ [ -d "$LLVM_SRC/$link" ]
}
# Initialise status
init() {
link=$1
- if has $link; then
- echo "true";
+ if has_link $link; then
+ echo "ON";
else
- echo "false"
+ echo "OFF"
fi
}
@@ -71,25 +73,42 @@ update() {
dir=$1
link=$2
need=$3
- if $need; then
- ln -sf $LLVM_SRC/../$dir $LLVM_SRC/$link
+ 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
- rm -f $LLVM_SRC/$link
+ 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 and quit
+# Lists linked projects
list_all() {
echo "Projects linked:"
- has $clang_link && echo " + Clang"
- has $clang_extra_link && echo " + Clang Tools Extra"
- has $rt_link && echo " + Compiler-RT"
- has $libcxx_link && echo " + LibC++"
- has $libcxxabi_link && echo " + LibC++abi"
- has $libunwind_link && echo " + LibUnwind"
- has $lld_link && echo " + LLD"
- has $lldb_link && echo " + LLDB"
- has $tests_link && echo " + Test-Suite"
+ 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
}
@@ -129,43 +148,43 @@ tests=`init $tests_link`
opt=$1
case $opt in
clang)
- need_all false
- clang=true
- clang_extra=true
+ need_all OFF
+ clang=ON
+ clang_extra=ON
shift
;;
lldb)
- need_all false
- clang=true
- lldb=true
+ need_all OFF
+ clang=ON
+ lldb=ON
shift
;;
lld)
- need_all false
- clang=true
- lld=true
+ need_all OFF
+ clang=ON
+ lld=ON
shift
;;
rt)
- need_all false
- clang=true
- rt=true
+ need_all OFF
+ clang=ON
+ rt=ON
shift
;;
libs)
- need_all false
- clang=true
- libcxx=true
- libcxxabi=true
- libunwind=true
+ need_all OFF
+ clang=ON
+ libcxx=ON
+ libcxxabi=ON
+ libunwind=ON
shift
;;
all)
- need_all true
+ need_all ON
shift
;;
none)
- need_all false
+ need_all OFF
shift
;;
list)
@@ -183,9 +202,9 @@ while ! test -z $1; do
opt=$1
sign=${opt:0:1}
- flag=true
+ flag=ON
if [ "$sign" = "-" ]; then
- flag=false
+ flag=OFF
opt=${opt:1}
elif [ "$sign" = "+" ]; then
opt=${opt:1}
@@ -233,7 +252,7 @@ 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" = true -a "$clang" = false ]; then
+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
@@ -249,4 +268,12 @@ 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