Check file content to see if it looks auto-generated
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/scripts/code_style.py b/scripts/code_style.py
index 08ec4af..71e3edf 100755
--- a/scripts/code_style.py
+++ b/scripts/code_style.py
@@ -51,6 +51,12 @@
checks = re.findall(CHECK_CALL_RE, content)
return frozenset(word for s in checks for word in s.split())
+# Check for comment string indicating an auto-generated file
+AUTOGEN_RE = re.compile(r"Warning[ :-]+This file is (now )?auto[ -]generated", re.ASCII | re.IGNORECASE)
+def is_file_autogenerated(filename):
+ content = open(filename, encoding="utf-8").read()
+ return AUTOGEN_RE.search(content) is not None
+
def get_src_files(since: Optional[str]) -> List[str]:
"""
Use git to get a list of the source files.
@@ -85,7 +91,8 @@
# generated files (we're correcting the templates instead).
src_files = [filename for filename in src_files
if not (filename.startswith("3rdparty/") or
- filename in generated_files)]
+ filename in generated_files or
+ is_file_autogenerated(filename))]
return src_files
def get_uncrustify_version() -> str: