Diana Picus | 72189fd | 2016-05-23 19:32:46 +0300 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # This script removes a worktree environment for LLVM and all other projects: |
| 4 | # * it removes all the worktrees and corresponding build directories |
| 5 | # * it runs git worktree prune in all the repos |
| 6 | # * it DOES NOT remove the corresponding branch |
| 7 | |
| 8 | . llvm-common |
| 9 | |
| 10 | if [ "$1" = "" -o "$2" = "" ]; then |
| 11 | echo "Usage: $0 <llvm-repo-dir> <llvm-worktree-dir>" |
| 12 | exit 1 |
| 13 | fi |
| 14 | |
| 15 | llvm_repo_dir=$1 |
| 16 | llvm_worktree_dir=$2 |
| 17 | |
| 18 | if [ ! -d $llvm_repo_dir ]; then |
| 19 | echo "Couldn't find llvm repo in $llvm_repo_dir" |
| 20 | exit 1 |
| 21 | fi |
| 22 | |
| 23 | if [ ! -d $llvm_worktree_dir ]; then |
| 24 | echo "Couldn't find llvm worktree in $llvm_worktree_dir" |
| 25 | exit 1 |
| 26 | fi |
| 27 | |
| 28 | # Clean up the worktrees (if we remove the LLVM worktree dir, all the other |
| 29 | # worktrees are removed too, so we only need to prune the repos) |
| 30 | safe_run remove_worktree $llvm_repo_dir $llvm_worktree_dir |
| 31 | safe_run remove_worktree $llvm_repo_dir/../clang |
Diana Picus | 72189fd | 2016-05-23 19:32:46 +0300 | [diff] [blame] | 32 | safe_run remove_worktree $llvm_repo_dir/../compiler-rt |
| 33 | safe_run remove_worktree $llvm_repo_dir/../lld |
| 34 | safe_run remove_worktree $llvm_repo_dir/../libcxx |
| 35 | safe_run remove_worktree $llvm_repo_dir/../libcxxabi |
| 36 | safe_run remove_worktree $llvm_repo_dir/../libunwind |
| 37 | safe_run remove_worktree $llvm_repo_dir/../lldb |
| 38 | safe_run remove_worktree $llvm_repo_dir/../test-suite |
| 39 | |
| 40 | # Clean up build directories too |
| 41 | env_root_dir=`readlink -m $llvm_worktree_dir/../` |
| 42 | echo "Removing everything in $env_root_dir" |
| 43 | safe_run rm -rf $env_root_dir |