Merge pull request #7874 from yanrayw/7360-code-size-improvement

code_size_compare.py: run make clean before build libraries
diff --git a/scripts/code_size_compare.py b/scripts/code_size_compare.py
index 3bd3e4c..0ed2899 100755
--- a/scripts/code_size_compare.py
+++ b/scripts/code_size_compare.py
@@ -91,6 +91,7 @@
         """
         arch: architecture to measure code size on.
         config: configuration type to measure code size with.
+        sys_arch: host architecture.
         make_command: command to build library (Inferred from arch and config).
         """
         self.arch = arch
@@ -273,6 +274,7 @@
         self.old_rev = old_revision
         self.new_rev = new_revision
         self.git_command = "git"
+        self.make_clean = 'make clean'
         self.make_command = code_size_info.make_command
         self.fname_suffix = "-" + code_size_info.arch + "-" +\
                             code_size_info.config
@@ -307,6 +309,10 @@
         my_environment = os.environ.copy()
         try:
             subprocess.check_output(
+                self.make_clean, env=my_environment, shell=True,
+                cwd=git_worktree_path, stderr=subprocess.STDOUT,
+            )
+            subprocess.check_output(
                 self.make_command, env=my_environment, shell=True,
                 cwd=git_worktree_path, stderr=subprocess.STDOUT,
             )