Add --overlay

In that subsequent runs doesn't remove platforms/ and samples/.
--package-dir gets the accumulated stuff too.

Change-Id: I1f4e314f75ae7068fd168df072d02e9635be752f
diff --git a/build/tools/gen-platforms.sh b/build/tools/gen-platforms.sh
index 0ced51f..2fc7d8a 100755
--- a/build/tools/gen-platforms.sh
+++ b/build/tools/gen-platforms.sh
@@ -68,6 +68,7 @@
 OPTION_ARCH=
 OPTION_ABI=
 OPTION_DEBUG_LIBS=
+OPTION_OVERLAY=
 PACKAGE_DIR=
 
 VERBOSE=no
@@ -118,6 +119,9 @@
   --debug-libs)
     OPTION_DEBUG_LIBS=true
     ;;
+  --overlay)
+    OPTION_OVERLAY=true
+    ;;
   *)
     echo "unknown option '$opt', use --help"
     exit 1
@@ -565,7 +569,9 @@
 #   $SRC/android-$PLATFORM/arch-$ARCH/include --> $DST/android-$PLATFORM/arch-$ARCH/usr/include
 #   $SRC/android-$PLATFORM/arch-$ARCH/lib --> $DST/android-$PLATFORM/arch-$ARCH/usr/lib
 #
-rm -rf $DSTDIR/platforms && mkdir -p $DSTDIR/platforms
+if [ -z "$OPTION_OVERLAY" ]; then
+    rm -rf $DSTDIR/platforms && mkdir -p $DSTDIR/platforms
+fi
 for ARCH in $ARCHS; do
     # Find first platform for this arch
     PREV_SYSROOT_DST=
@@ -651,7 +657,9 @@
     # $SRC/android-$PLATFORM/samples/ --> $DST/samples
     #
     dump "Copying generic samples"
-    rm -rf $DSTDIR/samples && mkdir -p $DSTDIR/samples
+    if [ -z "OPTION_OVERLAY" ]; then
+        rm -rf $DSTDIR/samples && mkdir -p $DSTDIR/samples
+    fi
     copy_src_directory  samples samples samples
 
     for PLATFORM in $PLATFORMS; do