2024-03-04 14:30:02 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
"""
|
2024-03-21 16:34:17 +02:00
|
|
|
This script checks that all source headers are installed by inspecting
|
2025-05-07 07:44:08 +03:00
|
|
|
meson.build files.
|
2024-03-04 14:30:02 +02:00
|
|
|
|
2024-03-21 16:34:17 +02:00
|
|
|
Usage: ./tools/find-uninstalled-headers.py
|
2024-03-04 14:30:02 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
import pathlib
|
|
|
|
import re
|
2024-03-21 16:34:17 +02:00
|
|
|
import sys
|
|
|
|
|
2024-03-04 14:30:02 +02:00
|
|
|
|
2024-03-21 16:55:06 +02:00
|
|
|
EXCLUDE_LIST = [
|
|
|
|
'src/lib/dns/name_internal.h',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2024-03-04 14:30:02 +02:00
|
|
|
def main():
|
2025-05-07 07:44:08 +03:00
|
|
|
meson_builds = sorted(pathlib.Path('./src/lib').glob('**/meson.build'))
|
2024-03-04 14:30:02 +02:00
|
|
|
headers = sorted(pathlib.Path('./src/lib').glob('**/*.h'))
|
2025-05-07 07:44:08 +03:00
|
|
|
headers_pattern = re.compile(r'kea_.*_headers = \[([^]]*)(\]?)$')
|
2024-03-04 14:30:02 +02:00
|
|
|
failure = False
|
2025-05-07 07:44:08 +03:00
|
|
|
for meson_build in meson_builds:
|
|
|
|
with open(meson_build, 'r', encoding='utf-8') as f:
|
2024-03-04 14:30:02 +02:00
|
|
|
lines = f.readlines()
|
|
|
|
in_headers_block = False
|
|
|
|
for line in lines:
|
2025-05-07 07:44:08 +03:00
|
|
|
line = line.strip()
|
|
|
|
if line == ']':
|
2024-03-04 14:30:02 +02:00
|
|
|
in_headers_block = False
|
2025-05-07 07:44:08 +03:00
|
|
|
continue
|
2024-03-04 14:30:02 +02:00
|
|
|
|
|
|
|
headers_matches = headers_pattern.search(line)
|
|
|
|
if headers_matches is None:
|
2025-05-07 07:44:08 +03:00
|
|
|
# Entries on multiple lines.
|
|
|
|
if in_headers_block:
|
|
|
|
header = line.strip().strip(',').strip("'").strip()
|
|
|
|
if header == '':
|
|
|
|
continue
|
|
|
|
relative_path = meson_build.parent / header
|
|
|
|
if relative_path not in headers:
|
|
|
|
print(f'ERROR: Header {relative_path} not installed.')
|
|
|
|
failure = True
|
|
|
|
continue
|
|
|
|
headers.remove(relative_path)
|
|
|
|
else:
|
|
|
|
# Entries on a single line.
|
|
|
|
header_line = headers_matches.group(1)
|
|
|
|
for header in header_line.split(','):
|
|
|
|
header = header.strip().strip("'")
|
|
|
|
if header == '':
|
|
|
|
# TODO: Why does this happen?
|
|
|
|
continue
|
|
|
|
relative_path = meson_build.parent / header.strip()
|
|
|
|
if relative_path not in headers:
|
|
|
|
print(f'ERROR: Header {relative_path} not installed.')
|
|
|
|
failure = True
|
|
|
|
continue
|
|
|
|
headers.remove(relative_path)
|
|
|
|
|
|
|
|
end_square_bracket = headers_matches.group(2)
|
|
|
|
if end_square_bracket == ']':
|
2024-03-04 14:30:02 +02:00
|
|
|
in_headers_block = False
|
|
|
|
else:
|
2025-05-07 07:44:08 +03:00
|
|
|
in_headers_block = True
|
2024-03-04 14:30:02 +02:00
|
|
|
|
|
|
|
first = True
|
|
|
|
for header in headers:
|
2024-03-21 16:55:06 +02:00
|
|
|
if str(header) in EXCLUDE_LIST:
|
|
|
|
continue
|
|
|
|
if any(i in header.parts for i in ['tests', 'testutils', 'unittests']):
|
|
|
|
continue
|
|
|
|
if first:
|
2025-05-07 07:44:08 +03:00
|
|
|
print('The following headers are not mentioned in an install_headers call of '
|
|
|
|
'their respective meson.build file:')
|
2024-03-21 16:55:06 +02:00
|
|
|
first = False
|
|
|
|
print(f'- {header}')
|
|
|
|
failure = True
|
2024-03-04 14:30:02 +02:00
|
|
|
|
|
|
|
if failure:
|
2024-03-21 16:34:17 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
2024-03-04 14:30:02 +02:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|