From 69f7191d5d223fecc0556261ea31bdaec701f957 Mon Sep 17 00:00:00 2001 From: Justin Yun Date: Mon, 8 Mar 2021 19:31:37 +0900 Subject: [PATCH] Define __ANDROID_VENDOR__ and __ANDROID_PRODUCT__ __ANDROID_VNDK__ is defined for the modules that are able to use the VNDK libraries. As both product and vendor variants define __ANDROID_VNDK__, we don't know if a module is built for vendor or product on build time. __ANDROID_VENDOR__ and __ANDROID_PRODUCT__ macros can be used to specify the image-variant-dependent codes. Bug: 180646847 Test: m nothing Change-Id: I9a37607b1e1e4e16eab02fb6c96d1a92158c96b8 --- core/binary.mk | 9 +++++++++ core/local_vndk.mk | 2 ++ 2 files changed, 11 insertions(+) diff --git a/core/binary.mk b/core/binary.mk index fa36d644c..2c20eed60 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -311,6 +311,15 @@ ifneq ($(LOCAL_USE_VNDK),) my_api_level := $(call codename-or-sdk-to-sdk,$(BOARD_VNDK_VERSION)) endif my_cflags += -D__ANDROID_VNDK__ + ifneq ($(LOCAL_USE_VNDK_VENDOR),) + # Vendor modules have LOCAL_USE_VNDK_VENDOR when + # BOARD_VNDK_VERSION is defined. + my_cflags += -D__ANDROID_VENDOR__ + else ifneq ($(LOCAL_USE_VNDK_PRODUCT),) + # Product modules have LOCAL_USE_VNDK_PRODUCT when + # PRODUCT_PRODUCT_VNDK_VERSION is defined. + my_cflags += -D__ANDROID_PRODUCT__ + endif endif ifndef LOCAL_IS_HOST_MODULE diff --git a/core/local_vndk.mk b/core/local_vndk.mk index b1bd3e6c8..befbc5911 100644 --- a/core/local_vndk.mk +++ b/core/local_vndk.mk @@ -5,6 +5,7 @@ ifndef LOCAL_IS_HOST_MODULE ifndef LOCAL_SDK_VERSION ifneq (,$(filter true,$(LOCAL_VENDOR_MODULE) $(LOCAL_ODM_MODULE) $(LOCAL_OEM_MODULE) $(LOCAL_PROPRIETARY_MODULE))) LOCAL_USE_VNDK:=true + LOCAL_USE_VNDK_VENDOR:=true # Note: no need to check LOCAL_MODULE_PATH* since LOCAL_[VENDOR|ODM|OEM]_MODULE is already # set correctly before this is included. endif @@ -40,6 +41,7 @@ ifdef LOCAL_USE_VNDK # If we're not using the VNDK, drop all restrictions ifndef BOARD_VNDK_VERSION LOCAL_USE_VNDK:= + LOCAL_USE_VNDK_VENDOR:= LOCAL_USE_VNDK_PRODUCT:= endif endif