esp-idf: Unable to build component host tests that test code using hal (IDFGH-9074)

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.0

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

What is the expected behavior?

I am trying to write host tests for a led manager, which needs to mock hal.

What is the actual behavior?

...
[0/1] Re-running CMake...-- Component directory /home/vbox/esp/esp-idf/tools/mocks/hal/include does not contain a CMakeLists.txt file. No component will be added
...
In file included from /home/vbox/led_manager/include/led_strip_encoder.h:9,
                 from /home/vbox/led_manager/led_strip_encoder.c:8:
/home/vbox/esp/esp-idf/components/driver/include/driver/rmt_encoder.h:11:10: fatal error: hal/rmt_types.h: No such file or directory
   11 | #include "hal/rmt_types.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.

Steps to reproduce.

copy led_strip_encoder.h/c into component under test and use code add driver and hal mocks to host test cmakelists

list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/driver/")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/hal/")

Build or installation Logs.

vbox@vbox:~/led_manager/host_test$ idf.py build
Executing action: all (aliases: build)
Running ninja in directory /home/vbox/led_manager/host_test/build
Executing "ninja all"...
[0/1] Re-running CMake...-- Component directory /home/vbox/esp/esp-idf/tools/mocks/hal/include does not contain a CMakeLists.txt file. No component will be added
-- Building ESP-IDF components for target linux
Processing 3 dependencies:
[3/3] led_manager (0.0.1)-- building DRIVER MOCKS (only SPI, I2C and GPIO driver)
-- building FREERTOS MOCKS (only task, event-groups and queue)
-- Project sdkconfig file /home/vbox/led_manager/host_test/sdkconfig
Loading defaults file /home/vbox/led_manager/host_test/sdkconfig.defaults...
-- building FREERTOS MOCKS (only task, event-groups and queue)
-- building DRIVER MOCKS (only SPI, I2C and GPIO driver)
-- Component idf::main will be linked with -Wl,--whole-archive
-- Components: cmock component_base driver esp_common esp_event esp_rom freertos led_manager linux log main unity
-- Component paths: /home/vbox/esp/esp-idf/components/cmock /home/vbox/led_manager/host_test/managed_components/component_base /home/vbox/esp/esp-idf/tools/mocks/driver /home/vbox/esp/esp-idf/components/esp_common /home/vbox/esp/esp-idf/components/esp_event /home/vbox/esp/esp-idf/components/esp_rom /home/vbox/esp/esp-idf/tools/mocks/freertos /home/vbox/led_manager /home/vbox/esp/esp-idf/components/linux /home/vbox/esp/esp-idf/components/log /home/vbox/led_manager/host_test/main /home/vbox/esp/esp-idf/components/unity
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vbox/led_manager/host_test/build
[1/38] Try to find ruby. If this fails, you need to install rubyruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]
[23/37] Try to find ruby. If this fails, you need to install rubyruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]
[29/36] Building C object esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/led_strip_encoder.c.oFAILED: esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/led_strip_encoder.c.o 
/usr/bin/cc -DUNITY_INCLUDE_CONFIG_H -I/home/vbox/led_manager/host_test/build/config -I/home/vbox/led_manager/include -I/home/vbox/esp/esp-idf/tools/mocks/freertos/include -I/home/vbox/esp/esp-idf/components/freertos/FreeRTOS-Kernel/include -I/home/vbox/esp/esp-idf/components/freertos/esp_additions/include -I/home/vbox/esp/esp-idf/components/freertos/esp_additions/include/freertos -I/home/vbox/esp/esp-idf/components/freertos/FreeRTOS-Kernel/include/freertos -I/home/vbox/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/linux/include -I/home/vbox/led_manager/host_test/build/esp-idf/freertos/mocks -I/home/vbox/esp/esp-idf/components/log/include -I/home/vbox/esp/esp-idf/components/esp_rom/include -I/home/vbox/esp/esp-idf/components/esp_rom/include/linux -I/home/vbox/esp/esp-idf/tools/mocks/soc/include -I/home/vbox/esp/esp-idf/components/esp_common/include -I/home/vbox/esp/esp-idf/components/cmock/CMock/src -I/home/vbox/esp/esp-idf/components/unity/include -I/home/vbox/esp/esp-idf/components/unity/unity/src -I/home/vbox/led_manager/host_test/managed_components/component_base/include -I/home/vbox/esp/esp-idf/components/esp_event/include -I/home/vbox/esp/esp-idf/components/linux/include -I/home/vbox/esp/esp-idf/components/driver/include -I/home/vbox/esp/esp-idf/components/driver/include/driver -I/home/vbox/esp/esp-idf/tools/mocks/hal/include -I/home/vbox/esp/esp-idf/tools/mocks/esp_hw_support/include -I/home/vbox/led_manager/host_test/build/esp-idf/driver/mocks -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -Og -fmacro-prefix-map=/home/vbox/led_manager/host_test=. -fmacro-prefix-map=/home/vbox/esp/esp-idf=/IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu17 -Wno-old-style-declaration -D_GNU_SOURCE -DIDF_VER=\"v5.0-161-g76804f3d42\" -DESP_PLATFORM -DSPI_MOCK -MD -MT esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/led_strip_encoder.c.o -MF esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/led_strip_encoder.c.o.d -o esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/led_strip_encoder.c.o -c /home/vbox/led_manager/led_strip_encoder.c
In file included from /home/vbox/led_manager/include/led_strip_encoder.h:9,
                 from /home/vbox/led_manager/led_strip_encoder.c:8:
