From ec8f38c9da3905fb529d773f523c12790b5e728b Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 10 Jan 2023 17:47:20 +0100 Subject: [PATCH] build system: generate the partition table by default for linux target This fixes the issue that "idf.py partition-table" had to be run manually in order for the partition table to be generated, when building for linux target. --- .../partition_api_test/CMakeLists.txt | 2 -- .../host_test/partition_api_test/README.md | 3 +-- .../host_test/nvs_host_test/CMakeLists.txt | 2 -- components/partition_table/CMakeLists.txt | 18 ++++++++++++++++++ components/spiffs/host_test/CMakeLists.txt | 3 ++- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/components/esp_partition/host_test/partition_api_test/CMakeLists.txt b/components/esp_partition/host_test/partition_api_test/CMakeLists.txt index 3986bdb314..469a614a14 100644 --- a/components/esp_partition/host_test/partition_api_test/CMakeLists.txt +++ b/components/esp_partition/host_test/partition_api_test/CMakeLists.txt @@ -7,5 +7,3 @@ set(COMPONENTS main) list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") project(partition_api_test) - -add_dependencies(partition_api_test.elf partition-table) diff --git a/components/esp_partition/host_test/partition_api_test/README.md b/components/esp_partition/host_test/partition_api_test/README.md index 8e2e38e920..73c2e9762f 100644 --- a/components/esp_partition/host_test/partition_api_test/README.md +++ b/components/esp_partition/host_test/partition_api_test/README.md @@ -8,9 +8,8 @@ Source the IDF environment as usual. Once this is done, build the application: ```bash -idf.py build partition-table +idf.py build ``` -Note that for the time being, `partition-table` target needs to be built manually. # Run ```bash diff --git a/components/nvs_flash/host_test/nvs_host_test/CMakeLists.txt b/components/nvs_flash/host_test/nvs_host_test/CMakeLists.txt index 655d83dcf0..cd3f3ebece 100644 --- a/components/nvs_flash/host_test/nvs_host_test/CMakeLists.txt +++ b/components/nvs_flash/host_test/nvs_host_test/CMakeLists.txt @@ -8,5 +8,3 @@ set(COMPONENTS main) list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") project(nvs_host_test) - -add_dependencies(nvs_host_test.elf partition-table) diff --git a/components/partition_table/CMakeLists.txt b/components/partition_table/CMakeLists.txt index 31260c1f12..f386028612 100644 --- a/components/partition_table/CMakeLists.txt +++ b/components/partition_table/CMakeLists.txt @@ -96,6 +96,24 @@ else() "Either change partition table in menuconfig or create this input file.") endif() +if(${target} STREQUAL "linux" AND EXISTS ${partition_csv}) + # partition-table target is normally invoked as a dependency of 'flash' target. + # However, when building for "linux" target, 'flash' target doesn't exist, + # so we need to attach the partition table build to the executable target. + # + # The problem is that the executable target is not yet defined + # when the component CMakeLists.txt file is evaluated, so we + # can only get it as a generator expression. But generator expressions + # can't be used in 'add_dependencies': + # https://gitlab.kitware.com/cmake/cmake/-/issues/19467 + # + # Therefore attach partition-table to the internal __idf_build_target + # target. This is a hack, since that target name is an implementation detail + # of the build system. + + add_dependencies(__idf_build_target partition-table) +endif() + # Add signing steps if(CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME) if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES) diff --git a/components/spiffs/host_test/CMakeLists.txt b/components/spiffs/host_test/CMakeLists.txt index 03f7125aed..81a2485a61 100644 --- a/components/spiffs/host_test/CMakeLists.txt +++ b/components/spiffs/host_test/CMakeLists.txt @@ -22,4 +22,5 @@ set_property( DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES "../image.bin") -add_dependencies(host_test_spiffs.elf partition-table image.bin) + +add_dependencies(host_test_spiffs.elf image.bin)