Skip to content

Commit d41e0f0

Browse files
committed
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.
1 parent 9acb856 commit d41e0f0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/build/clang_coverage_wrapper.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
import logging
17+
import os
18+
import sys
1719

1820
import click
1921
import coloredlogs
@@ -80,9 +82,17 @@ def main(log_level, no_log_timestamps, output, raw_profile_filename):
8082
log_fmt = "%(levelname)-7s %(message)s"
8183
coloredlogs.install(level=__LOG_LEVELS__[log_level], fmt=log_fmt)
8284

85+
expected_output = jinja2.Template(_CPP_TEMPLATE).render(raw_profile_filename=raw_profile_filename)
86+
if os.path.exists(output):
87+
with open(output, 'rt') as f:
88+
if f.read() == expected_output:
89+
logging.info("File %s is already as expected. Will not re-write", output)
90+
sys.exit(0)
91+
92+
8393
logging.info("Writing output to %s (profile name: %s)", output, raw_profile_filename)
8494
with open(output, "wt") as f:
85-
f.write(jinja2.Template(_CPP_TEMPLATE).render(raw_profile_filename=raw_profile_filename))
95+
f.write(expected_output)
8696

8797
logging.debug("Writing completed")
8898

0 commit comments

Comments
 (0)