Improve BUILDDIR handling with symlinks

If BUILDDIR is a local symlink to another directory in the same parent
directory (out -> out.angler), then using out and .. as relative paths
to get back and forth work.

But if BUILDDIR is a symlink to another directory altogether (out ->
/mnt/sdd/out.master), then we shouldn't be relying on relative paths (so
that the source directory can still be moved).

Change-Id: I946c8116090410ab2b935eafba9b6e96f5f2f1dd
diff --git a/bootstrap.bash b/bootstrap.bash
index c4c7e35..62c429c 100755
--- a/bootstrap.bash
+++ b/bootstrap.bash
@@ -8,11 +8,7 @@
     echo "error: To use BUILDDIR, run from the source directory"
     exit 1
   fi
-  if [[ ${ORIG_SRCDIR:0:1} == '/' ]]; then
-    export BUILDDIR=$PWD
-  else
-    export BUILDDIR=$(python -c "import os; print os.path.relpath('.', '$ORIG_SRCDIR')")
-  fi
+  export BUILDDIR=$("${ORIG_SRCDIR}/build/soong/reverse_path.py" "$ORIG_SRCDIR")
   cd $ORIG_SRCDIR
 fi
 if [[ -z "$BUILDDIR" ]]; then
@@ -49,11 +45,7 @@
       exit 1
     fi
 
-    if [[ ${BUILDDIR:0:1} == '/' ]]; then
-      export SRCDIR_FROM_BUILDDIR=$PWD
-    else
-      export SRCDIR_FROM_BUILDDIR=$(python -c "import os; print os.path.relpath('.', '$BUILDDIR')")
-    fi
+    export SRCDIR_FROM_BUILDDIR=$(build/soong/reverse_path.py "$BUILDDIR")
 
     sed -e "s|@@BuildDir@@|${BUILDDIR}|" \
         -e "s|@@SrcDirFromBuildDir@@|${SRCDIR_FROM_BUILDDIR}|" \