Hi Kenn,
Normally you would have one component.mk file for each of components/cloud, components/eth_control, etc. and no component.mk file in the top-level "components" directory.
So for example, components/cloud/component.mk would contain:
Code: Select all
COMPONENT_ADD_INCLUDEDIRS := include
COMPONENT_SRCDIRS := .
... and so on with very similar component.mk files for the other 4 components (eth_control, sensor_control, etc).
Regarding any "components/include" directory in your project, suggest finding a way to remove it - maybe by moving the headers into a component's header directory.
Remove any "components/component.mk" file entirely: the idea is that each component is responsible for itself.
For GNU Make, that's it - nothing else is needed. Each component should be able to include headers from any other component, provided the components are all included in the build and each include directory is in that component's COMPONENT_ADD_INCLUDEDIRS list.
**
If you want to use CMake build system instead, then you will need to add a CMakeLists.txt file instead of each component.mk file. There are two big differences to the component.mk files. The first difference is that each source file needs to be specified, rather than a directory name. For example:
https://docs.espressif.com/projects/esp ... cmakelists
The second difference applies to any component (except for "main") that needs to include headers from another component. For example, if "cloud" needs to include headers from "sensor_control":
Then components/cloud/CMakeLists.txt looks like:
Code: Select all
set(COMPONENT_SRCS "sourcefile.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_REQUIRES sensor_control)
register_component()
... that's it!
Some things to note:
- COMPONENT_REQUIRES is for CMake only and will be ignored in a component.mk file
- The component.mk files and CMakeLists.txt files are never needed at the same time. If you only wish to use one of the two possible build systems, you only need one type of file.
- There shouldn't be any need for any component's build file to have paths that depend on the path of one component relative to the other component. Each component is intended to be self-contained, and only refers to other components by name not by path.