aboutsummaryrefslogtreecommitdiff
path: root/helpers/.llvm-env-remove
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2016-05-23 19:32:46 +0300
committerDiana Picus <diana.picus@linaro.org>2016-06-15 12:27:43 +0300
commit72189fd702d00d45714f98857a88159097933b5c (patch)
tree285a34a287a234fcc1e558febb0f036e0aa112ba /helpers/.llvm-env-remove
parent488ec270d3bb2e34837ccf25431d73b5c5d68dc3 (diff)
Use git worktree in the LLVM helper scripts
This commit adds a new script, llvm-env, which sets up the environment for working with LLVM. It looks for an environment variable LLVM_ROOT and tries to create the following hierarchy: $LLVM_ROOT `- repos | `- llvm | `- clang | `- compiler-rt | [...] `- <branch1> | `- llvm | `- build | `- debug `- <branch2> | `- llvm | `- build | `- debug [...] The $LLVM_ROOT/repos directory contains all the repositories, as checked out by llvm-prepare, and will always track master. For other branches, llvm-env <branch_name> will create a new directory, $LLVM_ROOT/<branch_name>, and will add an llvm worktree directory there. If -d is passed, it will also create a debug directory there, otherwise it will create a build directory. Notice that these 2 can live in parallel, and we can switch between them at any time by invoking llvm-env. It will set LLVM_SRC and LLVM_BLD accordingly, and also modify the path to point to the binaries in LLVM_BLD. The other scripts will now work with the LLVM_SRC and LLVM_BLD set by llvm-env in the current shell. Because llvm-env controls whether or not we're doing a debug build, llvm-build will no longer take a -d flag (it will instead look after a LLVM_DEBUG environment variable, also set by llvm-env). There are changes in llvm-projs, too, because now it no longer creates links - instead it creates worktree directories in the corresponding $LLVM_ROOT/<branch>/llvm. Other scripts have also been updated accordingly. To make things easier, here are some of the changes that I had to make that are not particularly important for the review (pretty mechanical stuff): * Moved function has() from llvm-branch to llvm-common, so I could reuse it * Because of this, I had to rename the has() function in llvm-projs to has_link(), which is actually a better name for it anyway * Disable the checks for LLVM_SRC and LLVM_BLD in llvm-common Change-Id: I9e02f6d8e0c803e79838845013b81331dffba99c
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