Having idf_component.yml issues when trying to create my own components.
Posted: Mon Apr 22, 2024 11:39 am
I have been hitting my head against the proverbial brick wall trying to create my own components... Having found they exist they seem an excellent way to sub-divide a project into multiple independent units.
It seems that the idf_component.yml files are being ignored in some specific cases causing the cmake build to fail. All my components work when they are pulled directly from my github, as dependencies, and they also work when the directory name that contains the component matches the component name. But when using directory names that don't match the component name it fails to create the build system. I am not looking to put any components on the official components website at present, just within my own github.
My folders and files have the following structure (some files omitted for brevity):
As you can see each 'component' I'm developing is stored in a common '~/vscode/esp-idf' (this is actually a longer path, but used for brevity) directory and has its own effective "root/" and then the example code (that uses the component) is within an 'example' directory.
Occasionally when I'm making a large changes I will create a backup '_bk0' directory which normally I just ignore. However, lvgl has major breaking changes between 8.3 and 9.1 so while I was working on the new version I needed to go look at the original and that is where I realised that things fell down in a big messy heap!
During testing I also noticed that if I were to clone a "component" from my github into a directory that didn't have the same name it would also fail.
Using 'lcd-2090' as the example it works if it contains the following:
The various dependencies are downloaded and the code compiles and works with no issues.
If however I am within the 'lcd-2090_bk0' directory the dependencies are downloaded but the cmake creation state fails with the following errors:
The same '/example/main/idf_component.yml' file with 'lcd-2090' instead of 'i400s/lcd-2090' produces a similar error:
I did originally think that maybe this was something to do with the dependency chain because if I changed the '/example/main/idf_component.yml' path/override_path to point to "../../../lcd-2090" or I changed the line 'i400s/lcd-2090' to be either 'i400s/lcd-2090_bk0' or 'lcd-2090_bk0' then the dependencies are met and the build works correctly. Obviously in the first instance it makes the build look at the incorrect component code directory and in the latter two changes I've had to manually change the name of the component when I rename the folder which defeats the whole purpose of using the relative 'path: "../../"'.
Also I thought about, and tested, making the '/example/main/idf_component.yml' 'i400s/lcd-2090' pull from 'git: git@github.com:i400s/lcd-2090.git' and that worked fine, but obviously then means that the 'example/managed_components' now has a 'i400s__lcd-2090' and in the case of the '~/vscode/lcd-2090_bk0' has downloaded the incorrect version (the '~/vscode/lcd-2090' repository) and I really don't want to start having multiple versions all requiring uploads to download when the relative path should be working.
I also tested just using 'path:', using 'path:' and 'override_path:' and just using 'override_path:' and none seemed to may any difference to it failing.
My reading of the component manual was that using just the relative paths it should have found the component directory '~/vscode/esp-idf/lcd-2090_bk0' (which I think it did!) and then the creating of the make system by esp-idf should look at (use) the relative path component but for some reason it is trying to find a "directory" with the names 'i400s__lcd-2090' or 'lcd-2090' which it can't find even though it found the component.
Anyways, that's the issue I'm having so any help or guidance on why its not working as the manual seems to suggest it should would be much appreciated.
It seems that the idf_component.yml files are being ignored in some specific cases causing the cmake build to fail. All my components work when they are pulled directly from my github, as dependencies, and they also work when the directory name that contains the component matches the component name. But when using directory names that don't match the component name it fails to create the build system. I am not looking to put any components on the official components website at present, just within my own github.
My folders and files have the following structure (some files omitted for brevity):
Code: Select all
~/vscode/esp-idf/
i2c-mcp9808/
example/
CmakeLists.txt
sdkconfig
main/
CmakeLists.txt
idf_component.yml
i2c_mcp9808.main.c
CmakeLists.txt
idf_component.yml
i2c_mcp9808.c
lcd-2090/
example/
CmakeLists.txt
sdkconfig
main/
idf_component.yml
lcd_2090_main.c
CmakeLists.txt
idf_component.yml
lcd-2090.c
lcd-2090_bk0/
example/
CmakeLists.txt
sdkconfig
main/
idf_component.yml
lcd_2090_main.c
CmakeLists.txt
idf_component.yml
lcd-2090.c
Occasionally when I'm making a large changes I will create a backup '_bk0' directory which normally I just ignore. However, lvgl has major breaking changes between 8.3 and 9.1 so while I was working on the new version I needed to go look at the original and that is where I realised that things fell down in a big messy heap!
During testing I also noticed that if I were to clone a "component" from my github into a directory that didn't have the same name it would also fail.
Using 'lcd-2090' as the example it works if it contains the following:
Code: Select all
/example/main/CmakeLists.txt
idf_component_register(SRCS "lcd_2090_main.c"
INCLUDE_DIRS ".")
/example/main/idf_component.yml
dependencies:
idf: ">=5.3"
lvgl/lvgl: "^8.3"
i400s/i2c-mcp9808:
override_path: "../../../i2c-mcp9808"
i400s/lcd-2090:
version: "0.0.1"
path: "../../"
override_path: "../../"
/example/CmakeLists.txt
# The following lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(lcd-2090)
/CmakeLists.txt
idf_component_register(SRCS "lcd_2090.c"
INCLUDE_DIRS "include"
REQUIRES "driver"
"esp_driver_gpio")
/idf_component.yml
version: 0.0.1
description: "lcd-2090 driver for Adafruit 2090 (ili9341 lcd & i2c-ft6x06 capacitive touch)"
repository: https://github.com/i400s/lcd-2090.git
url: https://github.com/i400s/lcd-2090.git
dependencies:
idf:
version: '>=5.3'
esp_lcd_touch:
version: '>=1.1.1'
esp_lcd_ili9341: "^2.0"
i400s/i2c-ft6x06:
git: git@github.com:i400s/i2c-ft6x06.git
If however I am within the 'lcd-2090_bk0' directory the dependencies are downloaded but the cmake creation state fails with the following errors:
Code: Select all
Dependencies lock doesn't exist, solving dependencies.
Using component placed at /home/wilsonj/Documents/foldered/vscode/esp-idf/i2c-mcp9808 for dependency i400s/i2c-mcp9808(*), specified in /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/main/idf_component.yml
Using component placed at /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0 for dependency i400s/lcd-2090(0.0.1), specified in /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/main/idf_component.yml
.............Updating lock file at /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/dependencies.lock
Processing 8 dependencies:
[1/8] espressif/cmake_utilities (0.5.3)
[2/8] espressif/esp_lcd_ili9341 (2.0.0)
[3/8] espressif/esp_lcd_touch (1.1.1)
[4/8] i400s/i2c-ft6x06 (f330f25d871d3e8297df861f59f4bcb0b2b5c0f4)
[5/8] i400s/i2c-mcp9808 (0.0.1)
[6/8] i400s/lcd-2090 (0.0.1)
[7/8] idf (5.3.0)
[8/8] lvgl/lvgl (8.3.11)
CMake Error at /mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:268 (message):
Failed to resolve component 'i400s__lcd-2090'.
Call Stack (most recent call first):
/mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:310 (__build_resolve_and_add_req)
/mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:607 (__build_expand_requirements)
/mnt/md8/_development/esp/esp-idf/tools/cmake/project.cmake:710 (idf_build_process)
CMakeLists.txt:6 (project)
-- Configuring incomplete, errors occurred!
* The terminal process "/usr/bin/bash '-c', 'cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -B /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/build -S /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example'" terminated with exit code: 1.
Code: Select all
Dependencies lock doesn't exist, solving dependencies.
Using component placed at /home/wilsonj/Documents/foldered/vscode/esp-idf/i2c-mcp9808 for dependency i400s/i2c-mcp9808(*), specified in /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/main/idf_component.yml
Using component placed at /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0 for dependency lcd-2090(0.0.1), specified in /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/main/idf_component.yml
.............Updating lock file at /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/dependencies.lock
Processing 8 dependencies:
[1/8] espressif/cmake_utilities (0.5.3)
[2/8] espressif/esp_lcd_ili9341 (2.0.0)
[3/8] espressif/esp_lcd_touch (1.1.1)
[4/8] i400s/i2c-ft6x06 (f330f25d871d3e8297df861f59f4bcb0b2b5c0f4)
[5/8] i400s/i2c-mcp9808 (0.0.1)
[6/8] idf (5.3.0)
[7/8] lcd-2090 (0.0.1)
[8/8] lvgl/lvgl (8.3.11)
CMake Error at /mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:268 (message):
Failed to resolve component 'lcd-2090'.
Call Stack (most recent call first):
/mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:310 (__build_resolve_and_add_req)
/mnt/md8/_development/esp/esp-idf/tools/cmake/build.cmake:607 (__build_expand_requirements)
/mnt/md8/_development/esp/esp-idf/tools/cmake/project.cmake:710 (idf_build_process)
CMakeLists.txt:6 (project)
-- Configuring incomplete, errors occurred!
* The terminal process "/usr/bin/bash '-c', 'cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -B /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example/build -S /home/wilsonj/Documents/foldered/vscode/esp-idf/lcd-2090_bk0/example'" terminated with exit code: 1.
Also I thought about, and tested, making the '/example/main/idf_component.yml' 'i400s/lcd-2090' pull from 'git: git@github.com:i400s/lcd-2090.git' and that worked fine, but obviously then means that the 'example/managed_components' now has a 'i400s__lcd-2090' and in the case of the '~/vscode/lcd-2090_bk0' has downloaded the incorrect version (the '~/vscode/lcd-2090' repository) and I really don't want to start having multiple versions all requiring uploads to download when the relative path should be working.
I also tested just using 'path:', using 'path:' and 'override_path:' and just using 'override_path:' and none seemed to may any difference to it failing.
My reading of the component manual was that using just the relative paths it should have found the component directory '~/vscode/esp-idf/lcd-2090_bk0' (which I think it did!) and then the creating of the make system by esp-idf should look at (use) the relative path component but for some reason it is trying to find a "directory" with the names 'i400s__lcd-2090' or 'lcd-2090' which it can't find even though it found the component.
Anyways, that's the issue I'm having so any help or guidance on why its not working as the manual seems to suggest it should would be much appreciated.