/home/vbox/esp/esp-idf/components/driver/include/driver/rmt_encoder.h:11:10: fatal error: hal/rmt_types.h: No such file or directory
   11 | #include "hal/rmt_types.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
[30/36] Building CXX object esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/LedManager.cpp.oFAILED: esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/LedManager.cpp.o 
/usr/bin/c++ -DUNITY_INCLUDE_CONFIG_H -I/home/vbox/led_manager/host_test/build/config -I/home/vbox/led_manager/include -I/home/vbox/esp/esp-idf/tools/mocks/freertos/include -I/home/vbox/esp/esp-idf/components/freertos/FreeRTOS-Kernel/include -I/home/vbox/esp/esp-idf/components/freertos/esp_additions/include -I/home/vbox/esp/esp-idf/components/freertos/esp_additions/include/freertos -I/home/vbox/esp/esp-idf/components/freertos/FreeRTOS-Kernel/include/freertos -I/home/vbox/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/linux/include -I/home/vbox/led_manager/host_test/build/esp-idf/freertos/mocks -I/home/vbox/esp/esp-idf/components/log/include -I/home/vbox/esp/esp-idf/components/esp_rom/include -I/home/vbox/esp/esp-idf/components/esp_rom/include/linux -I/home/vbox/esp/esp-idf/tools/mocks/soc/include -I/home/vbox/esp/esp-idf/components/esp_common/include -I/home/vbox/esp/esp-idf/components/cmock/CMock/src -I/home/vbox/esp/esp-idf/components/unity/include -I/home/vbox/esp/esp-idf/components/unity/unity/src -I/home/vbox/led_manager/host_test/managed_components/component_base/include -I/home/vbox/esp/esp-idf/components/esp_event/include -I/home/vbox/esp/esp-idf/components/linux/include -I/home/vbox/esp/esp-idf/components/driver/include -I/home/vbox/esp/esp-idf/components/driver/include/driver -I/home/vbox/esp/esp-idf/tools/mocks/hal/include -I/home/vbox/esp/esp-idf/tools/mocks/esp_hw_support/include -I/home/vbox/led_manager/host_test/build/esp-idf/driver/mocks -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -Og -fmacro-prefix-map=/home/vbox/led_manager/host_test=. -fmacro-prefix-map=/home/vbox/esp/esp-idf=/IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++20 -fexceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v5.0-161-g76804f3d42\" -DESP_PLATFORM -DSPI_MOCK -std=gnu++20 -MD -MT esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/LedManager.cpp.o -MF esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/LedManager.cpp.o.d -o esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/LedManager.cpp.o -c /home/vbox/led_manager/LedManager.cpp
In file included from /home/vbox/esp/esp-idf/components/driver/include/driver/rmt_common.h:11,
                 from /home/vbox/esp/esp-idf/components/driver/include/driver/rmt_tx.h:12,
                 from /home/vbox/led_manager/include/SerialLed.hpp:30,
                 from /home/vbox/led_manager/LedManager.cpp:29:
