feat(hints): use all_component_info from project_description.json

Currently the component_requirements hint module does not work
as expected if the component list for a project is trimmed down.
With the new "all_component_info" dictionary info in project_description.json,
the module can produce hints even if cmake's COMPONENTS variable is
set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2023-10-02 16:24:41 +02:00
parent dba7d11096
commit 64d82b54bc
2 changed files with 33 additions and 4 deletions

View File

@@ -171,5 +171,34 @@ class TestNestedModuleComponentRequirements(unittest.TestCase):
self.tmpdir.cleanup()
class TestTrimmedModuleComponentRequirements(unittest.TestCase):
def setUp(self) -> None:
# Set up a dummy project with a trimmed down list of components and main component.
# The main component includes "esp_http_client.h", but the esp_http_client
# component is not added to main's requirements.
self.tmpdir = tempfile.TemporaryDirectory()
self.tmpdirpath = Path(self.tmpdir.name)
self.projectdir = self.tmpdirpath / 'project'
self.projectdir.mkdir(parents=True)
(self.projectdir / 'CMakeLists.txt').write_text((
'cmake_minimum_required(VERSION 3.16)\n'
'set(COMPONENTS main)\n'
'include($ENV{IDF_PATH}/tools/cmake/project.cmake)\n'
'project(foo)'))
maindir = self.projectdir / 'main'
maindir.mkdir()
(maindir / 'CMakeLists.txt').write_text('idf_component_register(SRCS "foo.c")')
(maindir / 'foo.c').write_text('#include "esp_http_client.h"\nvoid app_main(){}')
def test_trimmed_component_requirements(self) -> None:
output = run_idf(['app'], self.projectdir)
self.assertIn('To fix this, add esp_http_client to PRIV_REQUIRES list of idf_component_register call in', output)
def tearDown(self) -> None:
self.tmpdir.cleanup()
if __name__ == '__main__':
unittest.main()