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-pull b/helpers/git-pull
index 3dbd3e1..6db6029 100755
--- a/helpers/git-pull
+++ b/helpers/git-pull
@@ -4,7 +4,7 @@
# not to keep the prefix. If the branch already exists, try to merge. If not,
# check out from origin.
#
-# Syntax: git-pull linaro-local/[branch] -f
+# Syntax: git-pull linaro-local/[branch]
. llvm-common
@@ -12,10 +12,6 @@
if [[ $branch = '' ]]; then
branch=`get_branch`
fi
-force=$2
-if [[ $force != '-f' ]]; then
- force=
-fi
if [[ $branch = 'master' ]]; then
echo "Can't pull the master branch."
@@ -37,17 +33,9 @@
# If the branch exists already, merge
if git branch | grep -q $branch; then
- if [[ $force = '-f' ]]; then
- echo " + Force check out $branch"
- safe_run git checkout master
- safe_run git branch -D $branch
- safe_run git checkout -b $branch origin/$prefix$branch
- exit 0
- fi
-
echo " + Merging the origin branch..."
if not git merge --ff-only origin/$prefix$branch; then
- echo "Error merging the branch. Use -f to force."
+ echo "Error merging the branch."
exit 1
fi
# If not, just check out the branch