Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c3c9ef7 authored by Anton Hansson's avatar Anton Hansson
Browse files

Add more control to the java sdk enforcement.

I plan on turning the error on for APPS in AOSP soon, and in preparation for
that I'm introducing a finer granularity of warning/error control.

Also add an almost-empty whitelist, which will likely need to be expanded
in the future.

Bug: 73535841
Test: make
Exempt-From-Owner-Approval: cp from aosp and master
Change-Id: I2fc6700a504b7af50aa7bde727047bc56b167937
Merged-In: I13ebe3ead2d19aa797bcc39a7bbccdb55b9c7d1c
Merged-In: I87c968b2e8314300b155483bbb7ce5e169fe8f0c
parent 0c7a14ab
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -2,13 +2,31 @@
# Enforcement checks that LOCAL_SDK_VERSION and LOCAL_PRIVATE_PLATFORM_APIS are
# set correctly.
# Should be included by java targets that allow specifying LOCAL_SDK_VERSION.
# The JAVA_SDK_ENFORCEMENT_WARNING and JAVA_SDK_ENFORCEMENT_ERROR variables may
# be set to a particular module class to enable warnings and errors for that
# subtype.

whitelisted_modules := framework-res__auto_generated_rro

ifeq ($(LOCAL_SDK_VERSION)$(LOCAL_PRIVATE_PLATFORM_APIS),)
ifneq ($(JAVA_SDK_ENFORCEMENT_WARNING),)
$(warning Java modules must specify LOCAL_SDK_VERSION or LOCAL_PRIVATE_PLATFORM_APIS, but $(LOCAL_MODULE) specifies neither.)
  ifeq (,$(filter $(LOCAL_MODULE),$(whitelisted_modules)))
    ifneq ($(JAVA_SDK_ENFORCEMENT_WARNING)$(JAVA_SDK_ENFORCEMENT_ERROR),)
      my_message := Must specify LOCAL_SDK_VERSION or LOCAL_PRIVATE_PLATFORM_APIS,
      ifeq ($(LOCAL_MODULE_CLASS),$(JAVA_SDK_ENFORCEMENT_ERROR))
        $(call pretty-error,$(my_message))
      endif
      ifeq ($(LOCAL_MODULE_CLASS),$(JAVA_SDK_ENFORCEMENT_WARNING))
        $(call pretty-warning,$(my_message))
      endif
      my_message :=
    endif
  endif
else ifneq ($(LOCAL_SDK_VERSION),)
  ifneq ($(LOCAL_PRIVATE_PLATFORM_APIS),)
$(error $(LOCAL_MODULE) specifies both LOCAL_SDK_VERSION ($(LOCAL_SDK_VERSION)) and LOCAL_PRIVATE_PLATFORM_APIS ($(LOCAL_PRIVATE_PLATFORM_APIS)), but should specify only one.)
    my_message := Specifies both LOCAL_SDK_VERSION ($(LOCAL_SDK_VERSION)) and
    my_message += LOCAL_PRIVATE_PLATFORM_APIS ($(LOCAL_PRIVATE_PLATFORM_APIS))
    my_message += but should specify only one
    $(call pretty-error,$(my_message))
    my_message :=
  endif
endif