Tools: compile with debug symbols and provide path to sources

This commit is contained in:
Peter Barker 2023-05-30 14:48:05 +10:00 committed by Peter Barker
parent d2af1f0fa1
commit 2489a2bec4

View File

@ -19,6 +19,7 @@ Output is placed into ../ELF_DIFF_[VEHICLE_NAME]
import copy
import optparse
import os
import pathlib
import shutil
import string
import subprocess
@ -317,6 +318,9 @@ class SizeCompareBranches(object):
if extra_hwdef is not None:
waf_configure_args.extend(["--extra-hwdef", extra_hwdef])
if self.run_elf_diff:
waf_configure_args.extend(["--debug-symbols"])
if jobs is None:
jobs = self.jobs
if jobs is not None:
@ -348,6 +352,8 @@ class SizeCompareBranches(object):
self.run_waf(bootloader_waf_configure_args, show_output=False, source_dir=source_dir)
self.run_waf([v], show_output=False, source_dir=source_dir)
self.run_program("rsync", ["rsync", "-ap", "build/", outdir], cwd=source_dir)
if source_dir is not None:
pathlib.Path(outdir, "scb_sourcepath.txt").write_text(source_dir)
def vehicles_to_build_for_board_info(self, board_info):
vehicles_to_build = []
@ -450,6 +456,7 @@ class SizeCompareBranches(object):
tasks.append((board, self.master_commit, outdir_1, vehicles_to_build, self.extra_hwdef_master))
outdir_2 = os.path.join(tmpdir, "out-branch-%s" % (board,))
tasks.append((board, self.branch, outdir_2, vehicles_to_build, self.extra_hwdef_branch))
self.tasks = tasks
if self.parallel_copies is not None:
self.run_build_tasks_in_parallel(tasks)
@ -487,9 +494,22 @@ class SizeCompareBranches(object):
"--old_alias", "%s %s" % (master_branch, elf_filename),
"--new_alias", "%s %s" % (branch, elf_filename),
"--html_dir", "../ELF_DIFF_%s_%s" % (board, vehicle),
]
try:
master_source_prefix = result_master["vehicle"][vehicle]["source_path"]
branch_source_prefix = result_branch["vehicle"][vehicle]["source_path"]
elf_diff_commandline.extend([
"--old_source_prefix", master_source_prefix,
"--new_source_prefix", branch_source_prefix,
])
except KeyError:
pass
elf_diff_commandline.extend([
os.path.join(master_elf_dir, elf_filename),
os.path.join(new_elf_dir, elf_filename)
]
])
self.run_program("SCB", elf_diff_commandline)
@ -614,6 +634,8 @@ class SizeCompareBranches(object):
"vehicle": {},
}
have_source_trees = self.parallel_copies is not None and len(self.tasks) <= self.parallel_copies
for vehicle in vehicles_to_build:
if vehicle == 'bootloader' and board in self.bootloader_blacklist:
continue
@ -621,13 +643,21 @@ class SizeCompareBranches(object):
result["vehicle"][vehicle] = {}
v = result["vehicle"][vehicle]
v["bin_filename"] = self.vehicle_map[vehicle] + '.bin'
v["bin_dir"] = os.path.join(outdir, board, "bin")
elf_dirname = "bin"
if vehicle == 'bootloader':
# elfs for bootloaders are in the bootloader directory...
elf_dirname = "bootloader"
elf_dir = os.path.join(outdir, board, elf_dirname)
elf_basedir = outdir
if have_source_trees:
try:
v["source_path"] = pathlib.Path(outdir, "scb_sourcepath.txt").read_text()
elf_basedir = os.path.join(v["source_path"], 'build')
self.progress("Have source trees")
except FileNotFoundError:
pass
v["bin_dir"] = os.path.join(elf_basedir, board, "bin")
elf_dir = os.path.join(elf_basedir, board, elf_dirname)
v["elf_dir"] = elf_dir
v["elf_filename"] = self.vehicle_map[vehicle]