From 32206d3a7dd59b9993cb397704c40237115ed6df Mon Sep 17 00:00:00 2001 From: Renz Bagaporo Date: Thu, 12 Nov 2020 23:17:17 +0800 Subject: [PATCH] ci: enabled ldgen mapping check in ci --- components/esp_hw_support/linker.lf | 3 ++- components/spi_flash/linker.lf | 3 ++- tools/ci/check_ldgen_mapping_exceptions.txt | 1 + tools/ci/config/build.yml | 2 ++ tools/cmake/ldgen.cmake | 7 +++++++ tools/ldgen/generation.py | 13 +++++++++---- 6 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 tools/ci/check_ldgen_mapping_exceptions.txt diff --git a/components/esp_hw_support/linker.lf b/components/esp_hw_support/linker.lf index 9abbe07e38..1216b732d9 100644 --- a/components/esp_hw_support/linker.lf +++ b/components/esp_hw_support/linker.lf @@ -10,4 +10,5 @@ entries: rtc_pm (noflash_text) rtc_sleep (noflash_text) rtc_time (noflash_text) - rtc_wdt (noflash_text) + if IDF_TARGET_ESP32S3 = n: + rtc_wdt (noflash_text) diff --git a/components/spi_flash/linker.lf b/components/spi_flash/linker.lf index 6691173e54..25d9641143 100644 --- a/components/spi_flash/linker.lf +++ b/components/spi_flash/linker.lf @@ -1,7 +1,8 @@ [mapping:spi_flash] archive: libspi_flash.a entries: - spi_flash_rom_patch (noflash) + if IDF_TARGET_ESP32 = y: + spi_flash_rom_patch (noflash) spi_flash_chip_generic (noflash) spi_flash_chip_issi (noflash) spi_flash_chip_mxic (noflash) diff --git a/tools/ci/check_ldgen_mapping_exceptions.txt b/tools/ci/check_ldgen_mapping_exceptions.txt new file mode 100644 index 0000000000..0a9ce4f3e2 --- /dev/null +++ b/tools/ci/check_ldgen_mapping_exceptions.txt @@ -0,0 +1 @@ +libc diff --git a/tools/ci/config/build.yml b/tools/ci/config/build.yml index 2bff7b6f87..bc057aadb1 100644 --- a/tools/ci/config/build.yml +++ b/tools/ci/config/build.yml @@ -114,6 +114,7 @@ build_ssc_esp32s2: BUILD_SYSTEM: "cmake" TEST_TYPE: "unit_test" PYTHON_VER: 3 + LDGEN_CHECK_MAPPING: 0 script: - ${IDF_PATH}/tools/ci/find_apps_build_apps.sh - cd $CI_PROJECT_DIR/tools/unit-test-app @@ -156,6 +157,7 @@ build_esp_idf_tests_cmake_esp32c3: LOG_PATH: ${CI_PROJECT_DIR}/log_${TEST_PREFIX} BUILD_PATH: ${CI_PROJECT_DIR}/build_${TEST_PREFIX} PYTHON_VER: 3 + LDGEN_CHECK_MAPPING: 0 script: # it's not possible to build 100% out-of-tree and have the "artifacts" # mechanism work, but this is the next best thing diff --git a/tools/cmake/ldgen.cmake b/tools/cmake/ldgen.cmake index 22d7fe672d..1e4341e8b3 100644 --- a/tools/cmake/ldgen.cmake +++ b/tools/cmake/ldgen.cmake @@ -56,6 +56,12 @@ function(__ldgen_process_template template output) idf_build_get_property(config_env_path CONFIG_ENV_PATH) + if($ENV{LDGEN_CHECK_MAPPING}) + set(ldgen_check "--check-mapping" + "--check-mapping-exceptions=${idf_path}/tools/ci/check_ldgen_mapping_exceptions.txt") + message(STATUS "Mapping check enabled in ldgen") + endif() + add_custom_command( OUTPUT ${output} COMMAND ${python} ${idf_path}/tools/ldgen/ldgen.py @@ -67,6 +73,7 @@ function(__ldgen_process_template template output) --env-file "${config_env_path}" --libraries-file ${build_dir}/ldgen_libraries --objdump ${CMAKE_OBJDUMP} + ${ldgen_check} DEPENDS ${template} ${ldgen_fragment_files} ${ldgen_depends} ${SDKCONFIG} ) diff --git a/tools/ldgen/generation.py b/tools/ldgen/generation.py index 3d5f63ca05..edad0835f0 100644 --- a/tools/ldgen/generation.py +++ b/tools/ldgen/generation.py @@ -344,14 +344,19 @@ class GenerationModel: try: if not (obj == Mapping.MAPPING_ALL_OBJECTS and symbol is None and scheme_name == GenerationModel.DEFAULT_SCHEME): - if self.check_mappings and mapping.name not in self.check_mapping_exceptions: if not obj == Mapping.MAPPING_ALL_OBJECTS: - obj_section = sections_infos.get_obj_sections(archive, obj) - if not obj_section: - message = "'%s\:%s' not found" % (archive, obj) + obj_sections = sections_infos.get_obj_sections(archive, obj) + if not obj_sections: + message = "'%s:%s' not found" % (archive, obj) raise GenerationException(message, mapping) + if symbol: + obj_sym = fnmatch.filter(obj_sections, "*%s" % symbol) + if not obj_sym: + message = "'%s:%s %s' not found" % (archive, obj, symbol) + raise GenerationException(message, mapping) + self._add_mapping_rules(archive, obj, symbol, scheme_name, scheme_dictionary, mapping_rules) except KeyError: message = GenerationException.UNDEFINED_REFERENCE + " to scheme '" + scheme_name + "'."