Skip to content

Commit

Permalink
Do not always overwrite the clang coverage driver.
Browse files Browse the repository at this point in the history
Ninja seems to look at timestamps, so attempt to not change
timestamps, so that compiles are not re-run.
  • Loading branch information
andy31415 committed Feb 14, 2025
1 parent 9acb856 commit d41e0f0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/build/clang_coverage_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit d41e0f0

Please sign in to comment.