Merge branch 'feature/improve_chip_target_detection' into 'master'

tools: Improve chip target detection

Closes IDF-3751

See merge request espressif/esp-idf!15691
pull/7855/head
Roland Dobai 2021-11-05 15:31:32 +00:00
commit b1817115ce
2 zmienionych plików z 12 dodań i 2 usunięć

Wyświetl plik

@ -445,7 +445,11 @@ macro(project project_name)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(mapfile "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.map")
target_link_libraries(${project_elf} "-Wl,--cref" "-Wl,--Map=\"${mapfile}\"")
set(idf_target "${IDF_TARGET}")
string(TOUPPER ${idf_target} idf_target)
target_link_libraries(${project_elf} "-Wl,--cref" "-Wl,--defsym=IDF_TARGET_${idf_target}=0"
"-Wl,--Map=\"${mapfile}\"")
unset(idf_target)
endif()
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY

Wyświetl plik

@ -263,12 +263,18 @@ def detect_target_chip(map_file: Iterable) -> str:
''' Detect target chip based on the target archive name in the linker script part of the MAP file '''
scan_to_header(map_file, 'Linker script and memory map')
RE_TARGET = re.compile(r'project_elf_src_(.*)\.c.obj')
RE_TARGET = re.compile(r'IDF_TARGET_(\S*) =')
# For back-compatible with cmake in idf version before 5.0
RE_TARGET_CMAKEv4x = re.compile(r'project_elf_src_(\S*)\.c.obj')
# For back-compatible with make
RE_TARGET_MAKE = re.compile(r'^LOAD .*?/xtensa-([^-]+)-elf/')
for line in map_file:
match_target = RE_TARGET.search(line)
if match_target:
return match_target.group(1).lower()
match_target = RE_TARGET_CMAKEv4x.search(line)
if match_target:
return match_target.group(1)