Add LOCAL_OVERRIDES_MODULES

LOCAL_OVERRIDES_MODULES is similar to LOCAL_OVERRIDES_PACKAGES, but is
for executables.

Bug: 36491275
Test: LOCAL_OVERRIDES_MODULES := foo should prevent a target executable
foo from being installed. If foo is not a target executable, error
should be reported.

Change-Id: I558f3d94105f9e319f8413c1290799f1c70ee131
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 1763a06..b4d17b5 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -360,6 +360,18 @@
 intermediates.COMMON := $(call local-intermediates-dir,COMMON)
 generated_sources_dir := $(call local-generated-sources-dir)
 
+ifneq ($(LOCAL_OVERRIDES_MODULES),)
+  ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
+    ifndef LOCAL_IS_HOST_MODULE
+      EXECUTABLES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_MODULES))
+    else
+      $(call pretty-error,host modules cannot use LOCAL_OVERRIDES_MODULES)
+    endif
+  else
+      $(call pretty-error,LOCAL_MODULE_CLASS := $(LOCAL_MODULE_CLASS) cannot use LOCAL_OVERRIDES_MODULES)
+  endif
+endif
+
 ###########################################################
 # Pick a name for the intermediate and final targets
 ###########################################################