From d41e0f05d3ae13a8f3af38aa851bf336a383383e Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Fri, 14 Feb 2025 15:04:37 -0500 Subject: [PATCH 1/2] Do not always overwrite the clang coverage driver. Ninja seems to look at timestamps, so attempt to not change timestamps, so that compiles are not re-run. --- scripts/build/clang_coverage_wrapper.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/build/clang_coverage_wrapper.py b/scripts/build/clang_coverage_wrapper.py index a8b2cc98abbfd5..aa4d9dad0edb0f 100644 --- a/scripts/build/clang_coverage_wrapper.py +++ b/scripts/build/clang_coverage_wrapper.py @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging +import os +import sys import click import coloredlogs @@ -80,9 +82,17 @@ def main(log_level, no_log_timestamps, output, raw_profile_filename): log_fmt = "%(levelname)-7s %(message)s" coloredlogs.install(level=__LOG_LEVELS__[log_level], fmt=log_fmt) + expected_output = jinja2.Template(_CPP_TEMPLATE).render(raw_profile_filename=raw_profile_filename) + if os.path.exists(output): + with open(output, 'rt') as f: + if f.read() == expected_output: + logging.info("File %s is already as expected. Will not re-write", output) + sys.exit(0) + + logging.info("Writing output to %s (profile name: %s)", output, raw_profile_filename) with open(output, "wt") as f: - f.write(jinja2.Template(_CPP_TEMPLATE).render(raw_profile_filename=raw_profile_filename)) + f.write(expected_output) logging.debug("Writing completed") From b9a980f473c34b4e1cc29b04a8b7d78312ee4100 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 14 Feb 2025 20:24:28 +0000 Subject: [PATCH 2/2] Restyled by autopep8 --- scripts/build/clang_coverage_wrapper.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/build/clang_coverage_wrapper.py b/scripts/build/clang_coverage_wrapper.py index aa4d9dad0edb0f..2497951069e6d7 100644 --- a/scripts/build/clang_coverage_wrapper.py +++ b/scripts/build/clang_coverage_wrapper.py @@ -89,7 +89,6 @@ def main(log_level, no_log_timestamps, output, raw_profile_filename): logging.info("File %s is already as expected. Will not re-write", output) sys.exit(0) - logging.info("Writing output to %s (profile name: %s)", output, raw_profile_filename) with open(output, "wt") as f: f.write(expected_output)