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
This commit is contained in:
Justin Yun 2024-02-23 17:48:22 +09:00
parent 3289747a5c
commit f3e89b8db4
2 changed files with 66 additions and 0 deletions

View file

@ -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",
}

View file

@ -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 <sys/cdefs.h>
__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