build: Add phony package to build enforce RRO packages

This allows one to build *__auto_generated_rro_(product|vendor).apk
under $(PRODUCT_OUT)/(product|vendor)/overlay/ without having to
build the full partition image or do full android build.

Change-Id: I0c215ed7968e0cba348d344e00a014470ac37b6e
diff --git a/core/definitions.mk b/core/definitions.mk
index 51def29..5563370 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -3932,6 +3932,7 @@
   $(eval enforce_rro_partition := $(word 6,$(_o))) \
   $(eval include $(BUILD_SYSTEM)/generate_enforce_rro.mk) \
   $(eval ALL_MODULES.$$(enforce_rro_source_module).REQUIRED_FROM_TARGET += $$(LOCAL_PACKAGE_NAME)) \
+  $(eval ENFORCE_RRO_PACKAGES_$$(call to-upper,$(enforce_rro_partition)) += $$(LOCAL_PACKAGE_NAME)) \
 )
 endef
 
diff --git a/core/main.mk b/core/main.mk
index 62fa53d..f027d9c 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -252,6 +252,8 @@
 
 ifneq ($(PRODUCT_ENFORCE_RRO_TARGETS),)
 ENFORCE_RRO_SOURCES :=
+ENFORCE_RRO_PACKAGES_PRODUCT :=
+ENFORCE_RRO_PACKAGES_VENDOR :=
 endif
 
 # Color-coded warnings including current module info
@@ -325,6 +327,22 @@
 # -------------------------------------------------------------------
 ifneq ($(PRODUCT_ENFORCE_RRO_TARGETS),)
 $(call generate_all_enforce_rro_packages)
+
+_modules_with_rro_suffix :=
+$(foreach m,$(PRODUCT_PACKAGES), \
+  $(eval _modules_with_rro_suffix += $$(m)__$(PRODUCT_NAME)__auto_generated_rro_%))
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := enforce_rro_packages_product
+LOCAL_MODULE_TAGS := optional
+LOCAL_REQUIRED_MODULES := $(filter $(_modules_with_rro_suffix),$(ENFORCE_RRO_PACKAGES_PRODUCT))
+include $(BUILD_PHONY_PACKAGE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := enforce_rro_packages_vendor
+LOCAL_MODULE_TAGS := optional
+LOCAL_REQUIRED_MODULES := $(filter $(_modules_with_rro_suffix),$(ENFORCE_RRO_PACKAGES_VENDOR))
+include $(BUILD_PHONY_PACKAGE)
 endif
 
 # -------------------------------------------------------------------