From 7d6cead15db9b3f86834ad238548ec28438fd2a7 Mon Sep 17 00:00:00 2001 From: Lukas Einhaus Date: Fri, 25 Oct 2024 16:09:19 +0200 Subject: [PATCH 01/32] fix(cmake): fix custom targets --- cmake/custom_targets.cmake | 39 +++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/cmake/custom_targets.cmake b/cmake/custom_targets.cmake index ddd84a40..639f41a9 100644 --- a/cmake/custom_targets.cmake +++ b/cmake/custom_targets.cmake @@ -11,6 +11,18 @@ function(elastic_ai_lib) # DEPS: all libaries, that the current library depends on. These need to be specified via # the elastic_ai_lib function as well. # + # + # Example: + # + # elastic_ai_lib(NAME Flash + # SOURCES Flash.c + # DEPS Common Spi Sleep) + # + # elastic_ai_lib(NAME NeedsFlash + # SOURCES ImplementationThatNeedsFlash.c + # DEPS Flash Common Spi Sleep) + # + # # We assume that public headers live inside an `include` directory in the package. # # @@ -18,38 +30,35 @@ function(elastic_ai_lib) # 1. __hdrs : a pure INTERFACE library containing only the public headers of this # module. These hdr only libs will be automatically linked when defining a new lib that depends # on the current one. - # 2. __nodeps : a library that contains the implementation in addition to 1, linking against all + # 2. : a library that contains the implementation in addition to 1, linking against all # all hdr libs of the specified dependencies. - # 3. : a library carrying all transitive dependencies. # # If you need to link a lib A against a library B that was not defined as an elastic_ai_lib # you will want to do it like this in most cases: # - # elastic_ai(NAME A SOURCES A.c) + # elastic_ai_lib(NAME A SOURCES A.c) # target_link_libraries(A PRIVATE B) - # target_include_directories(A__nodeps PRIVATE get_property(TARGET B INTERFACE_INCLUDE_DIRECTORY)) + # target_include_directories(A PRIVATE get_property(TARGET B INTERFACE_INCLUDE_DIRECTORY)) set(oneValueArgs NAME) set(multiValueArgs SOURCES DEPS) cmake_parse_arguments(PARSE_ARGV 0 arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ) - if(NOT ${arg_DEPS}) + if(NOT arg_DEPS) set(arg_DEPS "") endif () add_library(${arg_NAME}__hdrs INTERFACE) target_include_directories(${arg_NAME}__hdrs INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) - add_library(${arg_NAME}__nodeps ${arg_SOURCES}) - target_include_directories(${arg_NAME}__nodeps PRIVATE ${CMAKE_CURRENT_LIST_DIR}) + add_library(${arg_NAME} ${arg_SOURCES}) + target_include_directories(${arg_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}) set(hdrLibs "") foreach (lib ${DEPS}) list(APPEND hdrLibs ${lib}__hdrs) endforeach () - target_link_libraries(${arg_NAME}__nodeps PUBLIC ${arg_NAME}__hdrs) - target_link_libraries(${arg_NAME}__nodeps PRIVATE ${hdrLibs}) + target_link_libraries(${arg_NAME} PUBLIC ${arg_NAME}__hdrs) + target_link_libraries(${arg_NAME} PRIVATE ${hdrLibs}) - add_library(${arg_NAME} INTERFACE) - target_link_libraries(${arg_NAME} INTERFACE ${arg_NAME}__nodeps ${DEPS}) endfunction() @@ -65,20 +74,20 @@ function(elastic_ai_unit_test) cmake_parse_arguments(PARSE_ARGV 0 arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ) - if(NOT ${arg_MORE_SOURCES}) + if(NOT arg_MORE_SOURCES) set(arg__MORE_SOURCES "") endif () - if(NOT ${arg_MORE_LIBS}) + if(NOT arg_MORE_LIBS) set(arg_MORE_LIBS "") endif () - if (NOT ${arg_DEPS}) + if (NOT arg_DEPS) set(arg_DEPS "") endif () add_executable(unit-test_${arg_LIB_UNDER_TEST} Unittest${arg_LIB_UNDER_TEST}.c) target_sources(unit-test_${arg_LIB_UNDER_TEST} PRIVATE ${arg_MORE_SOURCES}) - target_link_libraries(unit-test_${arg_LIB_UNDER_TEST} ${arg_LIB_UNDER_TEST}__nodeps unity) + target_link_libraries(unit-test_${arg_LIB_UNDER_TEST} ${arg_LIB_UNDER_TEST} unity) add_test(unit-test_${arg_LIB_UNDER_TEST} unit-test_${arg_LIB_UNDER_TEST}) target_link_libraries(unit-test_${arg_LIB_UNDER_TEST} ${arg_MORE_LIBS}) endfunction() From 950a596d408559f6f89d071003dee383691f1121 Mon Sep 17 00:00:00 2001 From: Lukas Einhaus Date: Mon, 28 Oct 2024 13:51:42 +0100 Subject: [PATCH 02/32] wip(cmake): make the first three unit tests work --- .idea/cmake.xml | 12 -- .idea/runConfigurations/Unit_Tests.xml | 2 +- .idea/runConfigurations/all.xml | 2 +- CMakeLists.txt | 103 ++++----- cmake/custom_targets.cmake | 87 +++++--- cmake/env5.cmake | 4 + cmake/host.cmake | 4 + cmake/no_elastic_node.cmake | 1 + cmake/pico_sdk_import.cmake | 86 ++++++++ cmake/pico_targets.cmake | 24 +++ cmake/set_build_target.cmake | 9 + cmake/third_party_deps.cmake | 55 +++++ enV5_init.cmake | 27 --- helpers.cmake | 122 ----------- src/CMakeLists.txt | 10 + src/common/CMakeLists.txt | 6 +- src/filesystem/CMakeLists.txt | 14 +- src/flash/CMakeLists.txt | 14 +- src/flash/Flash.c | 4 +- src/fpga/CMakeLists.txt | 1 + .../fpgaConfigurationHandler/CMakeLists.txt | 26 ++- .../FpgaConfigurationHandler.c | 4 +- .../FpgaConfigurationHandlerHTTP.c | 3 +- .../FpgaConfigurationHandlerInternal.h | 2 +- src/fpga/middleware/CMakeLists.txt | 14 +- src/fpga/stub/CMakeLists.txt | 40 +--- src/fpga/stub/stub_defs.h | 18 ++ src/fpga/stub/stub_defs_v1.h | 17 ++ src/fpga/stub/stub_defs_v2.h | 17 ++ src/hal/enV5HwConfiguration/CMakeLists.txt | 17 +- src/hal/enV5HwController/CMakeLists.txt | 23 +- src/hal/gpio/CMakeLists.txt | 13 +- src/hal/i2c/CMakeLists.txt | 14 +- src/hal/qxspi/CMakeLists.txt | 14 +- src/hal/sleep/CMakeLists.txt | 12 +- src/hal/spi/CMakeLists.txt | 14 +- src/hal/time/CMakeLists.txt | 15 +- src/hal/uart/CMakeLists.txt | 15 +- src/network/CMakeLists.txt | 2 +- src/network/atCommands/CMakeLists.txt | 4 +- src/network/broker/CMakeLists.txt | 33 +-- src/network/config/CMakeLists.txt | 11 +- src/network/esp/CMakeLists.txt | 17 +- src/network/http/CMakeLists.txt | 18 +- src/network/wifi/CMakeLists.txt | 26 +-- src/rtos/CMakeLists.txt | 7 + src/sensor/adxl345b/CMakeLists.txt | 28 +-- src/sensor/bmi323/CMakeLists.txt | 34 +-- src/sensor/pac193x/CMakeLists.txt | 10 + src/sensor/pac193x/Pac193x.c | 11 +- src/sensor/sht3x/CMakeLists.txt | 20 +- src/sensor/sht3x/Sht3x.c | 4 +- src/sensor/sht3x/Sht3xInternal.h | 2 +- src/usb_protocol/CMakeLists.txt | 37 ++-- test/unit/CMakeLists.txt | 199 +++++++++++------- ...r.c => UnitTestFpgaConfigurationHandler.c} | 0 .../{UnittestPac193x.c => UnitTestPac193.c} | 3 +- .../unit/{UnittestSht3x.c => UnitTestSht3x.c} | 0 test/unit/dummies/flash/CMakeLists.txt | 12 +- test/unit/dummies/gpio/CMakeLists.txt | 4 + test/unit/dummies/http/CMakeLists.txt | 12 +- test/unit/dummies/i2c/CMakeLists.txt | 16 +- test/unit/dummies/i2c/I2c.c | 2 +- test/unit/dummies/sleep/CMakeLists.txt | 8 +- 64 files changed, 731 insertions(+), 654 deletions(-) delete mode 100644 .idea/cmake.xml create mode 100644 cmake/env5.cmake create mode 100644 cmake/host.cmake create mode 100644 cmake/no_elastic_node.cmake create mode 100644 cmake/pico_sdk_import.cmake create mode 100644 cmake/pico_targets.cmake create mode 100644 cmake/set_build_target.cmake create mode 100644 cmake/third_party_deps.cmake delete mode 100644 enV5_init.cmake delete mode 100644 helpers.cmake create mode 100644 src/CMakeLists.txt create mode 100644 src/fpga/stub/stub_defs.h create mode 100644 src/fpga/stub/stub_defs_v1.h create mode 100644 src/fpga/stub/stub_defs_v2.h rename test/unit/{UnittestFpgaConfigurationHandler.c => UnitTestFpgaConfigurationHandler.c} (100%) rename test/unit/{UnittestPac193x.c => UnitTestPac193.c} (99%) rename test/unit/{UnittestSht3x.c => UnitTestSht3x.c} (100%) diff --git a/.idea/cmake.xml b/.idea/cmake.xml deleted file mode 100644 index 818adc3f..00000000 --- a/.idea/cmake.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Unit_Tests.xml b/.idea/runConfigurations/Unit_Tests.xml index 0c3de4f4..d758d7ee 100644 --- a/.idea/runConfigurations/Unit_Tests.xml +++ b/.idea/runConfigurations/Unit_Tests.xml @@ -1,5 +1,5 @@ - +