mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-26 23:01:05 +08:00
MacOS, iOS: Replace dynamic comments in mig-generated files with stable ones.
Mig-generated files contain mig identifiers, which include timestamp and mig build info. To improve build determinism and goma cachehits we can replace these lines with something stable. Bug: crashpad:390 Change-Id: Iedb2f6e64428612899587c2ac4d488baf439961f Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3394052 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
243e1fd8e2
commit
9ed7e84644
@ -23,6 +23,33 @@ import sys
|
||||
from mig_gen import MigInterface
|
||||
|
||||
|
||||
def _make_generated_comments_deterministic(contents):
|
||||
"""Replaces generated code comments with determenistic ones.
|
||||
|
||||
This is what is generated by mig (only in .c files):
|
||||
/*
|
||||
* IDENTIFICATION:
|
||||
* stub generated Mon Jan 17 15:28:03 2022
|
||||
* with a MiG generated by bootstrap_cmds-122
|
||||
* OPTIONS:
|
||||
*/
|
||||
|
||||
We look for two specific lines and replace them like so:
|
||||
/*
|
||||
* IDENTIFICATION:
|
||||
* stub generated <suppressed by mig_fix.py>
|
||||
* with a MiG generated by <suppressed by mig_fix.py>
|
||||
* OPTIONS:
|
||||
*/
|
||||
"""
|
||||
|
||||
return re.sub(r'^( \* (?:stub generated|with a MiG generated by) ).+$',
|
||||
r'\1<suppressed by mig_fix.py>',
|
||||
contents,
|
||||
count=2,
|
||||
flags=re.MULTILINE)
|
||||
|
||||
|
||||
def _fix_user_implementation(implementation, fixed_implementation, header,
|
||||
fixed_header):
|
||||
"""Rewrites a MIG-generated user implementation (.c) file.
|
||||
@ -33,7 +60,8 @@ def _fix_user_implementation(implementation, fixed_implementation, header,
|
||||
unused in the user implementation file, and this will trigger a
|
||||
-Wunused-local-typedefs warning in gcc unless removed or marked with the
|
||||
“unused” attribute. Also changes header references to point to the new
|
||||
header filename, if changed.
|
||||
header filename, if changed. Replaces generated code comments with
|
||||
deterministic ones.
|
||||
|
||||
If |fixed_implementation| is None, overwrites the original; otherwise, puts
|
||||
the result in the file at |fixed_implementation|.
|
||||
@ -50,6 +78,9 @@ def _fix_user_implementation(implementation, fixed_implementation, header,
|
||||
'#include "%s"' % os.path.basename(header),
|
||||
'#include "%s"' % os.path.basename(fixed_header))
|
||||
|
||||
# Replace generated code comments with determenistic ones.
|
||||
contents = _make_generated_comments_deterministic(contents)
|
||||
|
||||
if fixed_implementation is None:
|
||||
file.seek(0)
|
||||
file.truncate()
|
||||
@ -71,6 +102,7 @@ def _fix_server_implementation(implementation, fixed_implementation, header,
|
||||
added to a header file, so that other files that include that header file
|
||||
will have access to these declarations from a compilation perspective. Also
|
||||
changes header references to point to the new header filename, if changed.
|
||||
Replaces generated code comments with deterministic ones.
|
||||
|
||||
If |fixed_implementation| is None or not provided, overwrites the original;
|
||||
otherwise, puts the result in the file at |fixed_implementation|.
|
||||
@ -117,6 +149,9 @@ extern
|
||||
'#include "%s"' % os.path.basename(header),
|
||||
'#include "%s"' % os.path.basename(fixed_header))
|
||||
|
||||
# Replace generated code comments with determenistic ones.
|
||||
contents = _make_generated_comments_deterministic(contents)
|
||||
|
||||
if fixed_implementation is None:
|
||||
file.seek(0)
|
||||
file.truncate()
|
||||
|
Loading…
x
Reference in New Issue
Block a user