From f3e89b8db4605039a936833461b27b312027f88c Mon Sep 17 00:00:00 2001 From: Justin Yun Date: Fri, 23 Feb 2024 17:48:22 +0900 Subject: [PATCH] Define __INTRODUCED_IN_LLNDK Symbols with __INTRODUCED_IN_LLNDK are available for LLNDK only if the vendor api level set by the RELEASE_BOARD_API_LEVEL is equal to or newer than the target vendor api level in __INTRODUCED_IN_LLNDK. This works only for the vendor variants at the same time ignoring __INTRODUCED_IN annotation for the vendor variants. On the other hand, __INTRODUCED_IN_LLNDK will be ignored from non-vendor variants. Bug: 302113279 Test: build Change-Id: I5317a73dbc73095f8d5d95131ca4d9ed39df6be1 --- libvendorsupport/Android.bp | 18 +++++++ .../include_llndk/android/llndk-versioning.h | 48 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 libvendorsupport/include_llndk/android/llndk-versioning.h diff --git a/libvendorsupport/Android.bp b/libvendorsupport/Android.bp index b4457b181..74e3f0044 100644 --- a/libvendorsupport/Android.bp +++ b/libvendorsupport/Android.bp @@ -34,3 +34,21 @@ cc_library { "liblog", ], } + +cc_library_headers { + name: "libvendorsupport_llndk_headers", + host_supported: true, + vendor_available: true, + recovery_available: true, + ramdisk_available: true, + vendor_ramdisk_available: true, + native_bridge_supported: true, + + export_include_dirs: ["include_llndk"], + llndk: { + llndk_headers: true, + }, + + system_shared_libs: [], + stl: "none", +} diff --git a/libvendorsupport/include_llndk/android/llndk-versioning.h b/libvendorsupport/include_llndk/android/llndk-versioning.h new file mode 100644 index 000000000..7c408c940 --- /dev/null +++ b/libvendorsupport/include_llndk/android/llndk-versioning.h @@ -0,0 +1,48 @@ +// Copyright (C) 2024 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +__BEGIN_DECLS + +#if defined(__ANDROID_VENDOR__) + +// LLNDK (https://source.android.com/docs/core/architecture/vndk/build-system#ll-ndk) is similar to +// NDK, but uses its own versioning of YYYYMM format for vendor builds. The LLNDK symbols are +// enabled when the vendor api level is equal to or newer than the ro.board.api_level. +#define __INTRODUCED_IN_LLNDK(vendor_api_level) \ + _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((enable_if( \ + __ANDROID_VENDOR_API__ >= vendor_api_level, \ + "available in vendor API level " #vendor_api_level " that " \ + "is newer than the current vendor API level. Guard the API " \ + "call with '#if (__ANDROID_VENDOR_API__ >= " #vendor_api_level ")'."))) \ + _Pragma("clang diagnostic pop") + +// For the vendor libraries, __INTRODUCED_IN must be ignored because they are only for NDKs but not +// for LLNDKs. +#undef __INTRODUCED_IN +#define __INTRODUCED_IN(x) + +#else // __ANDROID_VENDOR__ + +// For non-vendor libraries, __INTRODUCED_IN_LLNDK must be ignored because it must not change +// symbols of NDK or the system side of the treble boundary. +#define __INTRODUCED_IN_LLNDK(vendor_api_level) + +#endif // __ANDROID_VENDOR__ + +__END_DECLS