I have a similar problem as How to add external header files during bazel/tensorflow build. but I hope there is a better solution.
I have a module that requires some external .h header files at other location. Suppose I try to include "vendor/external/include/thirdpary.h", In Android.bp, I add some line like:
include_dirs: [
"vendor/external/include",
]
But the compiler is complaining this file does not exist when I include it in my CPP file:
#include "thirdpary.h"
                Using include_dirs is the correct approach. From what you write in your description it should work.
Here are some suggestions for error checking:
vendor/external/include actually a subfolder of $ANDROID_BUILD_TOP?Directories in include_dirs have to be specified relatively to the AOSP root directory. If the path is relative to your Android.bp you have to use local_include_dirs instead.
cc_binary {
    name: "my-module",
    srcs: [ "main.cpp" ],
    include_dirs: [ "vendor/external/include" ]
}
srcs list of the same module definition as include_dirs?If you want to inherit the include directory from a library your module depends on, then the library should use export_include_dirs.
cc_library {
    name: "my-library",
    export_include_dirs: [ "include" ]
}
cc_binary {
    name: "my-module",
    srcs: [ "main.cpp" ],
    static_libs: [ "my-library"] 
}
Rebuild your module and check the -I options.
m my-module | grep "main.cpp" | sed 's/-I/\n-I/g'
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With