scripts/upkeep: remove taisei.h include from non-header files

It's redundant because every local header pulls it in anyway, and it
also interacts badly with clangd's automatic include insertion
This commit is contained in:
Andrei Alexeyev 2024-05-16 23:12:15 +02:00
parent b6439b1319
commit 12fde81651
No known key found for this signature in database
GPG key ID: 72D26128040B9690

View file

@ -58,7 +58,7 @@ guard_regex = re.compile(rf'\s*?\n{guard_header_pattern}\s*?\n+(.*?)\n{hash_patt
header_regex = re.compile(rf'^(?:(?:\s*?/\*.*?---)(.*?)\*/)?{pragma_once_or_guard_header_pattern}(?:\s*?(\n{pre_taiseih_block_pattern}))?{pragma_once_or_guard_header_pattern}(?:\s*?{include_taiseih_pattern})?\s*', re.DOTALL)
badchar_regex = re.compile(rf'[^{guard_chars}]')
missing_guard_test_regex = re.compile(rf'^(?:\s*?/\*.*?\*/)\n(?:\n{pre_taiseih_block_pattern})?\n{include_taiseih_pattern}\n', re.DOTALL)
taiseih_removal_regex = re.compile(r'([ \t]*?)?#[ \t]*include[ \t]+"taisei.h"\n\n?', re.MULTILINE)
def header_template(match):
copyright_contributors = match.group(1) or ''
@ -138,6 +138,9 @@ class Janitor:
text = text.replace('#include "taisei.h"', '#pragma once\n#include "taisei.h"')
text = self.update_header(text)
text = self.transform_include_guards(text, path)
else:
# remove taisei.h include from non-headers
text = taiseih_removal_regex.sub('', text)
update_text_file(path, text)