Skip to content

Commit

Permalink
component manager: add build property DEPENDENCIES_LOCK
Browse files Browse the repository at this point in the history
closes #9394
  • Loading branch information
hfudev committed Dec 13, 2022
1 parent 6c4c6e0 commit 17224f3
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/en/api-guides/build-system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@ These are properties that describe the build. Values of build properties can be
- COMPILE_OPTIONS - compile options applied to all components' source files, regardless of it being C or C++
- COMPILE_DEFINITIONS - compile definitions applied to all component source files
- CXX_COMPILE_OPTIONS - compile options applied to all components' C++ source files
- DEPENDENCIES_LOCK - lock file path used in component manager. The default value is `dependencies.lock` under the project path.
- EXECUTABLE - project executable; set by call to ``idf_build_executable``
- EXECUTABLE_NAME - name of project executable without extension; set by call to ``idf_build_executable``
- EXECUTABLE_DIR - path containing the output executable
Expand Down
2 changes: 2 additions & 0 deletions docs/en/api-guides/tools/idf-component-manager.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ When CMake configures the project (e.g. ``idf.py reconfigure``) component manage

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``

You may set build property ``DEPENDENCIES_LOCK`` to specify the lock-file path in the top-level CMakeLists.txt. For example, adding ``idf_build_set_property(DEPENDENCIES_LOCK dependencies.lock.${IDF_TARGET})`` before ``project(PROJECT_NAME)`` could help generate different lock files for different targets.

Defining dependencies in the manifest
=====================================

Expand Down
1 change: 1 addition & 0 deletions docs/sphinx-known-warnings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
# Warnings in this file must be in the same overall order as the log file.
#
idf-component-manager.rst: WARNING: Badly formated string substitution: {IDF_TARGET}
esp_ble_mesh_defs.inc:line: WARNING: Duplicate C++ declaration, also defined at api-reference/bluetooth/esp-ble-mesh:line.
Declaration is '.. cpp:member:: uint16_t model_id'.
rmt_encoder.inc:line: WARNING: Duplicate C++ declaration, also defined at api-reference/peripherals/rmt:line.
Expand Down
3 changes: 3 additions & 0 deletions tools/cmake/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,13 @@ macro(idf_build_process target)
# Call for the component manager to prepare remote dependencies
idf_build_get_property(python PYTHON)
idf_build_get_property(component_manager_interface_version __COMPONENT_MANAGER_INTERFACE_VERSION)
idf_build_get_property(dependencies_lock_file DEPENDENCIES_LOCK)

execute_process(COMMAND ${python}
"-m"
"idf_component_manager.prepare_components"
"--project_dir=${project_dir}"
"--lock_path=${dependencies_lock_file}"
"--interface_version=${component_manager_interface_version}"
"prepare_dependencies"
"--local_components_list_file=${local_components_list_file}"
Expand Down
1 change: 1 addition & 0 deletions tools/cmake/component.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ function(__component_get_requirements)
"-m"
"idf_component_manager.prepare_components"
"--project_dir=${project_dir}"
"--lock_path=${DEPENDENCIES_LOCK}"
"--interface_version=${component_manager_interface_version}"
"inject_requirements"
"--idf_path=${idf_path}"
Expand Down
2 changes: 1 addition & 1 deletion tools/cmake/project.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if(NOT "$ENV{IDF_COMPONENT_MANAGER}" EQUAL "0")
idf_build_set_property(IDF_COMPONENT_MANAGER 1)
endif()
# Set component manager interface version
idf_build_set_property(__COMPONENT_MANAGER_INTERFACE_VERSION 1)
idf_build_set_property(__COMPONENT_MANAGER_INTERFACE_VERSION 2)

#
# Get the project version from either a version file or the Git revision. This is passed
Expand Down
25 changes: 25 additions & 0 deletions tools/test_build_system/test_component_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import os.path
from pathlib import Path

import pytest
from test_build_system_helpers import IdfPyFunc


@pytest.mark.test_app_copy('examples/get-started/blink')
def test_dependency_lock(idf_py: IdfPyFunc, test_app_copy: Path) -> None:
with open(test_app_copy / 'CMakeLists.txt', 'r+') as fw:
data = fw.read()
fw.seek(0)
fw.write(
data.replace(
'project(blink)',
'idf_build_set_property(DEPENDENCIES_LOCK dependencies.lock.${IDF_TARGET})\nproject(blink)',
)
)

idf_py('fullclean')
idf_py('reconfigure')
assert os.path.isfile(test_app_copy / 'dependencies.lock.esp32')
assert not os.path.isfile(test_app_copy / 'dependencies.lock')

0 comments on commit 17224f3

Please sign in to comment.