Including files in one custom component from another
Posted: Tue Feb 19, 2019 12:48 am
I'm working on a few projects that share a fair amount of code. I'm trying to modularize this code into custom components for use in the various IDF projects I have to make it easier to maintain the common code. The issue I'm having is that in ComponentA I haven't been able to find a way to include header files from ComponentB (besides using the full relative path). I'm sure its doable since the IDF components do the exact thing I'm wanting to do (eg: other ESP-IDF components can include esp_log.h). I'm guessing either something is wrong in my include path or my component.mk files.
I have the following file structure:
project
\-build
\-components
\-ComponentA
|-component.mk
\-ComponentA
\-include
|-componentA.h
\-src
|-componentA.c
\-ComponentB
|-component.mk
\-ComponentB
\-include
|-componentB.h
\-src
|-componentB.c
\-main
|-main.c
|-component.mk
|-Makefile
|-partition.csv
|-sdkconfig
So basically my components directory has two components in it. ComponentA and ComponentB containing another directory and a component.mk file. Each of the sub directories have another directory containing the src and include directories.
My component.mk files look like:
I can use the components themselves fine as long as I use the entire relative path, but it won't compile if I try using #include "ComponentA/include/componentA.h" or "ComponentA/componentA.h" or "ComponentA/ComponentA/include/componentA.h" or "components/ComponentA/ComponentA/include/componentA.h". Make throws "fatal error: {path I used in include}: No such file or directory. I really need ComponentA to depend on .h files from ComponentB.
Does anyone have any ideas as to what I'm doing wrong here?
Thanks in advance!
Ethan
I have the following file structure:
project
\-build
\-components
\-ComponentA
|-component.mk
\-ComponentA
\-include
|-componentA.h
\-src
|-componentA.c
\-ComponentB
|-component.mk
\-ComponentB
\-include
|-componentB.h
\-src
|-componentB.c
\-main
|-main.c
|-component.mk
|-Makefile
|-partition.csv
|-sdkconfig
So basically my components directory has two components in it. ComponentA and ComponentB containing another directory and a component.mk file. Each of the sub directories have another directory containing the src and include directories.
My component.mk files look like:
- COMPONENTS_SRCDIRS := ComponentA/src
- COMPONENT_ADD_INCLUDEDIRS := ComponentA/include
Does anyone have any ideas as to what I'm doing wrong here?
Thanks in advance!
Ethan