From 22b4c95d1ed2e2144d6e46a53c3d02c77ee38296 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Tue, 27 Nov 2018 09:45:21 +0800 Subject: [PATCH 1/3] ldgen: add traceback in case of exception --- tools/ldgen/ldgen.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/ldgen/ldgen.py b/tools/ldgen/ldgen.py index ca12fe8e8..25ce86e3c 100755 --- a/tools/ldgen/ldgen.py +++ b/tools/ldgen/ldgen.py @@ -17,6 +17,8 @@ import argparse import os +import traceback +import sys from fragments import FragmentFileModel from sdkconfig import SDKConfig @@ -95,6 +97,9 @@ def main(): print("linker script generation failed for %s\nERROR: %s" % (input_file.name, e.message)) # Delete the file so the entire build will fail; and not use an outdated script. os.remove(output_file.name) + # Print traceback and exit + traceback.print_exc() + sys.exit(1) if __name__ == "__main__": main() \ No newline at end of file From a9c784339d2474994d454f9fc4b0056bedc475fc Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Tue, 27 Nov 2018 10:50:51 +0800 Subject: [PATCH 2/3] ldgen: fix error on parsing archive from sections info --- tools/ldgen/generation.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/ldgen/generation.py b/tools/ldgen/generation.py index f3ee5f2c8..3dc14de63 100644 --- a/tools/ldgen/generation.py +++ b/tools/ldgen/generation.py @@ -581,8 +581,6 @@ and names """ class SectionsInfo(dict): - PATH = Optional("/") + ZeroOrMore(Regex(r"[^/.]+") + Literal("/")) - __info = collections.namedtuple("__info", "filename content") def __init__(self): @@ -591,8 +589,8 @@ class SectionsInfo(dict): def add_sections_info(self, sections_info_file): first_line = sections_info_file.readline() - archive = Literal("In archive").suppress() + SectionsInfo.PATH.suppress() + Fragment.ENTITY.setResultsName("archive") + Literal(":").suppress() - parser = archive + archive_path = Literal("In archive").suppress() + Regex(r"[^:]+").setResultsName("archive_path") + Literal(":").suppress() + parser = archive_path results = None @@ -601,7 +599,8 @@ class SectionsInfo(dict): except ParseException as p: raise ParseException("File " + sections_info_file.name + " is not a valid sections info file. " + p.message) - self.sections[results.archive] = SectionsInfo.__info(sections_info_file.name, sections_info_file.read()) + archive = os.path.basename(results.archive_path) + self.sections[archive] = SectionsInfo.__info(sections_info_file.name, sections_info_file.read()) def _get_infos_from_file(self, info): # Object file line: '{object}: file format elf32-xtensa-le' From 4c83f456ab082af4802a227d8381b5696998f781 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Tue, 27 Nov 2018 13:26:15 +0800 Subject: [PATCH 3/3] cmake: generate sections info for all static libs as in make --- tools/cmake/components.cmake | 2 ++ tools/cmake/ldgen.cmake | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/tools/cmake/components.cmake b/tools/cmake/components.cmake index cec044358..82d0fbcaa 100644 --- a/tools/cmake/components.cmake +++ b/tools/cmake/components.cmake @@ -62,6 +62,8 @@ function(register_component) set(include_type PUBLIC) set_property(TARGET ${COMPONENT_TARGET} PROPERTY OUTPUT_NAME ${COMPONENT_NAME}) + + ldgen_generate_sections_info(${COMPONENT_TARGET}) else() add_library(${COMPONENT_TARGET} INTERFACE) # header-only component set(include_type INTERFACE) diff --git a/tools/cmake/ldgen.cmake b/tools/cmake/ldgen.cmake index b69ff3bfb..4dc405436 100644 --- a/tools/cmake/ldgen.cmake +++ b/tools/cmake/ldgen.cmake @@ -22,7 +22,12 @@ function(ldgen_add_fragment_files target fragment_files) endforeach() set_property(TARGET ldgen APPEND PROPERTY FRAGMENT_FILES ${fragment_files_full_path}) +endfunction() +# ldgen_generate_sections_info +# +# Generate sections info for specified target to be used in linker script generation +function(ldgen_generate_sections_info target) get_filename_component(target_sections_info ${CMAKE_CURRENT_BINARY_DIR}/${target}.sections_info ABSOLUTE) add_custom_command(