Change interface for llvm-projs and llvm-sync

llvm-projs and llvm-sync used to have very inconsistent interfaces. This commit
updates the interfaces so that llvm-sync only synchronizes the repos that are
linked into the tree by llvm-projs (this makes it consistent with llvm-branch
and other scripts) and also revamps the interface provided by llvm-projs to
allow some long options for projects that are frequently used together as well
as short options for fine tuning whether or not to link each project.

Change-Id: Iffdbc8d7956473d09c8161d6fb773c530e5b4d79
diff --git a/helpers/llvm-sync b/helpers/llvm-sync
index 5d5cb27..0374221 100755
--- a/helpers/llvm-sync
+++ b/helpers/llvm-sync
@@ -19,48 +19,47 @@
 }
 
 prog=`basename $0`
-syntax="Syntax: $prog [-clang-tools-e(x)tra] [-compiler(r)T] [-(l)ibs] [-Lin(k)er] [-(d)ebugger] [-(t)ests] [-(w)eb pages] [-(a)ll]"
+clang=false
 cextra=false
 rt=false
-libs=false
+libcxx=false
+libcxxabi=false
+libunwind=false
 linker=false
 debug=false
 tests=false
 web=false
+if [ -d $LLVM_SRC/tools/clang ]; then clang=true; fi
+if [ -d $LLVM_SRC/tools/clang/tools/extra ]; then cextra=true; fi
+if [ -d $LLVM_SRC/projects/compiler-rt ]; then rt=true; fi
+if [ -d $LLVM_SRC/projects/libcxx ]; then libcxx=true; fi
+if [ -d $LLVM_SRC/projects/libcxxabi ]; then libcxxabi=true; fi
+if [ -d $LLVM_SRC/projects/libunwind ]; then libunwind=true; fi
+if [ -d $LLVM_SRC/tools/lld ]; then linker=true; fi
+if [ -d $LLVM_SRC/tools/lldb ]; then debug=true; fi
+if [ -d $LLVM_SRC/projects/test-suite ]; then tests=true; fi
 
-while getopts "xrlkdtwa" opt; do
+while getopts "wa" opt; do
   case $opt in
-    x)
-      cextra=true
-      ;;
-    r)
-      rt=true
-      ;;
-    l)
-      libs=true
-      ;;
-    k)
-      linker=true
-      ;;
-    d)
-      debug=true
-      ;;
-    t)
-      tests=true
-      ;;
     w)
       web=true
       ;;
     a)
+      clang=true
       cextra=true
       rt=true
-      libs=true
+      libcxx=true
+      libcxxabi=true
+      libunwind=true
       linker=true
       debug=true
       tests=true
       ;;
     *)
-      echo $syntax
+      echo "Syntax: $prog [-(w)eb pages] [-(a)ll]"
+      echo "Syncs the repos that are currently linked into the llvm source tree"
+      echo "-w forces sync for the web repos (which are never linked)"
+      echo "-a forces sync for non-web repos that are not linked"
       exit 1
       ;;
   esac
@@ -68,7 +67,10 @@
 
 # Compulsory updates
 repo_sync LLVM $LLVM_SRC
-repo_sync Clang $LLVM_SRC/../clang
+
+if $clang; then
+  repo_sync Clang $LLVM_SRC/../clang
+fi
 
 # Optional updates
 if $cextra; then
@@ -79,9 +81,15 @@
   repo_sync RT $LLVM_SRC/../compiler-rt
 fi
 
-if $libs; then
+if $libcxx; then
   repo_sync LibC++ $LLVM_SRC/../libcxx
+fi
+
+if $libcxxabi; then
   repo_sync LibC++ABI $LLVM_SRC/../libcxxabi
+fi
+
+if $libunwind; then
   repo_sync LibUnwind $LLVM_SRC/../libunwind
 fi