/home/vbox/esp/esp-idf/components/driver/include/driver/rmt_types.h:12:10: fatal error: hal/rmt_types.h: No such file or directory
   12 | #include "hal/rmt_types.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
[31/36] Building CXX object esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/SerialLed.cpp.oFAILED: esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/SerialLed.cpp.o 
/usr/bin/c++ -DUNITY_INCLUDE_CONFIG_H -I/home/vbox/led_manager/host_test/build/config -I/home/vbox/led_manager/include -I/home/vbox/esp/esp-idf/tools/mocks/freertos/include -I/home/vbox/esp/esp-idf/components/freertos/FreeRTOS-Kernel/include -I/home/vbox/esp/esp-idf/components/freertos/esp_additions/include -I/home/vbox/esp/esp-idf/components/freertos/esp_additions/include/freertos -I/home/vbox/esp/esp-idf/components/freertos/FreeRTOS-Kernel/include/freertos -I/home/vbox/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/linux/include -I/home/vbox/led_manager/host_test/build/esp-idf/freertos/mocks -I/home/vbox/esp/esp-idf/components/log/include -I/home/vbox/esp/esp-idf/components/esp_rom/include -I/home/vbox/esp/esp-idf/components/esp_rom/include/linux -I/home/vbox/esp/esp-idf/tools/mocks/soc/include -I/home/vbox/esp/esp-idf/components/esp_common/include -I/home/vbox/esp/esp-idf/components/cmock/CMock/src -I/home/vbox/esp/esp-idf/components/unity/include -I/home/vbox/esp/esp-idf/components/unity/unity/src -I/home/vbox/led_manager/host_test/managed_components/component_base/include -I/home/vbox/esp/esp-idf/components/esp_event/include -I/home/vbox/esp/esp-idf/components/linux/include -I/home/vbox/esp/esp-idf/components/driver/include -I/home/vbox/esp/esp-idf/components/driver/include/driver -I/home/vbox/esp/esp-idf/tools/mocks/hal/include -I/home/vbox/esp/esp-idf/tools/mocks/esp_hw_support/include -I/home/vbox/led_manager/host_test/build/esp-idf/driver/mocks -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -Og -fmacro-prefix-map=/home/vbox/led_manager/host_test=. -fmacro-prefix-map=/home/vbox/esp/esp-idf=/IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++20 -fexceptions -fno-rtti -D_GNU_SOURCE -DIDF_VER=\"v5.0-161-g76804f3d42\" -DESP_PLATFORM -DSPI_MOCK -std=gnu++20 -MD -MT esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/SerialLed.cpp.o -MF esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/SerialLed.cpp.o.d -o esp-idf/led_manager/CMakeFiles/__idf_led_manager.dir/SerialLed.cpp.o -c /home/vbox/led_manager/SerialLed.cpp
In file included from /home/vbox/esp/esp-idf/components/driver/include/driver/rmt_common.h:11,
                 from /home/vbox/esp/esp-idf/components/driver/include/driver/rmt_tx.h:12,
                 from /home/vbox/led_manager/include/SerialLed.hpp:30,
                 from /home/vbox/led_manager/SerialLed.cpp:29:
/home/vbox/esp/esp-idf/components/driver/include/driver/rmt_types.h:12:10: fatal error: hal/rmt_types.h: No such file or directory
   12 | #include "hal/rmt_types.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
[32/36] Building C object esp-idf/driver/CMakeFiles/__idf_driver.dir/mocks/Mocki2c.c.oninja: build stopped: subcommand failed.
HINT: Please make sure that the header name is correct. Also please check if you've specified all component dependencies with 'idf_component_register(REQUIRES ...)'. If the component is not present then it should be added by the IDF Component Manager. For more information run 'idf.py docs -sp api-guides/build-system.html'.
Also, please check if the header file has been removed, renamed or relocated - refer to the migration guide for more information.
ninja failed with exit code 1, output of the command is in the /home/vbox/led_manager/host_test/build/log/idf_py_stderr_output_21673 and /home/vbox/led_manager/host_test/build/log/idf_py_stdout_output_21673

More Information.

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Ah I missed those docs as they are not in the v5.0 stable docs, thanks for the links and details. I will apply the supplied patch and see how it goes. Thanks