Merge branch 'feature/use_libraries_directly_with_ldgen' into 'master'

Pass libraries as arguments to ldgen directly

See merge request idf/esp-idf!4887
This commit is contained in:
Angus Gratton
2019-04-29 08:49:42 +08:00
5 changed files with 66 additions and 76 deletions
+4 -4
View File
@@ -573,8 +573,8 @@ class SectionsInfo(dict):
def __init__(self):
self.sections = dict()
def add_sections_info(self, sections_info_file):
first_line = sections_info_file.readline()
def add_sections_info(self, sections_info_dump):
first_line = sections_info_dump.readline()
archive_path = (Literal("In archive").suppress() +
# trim the last character from archive_path, :
@@ -587,10 +587,10 @@ class SectionsInfo(dict):
try:
results = parser.parseString(first_line)
except ParseException as p:
raise ParseException("File " + sections_info_file.name + " is not a valid sections info file. " + p.message)
raise ParseException("Parsing sections info for library " + sections_info_dump.name + " failed. " + p.message)
archive = os.path.basename(results.archive_path)
self.sections[archive] = SectionsInfo.__info(sections_info_file.name, sections_info_file.read())
self.sections[archive] = SectionsInfo.__info(sections_info_dump.name, sections_info_dump.read())
def _get_infos_from_file(self, info):
# Object file line: '{object}: file format elf32-xtensa-le'
+16 -13
View File
@@ -18,12 +18,14 @@
import argparse
import sys
import tempfile
import subprocess
from fragments import FragmentFile
from sdkconfig import SDKConfig
from generation import GenerationModel, TemplateModel, SectionsInfo
from ldgen_common import LdGenFailure
from pyparsing import ParseException, ParseFatalException
from io import StringIO
def main():
@@ -42,9 +44,9 @@ def main():
nargs="+")
argparser.add_argument(
"--sections", "-s",
"--libraries-file",
type=argparse.FileType("r"),
help="Library sections info")
help="File that contains the list of libraries in the build")
argparser.add_argument(
"--output", "-o",
@@ -64,27 +66,28 @@ def main():
action='append', default=[],
help='Environment to set when evaluating the config file', metavar='NAME=VAL')
argparser.add_argument(
"--objdump",
help="Path to toolchain objdump")
args = argparser.parse_args()
input_file = args.input
fragment_files = [] if not args.fragments else args.fragments
libraries_file = args.libraries_file
config_file = args.config
output_path = args.output
kconfig_file = args.kconfig
sections = args.sections
objdump = args.objdump
try:
sections_infos = SectionsInfo()
if sections:
section_info_contents = [s.strip() for s in sections.read().split("\n")]
section_info_contents = [s for s in section_info_contents if s]
else:
section_info_contents = []
for sections_info_file in section_info_contents:
with open(sections_info_file) as sections_info_file_obj:
sections_infos.add_sections_info(sections_info_file_obj)
for library in libraries_file:
library = library.strip()
if library:
dump = StringIO(subprocess.check_output([objdump, "-h", library]).decode())
dump.name = library
sections_infos.add_sections_info(dump)
generation_model = GenerationModel()