Fix link_type checking
This was printing "error:", but not actually triggering an error.
Instead of trying to write a single line bash script to handle this,
move the actual check into python. This allows us to print all of the
errors for a single module before triggering the failure.
Also updates the warning format and the warn.py script to properly parse
these warning. Many of the java:sdk -> java:platform warnings are false
positives due to the lack of LOCAL_SDK_VERSION markings on prebuilts.
Individual tags can be marked as warnings now, which lets us check for
system libraries linking against vendor libraries (which won't work on
AOSP). I'm not sure this is a completely valid check, which one reason
that it's just a warning.
Test: m all_link_types (with some missing libs commented out)
Change-Id: I333e418c9a4511b7c7e826891ae481da08fbf6f9
diff --git a/core/definitions.mk b/core/definitions.mk
index 0c169e4..29b6539 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -3116,6 +3116,35 @@
endef
###########################################################
+# Link type checking
+###########################################################
+define check-link-type
+$(hide) mkdir -p $(dir $@) && rm -f $@
+$(hide) $(CHECK_LINK_TYPE) --makefile $(PRIVATE_MAKEFILE) --module $(PRIVATE_MODULE) \
+ --type "$(PRIVATE_LINK_TYPE)" $(addprefix --allowed ,$(PRIVATE_ALLOWED_TYPES)) \
+ $(addprefix --warn ,$(PRIVATE_WARN_TYPES)) $(PRIVATE_DEPS)
+$(hide) echo "$(PRIVATE_LINK_TYPE)" >$@
+endef
+
+define link-type-partitions
+ifndef LOCAL_IS_HOST_MODULE
+ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
+$(1): PRIVATE_LINK_TYPE += partition:vendor
+$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
+else ifeq (true,$(LOCAL_OEM_MODULE))
+$(1): PRIVATE_LINK_TYPE += partition:oem
+$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
+else ifeq (true,$(LOCAL_ODM_MODULE))
+$(1): PRIVATE_LINK_TYPE += partition:odm
+$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
+else
+# TODO: Mark libraries in /data
+$(1): PRIVATE_WARN_TYPES += partition:vendor partition:oem partition:odm
+endif
+endif
+endef
+
+###########################################################
## Other includes
###########################################################