Просмотр исходного кода

ci: enabled ldgen mapping check in ci

Renz Bagaporo 5 лет назад
Родитель
Сommit
ffefe603ae

+ 1 - 0
tools/ci/check_ldgen_mapping_exceptions.txt

@@ -0,0 +1 @@
+libc

+ 3 - 1
tools/ci/config/build.yml

@@ -57,7 +57,8 @@ build_ssc_esp32s2beta:
 build_esp_idf_tests_make:
   extends: .build_esp_idf_unit_test_template
   variables:
-      PYTHON_VER: 3
+    PYTHON_VER: 3
+    LDGEN_CHECK_MAPPING: 0
   script:
     - export EXTRA_CFLAGS=${PEDANTIC_CFLAGS}
     - export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS}
@@ -108,6 +109,7 @@ build_examples_make:
       - $LOG_PATH
     expire_in: 4 days
   variables:
+    LDGEN_CHECK_MAPPING: 0
     LOG_PATH: "$CI_PROJECT_DIR/log_examples_make"
   only:
     # Here both 'variables' and 'refs' conditions are given. They are combined with "AND" logic.

+ 7 - 0
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}
     )
 

+ 9 - 4
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 + "'."