Skip to content

Commit 071c357

Browse files
committed
Tools: size_compare_branches.py: strip elf files for identical comparison
1 parent a325c0e commit 071c357

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Tools/scripts/size_compare_branches.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,18 @@ def gather_results_for_task(self, task):
746746

747747
return result
748748

749+
def create_stripped_elf(self, path, bin_prefix="arm-none-eabi"):
750+
stripped_path = f"{path}-stripped"
751+
shutil.copy(path, stripped_path)
752+
753+
strip = "strip"
754+
if bin_prefix is not None:
755+
strip = "-".join([bin_prefix, strip])
756+
757+
self.run_program("strip", [strip, stripped_path])
758+
759+
return stripped_path
760+
749761
def compare_results(self, result_master, result_branch):
750762
ret = {}
751763
for vehicle in result_master["vehicle"].keys():
@@ -760,14 +772,21 @@ def compare_results(self, result_master, result_branch):
760772
new_path = os.path.join(new_bin_dir, bin_filename)
761773
master_size = os.path.getsize(master_path)
762774
new_size = os.path.getsize(new_path)
775+
identical = self.files_are_identical(master_path, new_path)
763776
except FileNotFoundError:
764777
elf_filename = result_master["vehicle"][vehicle]["elf_filename"]
765778
master_path = os.path.join(master_bin_dir, elf_filename)
766779
new_path = os.path.join(new_bin_dir, elf_filename)
767780
master_size = os.path.getsize(master_path)
768781
new_size = os.path.getsize(new_path)
769782

770-
identical = self.files_are_identical(master_path, new_path)
783+
identical = self.files_are_identical(master_path, new_path)
784+
if not identical:
785+
# try stripping the files and *then* comparing.
786+
# This treats symbol renames as then "identical".
787+
master_path_stripped = self.create_stripped_elf(master_path)
788+
new_path_stripped = self.create_stripped_elf(new_path)
789+
identical = self.files_are_identical(master_path_stripped, new_path_stripped)
771790

772791
board = result_master["board"]
773792
ret[vehicle] = SizeCompareBranchesResult(board, vehicle, new_size - master_size, identical)

0 commit comments

Comments
 (0)