]> granicus.if.org Git - esp-idf/blobdiff - docs/build_system.rst
Add SPI Master driver, example, test and docs
[esp-idf] / docs / build_system.rst
index 50514083ef75ba6d2a4f8f32b8dbb0eb92850f69..6687fa69ed2f8d70fa4ccb2a583052dc1bcb107e 100644 (file)
@@ -57,6 +57,7 @@ Example Project
 ---------------
 
 An example project directory tree might look like this::
+
     - myProject/
                  - Makefile
                  - sdkconfig
@@ -66,11 +67,11 @@ An example project directory tree might look like this::
                                - component2/ - component.mk
                                              - Kconfig
                                              - src1.c
-                                             - include/
-                                                    - component2.h
+                                             - include/ - component2.h
                  - main/       - src1.c
                                - src2.c
                                - component.mk
+
                  - build/
 
 This example "myProject" contains the following elements:
@@ -101,6 +102,7 @@ Minimal Example Makefile
 ^^^^^^^^^^^^^^^^^^^^^^^^
 
 ::
+
    PROJECT_NAME := myProject
    
    include $(IDF_PATH)/make/project.mk
@@ -135,7 +137,8 @@ Minimal Component Makefile
 ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 The minimal ``component.mk`` file is an empty file(!). If the file is empty, the default component behaviour is set:
-- All source files in the same directory as the makefile (*.c, *.cpp, *.S) will be compiled into the component library
+
+- All source files in the same directory as the makefile (``*.c``, ``*.cpp``, ``*.S``) will be compiled into the component library
 - A sub-directory "include" will be added to the global include search path for all other components.
 - The component library will be linked into the project app.
 
@@ -185,6 +188,18 @@ The following variables can be set inside ``component.mk`` to control build sett
   are available at all times. It is necessary if one component
   generates an include file which you then want to include in another
   component. Most components do not need to set this variable.
+- ``COMPONENT_ADD_LINKER_DEPS``: Optional list of component-relative paths
+  to files which should trigger a re-link of the ELF file if they change.
+  Typically used for linker script files and binary libraries. Most components do
+  not need to set this variable.
+
+The following variable only works for components that are part of esp-idf itself:
+
+- ``COMPONENT_SUBMODULES``: Optional list of git submodule paths
+  (relative to COMPONENT_PATH) used by the component. These will be
+  checked (and initialised if necessary) by the build process. This
+  variable is ignored if the component is outside the IDF_PATH
+  directory.
 
 
 Optional Component-Specific Variables
@@ -201,8 +216,8 @@ The following variables can be set inside ``component.mk`` to control the build
   ``COMPONENT_PRIV_INCLUDEDIRS`` variable, except these paths are not
   expanded relative to the component directory.
 - ``COMPONENT_SRCDIRS``: Directory paths, must be relative to the
-  component directory, which will be searched for source files (*.cpp,
-  *.c, *.S). Defaults to '.', ie the component directory
+  component directory, which will be searched for source files (``*.cpp``,
+  ``*.c``, ``*.S``). Defaults to '.', ie the component directory
   itself. Override this to specify a different list of directories
   which contain source files.
 - ``COMPONENT_OBJS``: Object files to compile. Default value is a .o
@@ -234,6 +249,12 @@ The following variables can be set inside ``component.mk`` to control the build
   +=``. It is also possible (although not recommended) to override
   this variable completely for a component.
 
+To apply compilation flags to a single source file, you can add a variable override as a target, ie::
+
+  apps/dhcpserver.o: CFLAGS += -Wno-unused-variable
+
+This can be useful if there is upstream code that emits warnings.
+
 Component Configuration
 -----------------------
 
@@ -358,12 +379,14 @@ The configuration system can be used to conditionally compile some files
 depending on the options selected in ``make menuconfig``:
 
 ``Kconfig``::
+
     config FOO_ENABLE_BAR
         bool "Enable the BAR feature."
         help
             This enables the BAR feature of the FOO component.
 
 ``component.mk``::
+
     COMPONENT_OBJS := foo_a.o foo_b.o
 
     ifdef CONFIG_FOO_BAR
@@ -392,8 +415,13 @@ file called graphics_lib.c::
 
 
 In this example, graphics_lib.o and logo.h will be generated in the
-component build directory, whereas logo.bmp resides in the component
-source directory.
+current directory (the build directory) while logo.bmp comes with the
+component and resides under the component path. Because logo.h is a
+generated file, it needs to be cleaned when make clean is called which
+why it is added to the COMPONENT_EXTRA_CLEAN variable.
+
+Cosmetic Improvements
+^^^^^^^^^^^^^^^^^^^^^
 
 Because logo.h is a generated file, it needs to be cleaned when make
 clean is called which why it is added to the COMPONENT_EXTRA_CLEAN
@@ -407,6 +435,28 @@ component's name would have to be added to the other component's
 ``COMPONENT_DEPENDS`` list to ensure that the components were built
 in-order.
 
+Embedding Binary Data
+^^^^^^^^^^^^^^^^^^^^^
+
+Sometimes you have a file with some binary or text data that you'd like to make available to your component - but you don't want to reformat the file as C source.
+
+You can set a variable COMPONENT_EMBED_FILES in component.mk, giving the names of the files to embed in this way::
+
+  COMPONENT_EMBED_FILES := server_root_cert.der
+
+Or if the file is a string, you can use the variable COMPONENT_EMBED_TXTFILES. This will embed the contents of the text file as a null-terminated string::
+
+  COMPONENT_EMBED_TXTFILES := server_root_cert.pem
+
+The file's contents will be added to the .rodata section in flash, and are available via symbol names as follows::
+
+  extern const uint8_t server_root_cert_pem_start[] asm("_binary_server_root_cert_pem_start");
+  extern const uint8_t server_root_cert_pem_end[]   asm("_binary_server_root_cert_pem_end");
+
+The names are generated from the full name of the file, as given in COMPONENT_EMBED_FILES. Characters /, ., etc. are replaced with underscores. The _binary prefix in the symbol name is added by objcopy and is the same for both text and binary files.
+
+For an example of using this technique, see examples/04_https_request - the certificate file contents are loaded from the text .pem file at compile time.
+
 
 Fully Overriding The Component Makefile
 ---------------------------------------