idf-component-manager.rst 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. *********************
  2. IDF Component Manager
  3. *********************
  4. The IDF Component manager is a tool that downloads dependencies for any ESP-IDF CMake project. The download happens automatically during a run of CMake. It can source components either from `the component registry <https://components.espressif.com>`_ or from a git repository.
  5. A list of components can be found on `<https://components.espressif.com/>`_
  6. Activating the Component Manager
  7. ================================
  8. If CMake is started using ``idf.py`` or `ESP-IDF VSCode Extension <https://marketplace.visualstudio.com/items?itemName=espressif.esp-idf-extension>`_ then the component manager will be activated by default.
  9. If CMake is used directly or with some CMake-based IDE like CLion, it's necessary to set the ``IDF_COMPONENT_MANAGER`` environment variable to ``1`` to enable the component manager integration with the build system.
  10. Using with a project
  11. ====================
  12. Dependencies for each component in the project are defined in a separate manifest file named ``idf_component.yml`` placed in the root of the component. The manifest file template can be created for a component by running ``idf.py create-manifest --component=my_component``. When a new manifest is added to one of the components in the project it's necessary to reconfigure it manually by running ``idf.py reconfigure``. Then build will track changes in ``idf_component.yml`` manifests and automatically triggers CMake when necessary.
  13. There is an example application: example:`build_system/cmake/component_manager` that uses components installed by the component manager.
  14. It's not necessary to have a manifest for components that don't need any managed dependencies.
  15. When CMake configures the project (e.g. ``idf.py reconfigure``) component manager does a few things:
  16. - Processes ``idf_component.yml`` manifests for every component in the project and recursively solves dependencies
  17. - Creates a ``dependencies.lock`` file in the root of the project with a full list of dependencies
  18. - Downloads all dependencies to the ``managed_components`` directory
  19. The lock-file ``dependencies.lock`` and content of ``managed_components`` directory is not supposed to be modified by a user. When the component manager runs it always make sure they are up to date. If these files were accidentally modified it's possible to re-run the component manager by triggering CMake with ``idf.py reconfigure``
  20. Defining dependencies in the manifest
  21. =====================================
  22. .. code-block:: yaml
  23. dependencies:
  24. # Required IDF version
  25. idf: ">=4.1"
  26. # Defining a dependency from the registry:
  27. # https://components.espressif.com/component/example/cmp
  28. example/cmp: ">=1.0.0"
  29. # # Other ways to define dependencies
  30. #
  31. # # For components maintained by Espressif only name can be used.
  32. # # Same as `espressif/cmp`
  33. # component: "~1.0.0"
  34. #
  35. # # Or in a longer form with extra parameters
  36. # component2:
  37. # version: ">=2.0.0"
  38. #
  39. # # For transient dependencies `public` flag can be set.
  40. # # `public` flag doesn't affect the `main` component.
  41. # # All dependencies of `main` are public by default.
  42. # public: true
  43. #
  44. # # For components hosted on non-default registry:
  45. # service_url: "https://componentregistry.company.com"
  46. #
  47. # # For components in git repository:
  48. # test_component:
  49. # path: test_component
  50. # git: ssh://git@gitlab.com/user/components.git
  51. #
  52. # # For test projects during component development
  53. # # components can be used from a local directory
  54. # # with relative or absolute path
  55. # some_local_component:
  56. # path: ../../projects/component