Add support for multiple LOCAL_COMPATIBILITY_SUITES & undefined testcase directories.

1) Updates the LOCAL_COMPATIBILITY_SUITE line to allow for a
   testcase to belong to multiple suites.
2) Building testcases no longer fails if
   COMPATIBILITY_TESTCASES_OUT_<suite> is not defined. This
   testcase will just not output to that directory.
   This will be utilized by the device-tests and general-tests
   suites that don't require any extra output besides the common
   testcase directory.

Bug: 35394351
Test: 1) Added multiple *TS testcases to cts & vts and verified they
       ended up in the common directory and each suite's testcase
       directory. Specifically tested CtsSplitApp to ensure the
       split usecase still works as well.
      2) Added a CTS testcase to the device-tests suite, built
       device-tests and verified the cts/android-cts/testcases
       copy was not produced.

Change-Id: Ic4c4e87e62be4fc0c5e394d88cc359518346dffa
diff --git a/core/definitions.mk b/core/definitions.mk
index 750c329..682cf46 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -3244,6 +3244,30 @@
 #$(warning 42 == $(call math_max,42,5))
 
 ###########################################################
+## Compatibility suite tools
+###########################################################
+
+# Return a list of output directories for a given suite and the current LOCAL_MODULE
+define compatibility_suite_dirs
+  $(strip \
+    $(COMPATIBILITY_TESTCASES_OUT_$(1)) \
+    $($(my_prefix)OUT_TESTCASES)/$(LOCAL_MODULE))
+endef
+
+# For each suite:
+# 1. Copy the files to the many suite output directories.
+# 2. Add all the files to each suite's dependent files list.
+# 3. Do the dependency addition to my_all_targets
+# Requires for each suite: my_compat_dist_$(suite) to be defined.
+define create-suite-dependencies
+$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
+  $(eval my_compat_files_$(suite) := $(call copy-many-files, $(my_compat_dist_$(suite)))) \
+  $(eval COMPATIBILITY.$(suite).FILES := \
+    $(COMPATIBILITY.$(suite).FILES) $(my_compat_files_$(suite))) \
+  $(eval $(my_all_targets) : $(my_compat_files_$(suite))))
+endef
+
+###########################################################
 ## Other includes
 ###########################################################