aboutsummaryrefslogtreecommitdiff
path: root/helpers/.llvm-env-remove
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/.llvm-env-remove')
-rwxr-xr-xhelpers/.llvm-env-remove44
1 files changed, 44 insertions, 0 deletions
diff --git a/helpers/.llvm-env-remove b/helpers/.llvm-env-remove
new file mode 100755
index 0000000..fba6deb
--- /dev/null
+++ b/helpers/.llvm-env-remove
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+
+# This script removes a worktree environment for LLVM and all other projects:
+# * it removes all the worktrees and corresponding build directories
+# * it runs git worktree prune in all the repos
+# * it DOES NOT remove the corresponding branch
+
+. llvm-common
+
+if [ "$1" = "" -o "$2" = "" ]; then
+ echo "Usage: $0 <llvm-repo-dir> <llvm-worktree-dir>"
+ exit 1
+fi
+
+llvm_repo_dir=$1
+llvm_worktree_dir=$2
+
+if [ ! -d $llvm_repo_dir ]; then
+ echo "Couldn't find llvm repo in $llvm_repo_dir"
+ exit 1
+fi
+
+if [ ! -d $llvm_worktree_dir ]; then
+ echo "Couldn't find llvm worktree in $llvm_worktree_dir"
+ exit 1
+fi
+
+# Clean up the worktrees (if we remove the LLVM worktree dir, all the other
+# worktrees are removed too, so we only need to prune the repos)
+safe_run remove_worktree $llvm_repo_dir $llvm_worktree_dir
+safe_run remove_worktree $llvm_repo_dir/../clang
+safe_run remove_worktree $llvm_repo_dir/../clang-tools-extra
+safe_run remove_worktree $llvm_repo_dir/../compiler-rt
+safe_run remove_worktree $llvm_repo_dir/../lld
+safe_run remove_worktree $llvm_repo_dir/../libcxx
+safe_run remove_worktree $llvm_repo_dir/../libcxxabi
+safe_run remove_worktree $llvm_repo_dir/../libunwind
+safe_run remove_worktree $llvm_repo_dir/../lldb
+safe_run remove_worktree $llvm_repo_dir/../test-suite
+
+# Clean up build directories too
+env_root_dir=`readlink -m $llvm_worktree_dir/../`
+echo "Removing everything in $env_root_dir"
+safe_run rm -rf $env_root_dir