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
diff --git a/helpers/git-svn-commit b/helpers/git-svn-commit
index 49cb0d3..f27bb77 100755
--- a/helpers/git-svn-commit
+++ b/helpers/git-svn-commit
@@ -50,11 +50,11 @@
else
echo "Not in base dir, won't try anything. But if you"
echo "saw the message 'resource out of date', remove"
- echo "the .git/svn directory and trying again."
+ echo "the .git/svn directory and try again."
exit 1
fi
fi
# Refresh / rebase to avoid future conflicts
safe_run git-refresh
-safe_run git-rebase-all
+safe_run git-rebase