aboutsummaryrefslogtreecommitdiff
path: root/helpers/llvm-projs
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/llvm-projs')
-rwxr-xr-xhelpers/llvm-projs165
1 files changed, 47 insertions, 118 deletions
diff --git a/helpers/llvm-projs b/helpers/llvm-projs
index 3429b89..288fc8c 100755
--- a/helpers/llvm-projs
+++ b/helpers/llvm-projs
@@ -1,14 +1,10 @@
#!/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.
+# Shorthand script for adding/removing llvm subprojects. It has a simpler
+# interface than llvm.py, but it calls it to do the actual work.
-. llvm-common
-
-safe_run verify_env
-
-prog=`basename $0`
+prog=$(basename $0)
+progdir=$(dirname $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"
@@ -32,86 +28,6 @@ syntax() {
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
@@ -125,24 +41,17 @@ need_all() {
tests=$need
}
+llvmtool=$progdir/../scripts/llvm.py
+
# No args, list
if [ "$1" = "" ]; then
echo "Use $prog -h for options"
echo
- list_all
+ python $llvmtool projects
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`
+need_all UNDEF
# See if the first option is one of the long options
opt=$1
@@ -188,7 +97,7 @@ case $opt in
shift
;;
list)
- list_all
+ python $llvmtool projects
exit
;;
-h)
@@ -257,23 +166,43 @@ if [ "$clang_extra" = ON -a "$clang" = OFF ]; then
exit
fi
+add=""
+remove=""
+
+update() {
+ project="$1"
+ flag="$2"
+
+ case $flag in
+ ON)
+ add="$add $project"
+ ;;
+ OFF)
+ remove="$remove $project"
+ ;;
+ UNDEF)
+ # Don't care
+ ;;
+ esac
+}
# 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
+update "test-suite" $tests
+update "lldb" $lldb
+update "lld" $lld
+update "libunwind" $libunwind
+update "libcxxabi" $libcxxabi
+update "libcxx" $libcxx
+update "compiler-rt" $rt
+update "clang" $clang
+update "clang-tools-extra" $clang_extra
+
+if [ "$add" != "" ]; then
+ add="-a $add"
+fi
+
+if [ "$remove" != "" ]; then
+ remove="-r $remove"
+fi
+
+python $llvmtool projects $add $remove