Add product and system_ext partition for emulator

Build product and system_ext image and add them to super partition.

Bug: 138382074
Test: boot emulator and check system_ext partition mounted
Change-Id: Ifa67bd6ad475ac5912e8f919c7a771c9958bd5c2
Merged-In: Ifa67bd6ad475ac5912e8f919c7a771c9958bd5c2
diff --git a/CleanSpec.mk b/CleanSpec.mk
index cbfca3e..4cfd21b 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -638,6 +638,11 @@
 # Move odm build.prop to /odm/etc/.
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/odm/build.prop)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/odm/build.prop)
+
+# Move product and system_ext to root for emulators
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/generic*/*/product)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/generic*/*/system_ext)
+
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/target/board/BoardConfigEmuCommon.mk b/target/board/BoardConfigEmuCommon.mk
index ac21918..76cb470 100644
--- a/target/board/BoardConfigEmuCommon.mk
+++ b/target/board/BoardConfigEmuCommon.mk
@@ -37,7 +37,9 @@
   BOARD_SUPER_PARTITION_GROUPS := emulator_dynamic_partitions
   BOARD_EMULATOR_DYNAMIC_PARTITIONS_PARTITION_LIST := \
       system \
-      vendor
+      vendor \
+      product \
+      system_ext
 
   # 3G
   BOARD_EMULATOR_DYNAMIC_PARTITIONS_SIZE := 3221225472
@@ -55,6 +57,11 @@
   BOARD_VENDORIMAGE_PARTITION_SIZE := 146800640
 endif
 
+TARGET_COPY_OUT_PRODUCT := product
+BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE := ext4
+TARGET_COPY_OUT_SYSTEM_EXT := system_ext
+BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE := ext4
+
 BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
 BOARD_FLASH_BLOCK_SIZE := 512
 DEVICE_MATRIX_FILE   := device/generic/goldfish/compatibility_matrix.xml