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