build: Add Bliss build support

Change-Id: Iab8b2ef8b644a7bea10bfd28b99d9e69539b1357
Signed-off-by: Jackeagle <jackeagle102@gmail.com>
diff --git a/core/Makefile b/core/Makefile
index 642784f..cb0df0d 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -331,6 +331,7 @@
 	$(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
 			TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \
 			TARGET_DEVICE="$(TARGET_DEVICE)" \
+			BLISS_DEVICE="$(TARGET_DEVICE)" \
 			PRODUCT_NAME="$(TARGET_PRODUCT)" \
 			PRODUCT_BRAND="$(PRODUCT_BRAND)" \
 			PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \
diff --git a/core/config.mk b/core/config.mk
index fba81ec..09c5d37 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -1086,4 +1086,16 @@
 include $(BUILD_SYSTEM)/soong_config.mk
 endif
 
+ifneq ($(BLISS_BUILD),)
+## We need to be sure the global selinux policies are included
+## last, to avoid accidental resetting by device configs
+#$(eval include device/bliss/sepolicy/common/sepolicy.mk)
+
+# Include any vendor specific config.mk file
+-include $(TOPDIR)vendor/*/build/core/config.mk
+
+# Include any vendor specific apicheck.mk file
+-include $(TOPDIR)vendor/*/build/core/apicheck.mk
+endif
+
 include $(BUILD_SYSTEM)/dumpvar.mk
diff --git a/core/product_config.mk b/core/product_config.mk
index bf98279..a622026 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -175,16 +175,22 @@
 include $(BUILD_SYSTEM)/product.mk
 include $(BUILD_SYSTEM)/device.mk
 
-ifneq ($(strip $(TARGET_BUILD_APPS)),)
-# An unbundled app build needs only the core product makefiles.
-all_product_configs := $(call get-product-makefiles,\
-    $(SRC_TARGET_DIR)/product/AndroidProducts.mk)
+# A Bliss build needs only the Bliss product makefiles.
+ifneq ($(BLISS_BUILD),)
+  all_product_configs := $(shell find device -path "*/$(BLISS_BUILD)/bliss.mk")
 else
-# Read in all of the product definitions specified by the AndroidProducts.mk
-# files in the tree.
-all_product_configs := $(get-all-product-makefiles)
-endif
+  ifneq ($(strip $(TARGET_BUILD_APPS)),)
+  # An unbundled app build needs only the core product makefiles.
+  all_product_configs := $(call get-product-makefiles,\
+      $(SRC_TARGET_DIR)/product/AndroidProducts.mk)
+  else
+  # Read in all of the product definitions specified by the AndroidProducts.mk
+  # files in the tree.
+  all_product_configs := $(get-all-product-makefiles)
+  endif # TARGET_BUILD_APPS
+endif # BLISS_BUILD
 
+ifeq ($(BLISS_BUILD),)
 all_named_products :=
 
 # Find the product config makefile for the current product.
@@ -210,6 +216,10 @@
 _cpm_words :=
 _cpm_word1 :=
 _cpm_word2 :=
+else
+    current_product_makefile := $(strip $(all_product_configs))
+    all_product_makefiles := $(strip $(all_product_configs))
+endif
 current_product_makefile := $(strip $(current_product_makefile))
 all_product_makefiles := $(strip $(all_product_makefiles))
 
diff --git a/envsetup.sh b/envsetup.sh
index a9bf43a..8eca483 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -137,6 +137,14 @@
         echo "Couldn't locate the top of the tree.  Try setting TOP." >&2
         return
     fi
+    if (echo -n $1 | grep -q -e "^bliss_") ; then
+        BLISS_BUILD=$(echo -n $1 | sed -e 's/^bliss_//g')
+        export BUILD_NUMBER=$( (date +%s%N ; echo $BLISS_BUILD; hostname) | openssl sha1 | sed -e 's/.*=//g; s/ //g' | cut -c1-10 )
+    else
+        BLISS_BUILD=
+    fi
+    export BLISS_BUILD
+
         TARGET_PRODUCT=$1 \
         TARGET_BUILD_VARIANT= \
         TARGET_BUILD_TYPE= \
@@ -623,6 +631,8 @@
         return 1
     fi
 
+    check_product $product
+
     TARGET_PRODUCT=$product \
     TARGET_BUILD_VARIANT=$variant \
     TARGET_PLATFORM_VERSION=$version \
diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh
index 5a54462..dac3ba9 100755
--- a/tools/buildinfo.sh
+++ b/tools/buildinfo.sh
@@ -61,4 +61,6 @@
 fi
 echo "ro.build.characteristics=$TARGET_AAPT_CHARACTERISTICS"
 
+echo "ro.bliss.device=$BLISS_DEVICE"
+
 echo "# end build properties"