Using NDK header when building vendor module with VNDK enabled

允我心安 提交于 2021-01-28 05:34:49

问题


I have a native vendor module built with AOSP (android 9.0.0_r35). This module uses android/input.h header. Note that this header is included in the android NDK.

When enabling the VNDK, building module fails with fatal error: 'android/input.h' file not found error.

This is caused by android build system (see compiler.go) who does not export the CommonGlobalIncludes when VNDK is enabled so frameworks/native/include (containing input.h) is not in include list.

I tried adding libandroid to LOCAL_SHARED_LIBRARIES without success. The android doc mentioning header does not refers to NDK includes. This file is supposed to stay stable so I think it is safe to use it from a vendor module.

Is there a module (LOCAL_SHARED_LIBRARIES or LOCAL_HEADER_LIBRARIES) to include to allow using NDK headers ? Else, is it safe to add $(ANDROID_BUILD_TOP)/out/soong/ndk/sysroot/usr/include/ to include path ?

Test code : Android.mk :

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE:= testIncludeInput_vendor
LOCAL_PROPRIETARY_MODULE := true
LOCAL_SRC_FILES := test.cpp
LOCAL_SHARED_LIBRARIES := libandroid 
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE:= testIncludeInput_system
LOCAL_SRC_FILES:= test.cpp
LOCAL_SHARED_LIBRARIES := libandroid 
include $(BUILD_STATIC_LIBRARY)

test.cpp :

#include <android/input.h>

来源:https://stackoverflow.com/questions/62390189/using-ndk-header-when-building-vendor-module-with-vndk-enabled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!