feat: Added extra gdbinit file loading for reproducible build

This commit is contained in:
Aleksei Apaseev 2022-04-26 21:24:01 +08:00 committed by BOT
parent 4bd5c4ef53
commit e8cb6bd6b3

View File

@ -4,8 +4,10 @@
# SPDX-License-Identifier: Apache-2.0
#
import json
import logging
import os.path
from typing import Any
try:
from esp_coredump import CoreDump
@ -16,6 +18,18 @@ except ImportError:
from esp_coredump.cli_ext import parser
def get_prefix_map_gdbinit_path(prog_path): # type: (str) -> Any
build_dir = os.path.abspath(os.path.dirname(prog_path))
desc_path = os.path.abspath(os.path.join(build_dir, 'project_description.json'))
if not os.path.isfile(desc_path):
raise ValueError(f'{desc_path} does not exist. Please build the app with "idf.py build"')
with open(desc_path, 'r') as f:
project_desc = json.load(f)
return project_desc.get('debug_prefix_map_gdbinit')
def main(): # type: () -> None
args = parser.parse_args()
@ -32,6 +46,8 @@ def main(): # type: () -> None
logging.basicConfig(format='%(levelname)s: %(message)s', level=log_level)
kwargs = {k: v for k, v in vars(args).items() if v is not None}
# pass the extra_gdbinit_file if the build is reproducible
kwargs['extra_gdbinit_file'] = get_prefix_map_gdbinit_path(kwargs['prog'])
del(kwargs['debug'])
del(kwargs['operation'])