From 4a3b21ca9ec9f17627ed144393318975af519532 Mon Sep 17 00:00:00 2001 From: Zebin Wu Date: Fri, 22 Dec 2023 22:53:44 +0800 Subject: [PATCH] esp32: update idf version to 5.1.2 --- .github/workflows/esp-idf-ci.yml | 2 +- README.md | 6 +-- README_CN.md | 6 +-- platform/esp/cmake/extension.cmake | 86 +++++++++++++++++++++++++++++- platform/esp/cmake/platform.cmake | 7 +++ 5 files changed, 99 insertions(+), 8 deletions(-) diff --git a/.github/workflows/esp-idf-ci.yml b/.github/workflows/esp-idf-ci.yml index 06aaaeb..da1823d 100644 --- a/.github/workflows/esp-idf-ci.yml +++ b/.github/workflows/esp-idf-ci.yml @@ -8,7 +8,7 @@ on: jobs: build: runs-on: ubuntu-latest - container: espressif/idf:v5.1 + container: espressif/idf:v5.1.2 steps: - name: Checkout code diff --git a/README.md b/README.md index 6cbb257..275d644 100644 --- a/README.md +++ b/README.md @@ -85,13 +85,13 @@ Option | Description #### Prepare -Set up the host environment and ESP-IDF as per the steps given [here](https://docs.espressif.com/projects/esp-idf/en/v5.1/get-started/index.html). +Set up the host environment and ESP-IDF as per the steps given [here](https://docs.espressif.com/projects/esp-idf/en/v5.1.2/get-started/index.html). -The currently tested ESP-IDF version is **v5.1**, switch to this version with the following command: +The currently tested ESP-IDF version is **v5.1.2**, switch to this version with the following command: ```bash git fetch --tag -git checkout v5.1 +git checkout v5.1.2 git submodule update ``` diff --git a/README_CN.md b/README_CN.md index f4bf511..968436c 100644 --- a/README_CN.md +++ b/README_CN.md @@ -91,13 +91,13 @@ homekit-bridge #### 准备 -根据ESP-IDF官方文档[快速入门](https://docs.espressif.com/projects/esp-idf/zh_CN/v5.1/get-started/index.html)准备环境。 +根据ESP-IDF官方文档[快速入门](https://docs.espressif.com/projects/esp-idf/zh_CN/v5.1.2/get-started/index.html)准备环境。 -目前经过测试的ESP-IDF版本为**v5.1**,通过以下命令切换到该版本: +目前经过测试的ESP-IDF版本为**v5.1.2**,通过以下命令切换到该版本: ```bash git fetch --tag -git checkout v5.1 +git checkout v5.1.2 git submodule update ``` diff --git a/platform/esp/cmake/extension.cmake b/platform/esp/cmake/extension.cmake index a189910..8c161e5 100644 --- a/platform/esp/cmake/extension.cmake +++ b/platform/esp/cmake/extension.cmake @@ -4,6 +4,74 @@ # you may not use this file except in compliance with the License. # See [CONTRIBUTORS.md] for the list of homekit-bridge project authors. +function(__component_info components output) + set(components_json "") + foreach(name ${components}) + __component_get_target(target ${name}) + __component_get_property(alias ${target} COMPONENT_ALIAS) + __component_get_property(prefix ${target} __PREFIX) + __component_get_property(dir ${target} COMPONENT_DIR) + __component_get_property(type ${target} COMPONENT_TYPE) + __component_get_property(lib ${target} COMPONENT_LIB) + __component_get_property(reqs ${target} REQUIRES) + __component_get_property(include_dirs ${target} INCLUDE_DIRS) + __component_get_property(priv_reqs ${target} PRIV_REQUIRES) + __component_get_property(managed_reqs ${target} MANAGED_REQUIRES) + __component_get_property(managed_priv_reqs ${target} MANAGED_PRIV_REQUIRES) + if("${type}" STREQUAL "LIBRARY") + set(file "$") + + # The idf_component_register function is converting each source file path defined + # in SRCS into absolute one. But source files can be also added with cmake's + # target_sources and have relative paths. This is used for example in log + # component. Let's make sure all source files have absolute path. + set(sources "") + get_target_property(srcs ${lib} SOURCES) + foreach(src ${srcs}) + get_filename_component(src "${src}" ABSOLUTE BASE_DIR "${dir}") + list(APPEND sources "${src}") + endforeach() + + else() + set(file "") + set(sources "") + endif() + + make_json_list("${reqs}" reqs) + make_json_list("${priv_reqs}" priv_reqs) + make_json_list("${managed_reqs}" managed_reqs) + make_json_list("${managed_priv_reqs}" managed_priv_reqs) + make_json_list("${include_dirs}" include_dirs) + make_json_list("${sources}" sources) + + string(JOIN "\n" component_json + " \"${name}\": {" + " \"alias\": \"${alias}\"," + " \"target\": \"${target}\"," + " \"prefix\": \"${prefix}\"," + " \"dir\": \"${dir}\"," + " \"type\": \"${type}\"," + " \"lib\": \"${lib}\"," + " \"reqs\": ${reqs}," + " \"priv_reqs\": ${priv_reqs}," + " \"managed_reqs\": ${managed_reqs}," + " \"managed_priv_reqs\": ${managed_priv_reqs}," + " \"file\": \"${file}\"," + " \"sources\": ${sources}," + " \"include_dirs\": ${include_dirs}" + " }" + ) + string(CONFIGURE "${component_json}" component_json) + if(NOT "${components_json}" STREQUAL "") + string(APPEND components_json ",\n") + endif() + string(APPEND components_json "${component_json}") + endforeach() + string(PREPEND components_json "{\n") + string(APPEND components_json "\n }") + set(${output} "${components_json}" PARENT_SCOPE) +endfunction() + # # Output the built components to the user. Generates files for invoking esp_idf_monitor # that doubles as an overview of some of the more important build properties. @@ -40,6 +108,7 @@ function(project_info test_components) endforeach() set(PROJECT_NAME ${CMAKE_PROJECT_NAME}) + idf_build_get_property(PROJECT_VER PROJECT_VER) idf_build_get_property(PROJECT_PATH PROJECT_DIR) idf_build_get_property(BUILD_DIR BUILD_DIR) idf_build_get_property(SDKCONFIG SDKCONFIG) @@ -47,6 +116,7 @@ function(project_info test_components) idf_build_get_property(PROJECT_EXECUTABLE EXECUTABLE) set(PROJECT_BIN ${CMAKE_PROJECT_NAME}.bin) idf_build_get_property(IDF_VER IDF_VER) + idf_build_get_property(common_component_reqs __COMPONENT_REQUIRES_COMMON) idf_build_get_property(sdkconfig_cmake SDKCONFIG_CMAKE) include(${sdkconfig_cmake}) @@ -64,8 +134,22 @@ function(project_info test_components) idf_build_get_property(build_dir BUILD_DIR) make_json_list("${build_components};${test_components}" build_components_json) make_json_list("${build_component_paths};${test_component_paths}" build_component_paths_json) + make_json_list("${common_component_reqs}" common_component_reqs_json) + + __component_info("${build_components};${test_components}" build_component_info_json) + + # The configure_file function doesn't process generator expressions, which are needed + # e.g. to get component target library(TARGET_LINKER_FILE), so the project_description + # file is created in two steps. The first step, with configure_file, creates a temporary + # file with cmake's variables substituted and unprocessed generator expressions. The second + # step, with file(GENERATE), processes the temporary file and substitute generator expression + # into the final project_description.json file. configure_file("${idf_path}/tools/cmake/project_description.json.in" - "${build_dir}/project_description.json") + "${build_dir}/project_description.json.templ") + file(READ "${build_dir}/project_description.json.templ" project_description_json_templ) + file(REMOVE "${build_dir}/project_description.json.templ") + file(GENERATE OUTPUT "${build_dir}/project_description.json" + CONTENT "${project_description_json_templ}") # Generate component dependency graph depgraph_generate("${build_dir}/component_deps.dot") diff --git a/platform/esp/cmake/platform.cmake b/platform/esp/cmake/platform.cmake index 18350c5..3e7dcf8 100644 --- a/platform/esp/cmake/platform.cmake +++ b/platform/esp/cmake/platform.cmake @@ -4,6 +4,9 @@ # you may not use this file except in compliance with the License. # See [CONTRIBUTORS.md] for the list of homekit-bridge project authors. +# required IDF version, some modules depend on specific IDF version +set(REQUIRED_IDF_VERSION 5.1.2) + # system api set(CONFIG_POSIX ON) @@ -20,6 +23,10 @@ set(BRIDGE_EMBEDFS_ROOT bridge_embedfs_root) include($ENV{IDF_PATH}/tools/cmake/idf.cmake) include(${CMAKE_CURRENT_LIST_DIR}/extension.cmake) +if(NOT $ENV{IDF_VERSION} STREQUAL ${REQUIRED_IDF_VERSION}) +message(FATAL_ERROR "IDF version must be v${REQUIRED_IDF_VERSION}, current version is v$ENV{IDF_VERSION}") +endif() + # Enable the component manager for regular projects if not explicitly disabled. if(NOT "$ENV{IDF_COMPONENT_MANAGER}" EQUAL "0") idf_build_set_property(IDF_COMPONENT_MANAGER 1)