Add options to blissify function

It's about time we update the blissify command to do a bit more for us.

Usage:
$ blissify options deviceCodename

Options:
-h | --help: Shows the help dialog
-c | --clean: Clean up before running the build
-d | --devclean: Clean up device only before running the build
-v | --vanilla: Build with no added app store solution **default option**
-g | --gapps: Build with Google Play Services added
-f | --foss: build with FOSS (arm64-v8a) app store solutions added **requires vendor/foss**
-F | --fossx: build with FOSS (x86_64) app store solutions added **requires vendor/foss**

This method is also backwards compatible with the legacy blissify command also:
$ blissify deviceCodename

Change-Id: I921971f380ea3b384aa06d435eb88a5c2e7d193f
diff --git a/build/envsetup.sh b/build/envsetup.sh
index dc0fba0..0a3b697 100644
--- a/build/envsetup.sh
+++ b/build/envsetup.sh
@@ -935,11 +935,118 @@
 
 function blissify()
 {
+	abt="$ANDROID_BUILD_TOP"
+	cd $abt
+	clean="n"
+	deviceclean="n"
+	export BLISS_BUILD_VARIANT=vanilla
+	while test $# -gt 0
+	do
+	  case $1 in
+
+	  # Normal option processing
+		-h | --help)
+		  echo "Usage: $0 options deviceCodename "
+		  echo "options: -h | --help: Shows this dialog"
+		  echo "         -c | --clean: Clean up before running the build"
+		  echo "         -d | --devclean: Clean up device tree before running the build"
+		  echo "         -v | --vanilla: Build with no added app store solution **default option** "
+		  echo "         -g | --gapps: Build with Google Play Services added"
+		  echo "         -f | --fossa: build with FOSS (arm64-v8a) app store solutions added"
+		  echo "         -F | --fossx: build with FOSS (x86_64) app store solutions added"
+		  echo ""
+		  echo "deviceCodename: "
+		  echo "your device codename, without the 'bliss_' in front"
+		  echo ""
+		  ;;
+		-c | --clean)
+		  clean="y";
+		  echo "Cleaning build and device tree selected."
+		  ;;
+		-d | --devclean)
+		  deviceclean="y";
+		  echo "Cleaning device tree selected."
+		  ;;
+		-v | --vanilla)
+		  echo "Building as stock (no gapps) **DEFAULT**"
+		  export BLISS_BUILD_VARIANT=vanilla
+		  ;;
+		-g | --gapps)
+		  echo "Building with gapps"
+		  export BLISS_BUILD_VARIANT=gapps
+		  ;;
+		-f | --fossa)
+		  echo "Building with FOSS apps for arm64-v8a support"
+		  export BLISS_BUILD_VARIANT=foss
+		  cd vendor/foss
+		  bash update.sh 2
+		  cd $abt
+		  ;;
+		-F | --fossx)
+		  echo "Building with FOSS apps for x86_64 support"
+		  export BLISS_BUILD_VARIANT=foss
+		  cd vendor/foss
+		  bash update.sh 1
+		  cd $abt
+		  ;;
+		
+	  # ...
+
+	  # Special cases
+		--)
+		  echo "Please use --help to verify correct usage"
+		  break
+		  ;;
+		--*)
+		  # error unknown (long) option $1
+		  echo "Please use --help to verify correct usage"
+		  break
+		  ;; 
+		-?)
+		  echo "Please use --help to verify correct usage"
+		  # error unknown (short) option $1
+		  break
+		  ;;
+
+	  # FUN STUFF HERE:
+	  # Split apart combined short options
+		-*)
+		  split=$1
+		  shift
+		  set -- $(echo "$split" | cut -c 2- | sed 's/./-& /g') "$@"
+		  continue
+		  ;;
+
+	  # Done with options
+		*)
+		  break
+		  ;;
+	  esac
+
+	  # for testing purposes:
+	  shift
+	done
+	
+	if [ $clean == "y" ];then
+		echo "Cleaning up a bit"
+		make clean && make clobber
+	fi
+	
+	if [ $deviceclean == "y" ];then
+		echo "Doing some device cleanup"
+		make deviceclean
+	fi
+	
+	if [ "$1" == "" ]; then
+		echo "No device name specified. Please use --help to verify correct usage"
+		return 0
+	fi
+	
     breakfast $*
     if [ $? -eq 0 ]; then
         mka blissify
     else
-        echo "No such item in brunch menu. Try 'breakfast'"
+        echo "No such item in brunch menu. Try 'breakfast' or verify your product is added to AndroidProducts.mk"
         return 1
     fi
     return $?
diff --git a/config/common.mk b/config/common.mk
index bd6fe44..6b88f1c 100644
--- a/config/common.mk
+++ b/config/common.mk
@@ -158,5 +158,15 @@
     FodAnimationResources
 endif
 
+# FOSS Apps
+ifeq ($(BLISS_BUILD_VARIANT), foss)
+$(call inherit-product, vendor/foss/foss.mk)
+endif
+
+# Go-gapps
+ifeq ($(BLISS_BUILD_VARIANT), goapps)
+$(call inherit-product, vendor/gapps-go/gapps-go.mk)
+endif
+
 -include $(WORKSPACE)/build_env/image-auto-bits.mk
 -include vendor/bliss/config/partner_gms.mk