EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1287 background imageLoading...
Page #1287 background image
Chapter 4. API Guides
Multiple components with the same name
When ESP-IDF is collecting all the components to compile, it will do this in the order specied by COMPO-
NENT_DIRS; by default, this means ESP-IDFs internal components first (IDF_PATH/components), then
any components in directories specified in EXTRA_COMPONENT_DIRS, and finally the projects components
(PROJECT_DIR/components). If two or more of these directories contain component sub-directories with the
same name, the component in the last place searched is used. This allows, for example, overriding ESP-IDF com-
ponents with a modified version by copying that component from the ESP-IDF components directory to the project
components directory and then modifying it there. If used in this way, the ESP-IDF directory itself can remain
untouched.
Note: If a component is overridden in an existing project by moving it to a new location, the project will not
automatically see the new component path. Run idf.py reconfigure (or delete the project build folder) and
then build again.
Minimal Component CMakeLists
The minimal component CMakeLists.txt file simply registers the component to the build system using
idf_component_register:
idf_component_register(SRCS "foo.c" "bar.c"
INCLUDE_DIRS "include"
REQUIRES mbedtls)
SRCS is a list of source files (*.c, *.cpp, *.cc, *.S). These source files will be compiled into the com-
ponent library.
INCLUDE_DIRS is a list of directories to add to the global include search path for any component which
requires this component, and also the main source files.
REQUIRES is not actually required, but it is very often required to declare what other components this com-
ponent will use. See Component Requirements.
A library with the name of the component will be built and linked into the final app.
Directories are usually specified relative to the CMakeLists.txt file itself, although they can be absolute.
There are other arguments that can be passed to idf_component_register. These arguments are discussed
here.
See example component requirements and example component CMakeLists for more complete component CMake-
Lists.txt examples.
Create a new component
Use the command idf.py create-component for creating a new component. The new component will contain
set of files necessary for building a component. You may include the components header file into your project and
use its functionality. For more information execute idf.py create-component --help.
Example:
idf.py -C components create-component my_component
The example will create a new component in the subdirectory components under the current working directory. For
more information about components follow the documentation page see above.
Preset Component Variables
The following component-specic variables are available for use inside component CMakeLists, but should not be
modified:
Espressif Systems 1276
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish