Remove support for user tags in the build system.

It is not forbidden to say LOCAL_MODULE_TAGS := user,
and if you don't say LOCAL_MODULE_TAGS, it now defaults
to optional.

Change-Id: I0a0b200bb6f1c7bf1fe3a89cdc8f69678617526c
diff --git a/core/main.mk b/core/main.mk
index 7598d86..ac6442a 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -224,13 +224,11 @@
 # Bring in dex_preopt.mk
 include $(BUILD_SYSTEM)/dex_preopt.mk
 
-ifneq ($(filter eng user userdebug,$(MAKECMDGOALS)),)
+ifneq ($(filter user userdebug eng,$(MAKECMDGOALS)),)
 $(info ***************************************************************)
 $(info ***************************************************************)
-$(info Don't pass '$(filter eng user userdebug tests,$(MAKECMDGOALS))' on \
+$(info Do not pass '$(filter user userdebug eng tests,$(MAKECMDGOALS))' on \
 		the make command line.)
-# XXX The single quote on this line fixes gvim's syntax highlighting.
-# Without which, the rest of this file is impossible to read.
 $(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)
 $(info choosecombo.)
 $(info ***************************************************************)
@@ -279,13 +277,13 @@
 
 ## user/userdebug ##
 
-user_variant := $(filter userdebug user,$(TARGET_BUILD_VARIANT))
+user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
 enable_target_debugging := true
+tags_to_install :=
 ifneq (,$(user_variant))
   # Target is secure in user builds.
   ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
 
-  tags_to_install := user
   ifeq ($(user_variant),userdebug)
     # Pick up some extra useful tools
     tags_to_install += debug
@@ -333,7 +331,7 @@
 ## eng ##
 
 ifeq ($(TARGET_BUILD_VARIANT),eng)
-tags_to_install := user debug eng
+tags_to_install := debug eng
 ifneq ($(filter ro.setupwizard.mode=ENABLED, $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))),)
   # Don't require the setup wizard on eng builds
   ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\
@@ -345,7 +343,7 @@
 ## tests ##
 
 ifeq ($(TARGET_BUILD_VARIANT),tests)
-tags_to_install := user debug eng tests
+tags_to_install := debug eng tests
 endif
 
 ## sdk ##
@@ -362,7 +360,7 @@
 
 # TODO: this should be eng I think.  Since the sdk is built from the eng
 # variant.
-tags_to_install := user debug eng
+tags_to_install := debug eng
 ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
 ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
 else # !sdk
@@ -591,54 +589,45 @@
 
 # -------------------------------------------------------------------
 # Figure out our module sets.
-
+#
 # Of the modules defined by the component makefiles,
 # determine what we actually want to build.
-Default_MODULES := $(sort $(ALL_DEFAULT_INSTALLED_MODULES) \
-                          $(CUSTOM_MODULES))
-# TODO: Remove the 3 places in the tree that use
-# ALL_DEFAULT_INSTALLED_MODULES and get rid of it from this list.
 
 ifdef FULL_BUILD
   # The base list of modules to build for this product is specified
   # by the appropriate product definition file, which was included
   # by product_config.make.
-  user_PACKAGES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)
-  $(call expand-required-modules,user_PACKAGES,$(user_PACKAGES))
-  user_PACKAGES := $(call module-installed-files, $(user_PACKAGES))
+  product_MODULES := $(call module-installed-files, \
+                       $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES))
+  ifeq (0,1)
+    $(info product_MODULES for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
+    $(foreach p,$(product_MODULES),$(info :   $(p)))
+    $(error done)
+  endif
 else
   # We're not doing a full build, and are probably only including
   # a subset of the module makefiles.  Don't try to build any modules
   # requested by the product, because we probably won't have rules
   # to build them.
-  user_PACKAGES :=
-endif
-# Use tags to get the non-APPS user modules.  Use the product
-# definition files to get the APPS user modules.
-user_MODULES := $(sort $(call get-tagged-modules,user shell_$(TARGET_SHELL)))
-
-# Print the user modules that are not in ...PRODUCT_PACKAGES
-ifeq (1,1)
-  $(warning Writing modules list: modules/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT).txt)
-  $(shell rm -f modules/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT).txt)
-  $(foreach m, \
-      $(filter-out $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \
-          $(call module-names-for-tag-list, user)), \
-      $(shell echo $m >> modules/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT).txt))
+  product_MODULES :=
 endif
 
-
-user_MODULES := $(user_MODULES) $(user_PACKAGES)
-
-eng_MODULES := $(sort $(call get-tagged-modules,eng))
+# When modules are tagged with debug eng or tests, they are installed
+# for those variants regardless of what the product spec says.
 debug_MODULES := $(sort $(call get-tagged-modules,debug))
+eng_MODULES := $(sort $(call get-tagged-modules,eng))
 tests_MODULES := $(sort $(call get-tagged-modules,tests))
 
-ifeq ($(strip $(tags_to_install)),)
-$(error ASSERTION FAILED: tags_to_install should not be empty)
-endif
-modules_to_install := $(sort $(Default_MODULES) \
-          $(foreach tag,$(tags_to_install),$($(tag)_MODULES)))
+# TODO: Remove the 3 places in the tree that use ALL_DEFAULT_INSTALLED_MODULES
+# and get rid of it from this list.
+# TODO: The shell is chosen by magic.  Do we still need this?
+modules_to_install := $(sort \
+        $(ALL_DEFAULT_INSTALLED_MODULES) \
+        $(product_MODULES) \
+        $(foreach tag,$(tags_to_install),$($(tag)_MODULES)) \
+        $(call get-tagged-modules, shell_$(TARGET_SHELL)) \
+        $(CUSTOM_MODULES) \
+    )
 
 # Some packages may override others using LOCAL_OVERRIDES_PACKAGES.
 # Filter out (do not install) any overridden packages.
@@ -686,15 +675,6 @@
 
 endif # dont_bother
 
-# Print the modules that we think we will install
-ifeq (1,1)
-  $(warning Writing installed file list: installed/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT).txt)
-  $(shell rm -f installed/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT).txt)
-  $(foreach m, $(modules_to_install), \
-      $(shell echo $m >> installed/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT).txt))
-  $(error stop)
-endif
-
 
 # These are additional goals that we build, in order to make sure that there
 # is as little code as possible in the tree that doesn't build.