2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-29 04:57:52 +00:00

[#3734] Switch tools/find-uninstalled-headers.py to Meson

This commit is contained in:
Andrei Pavel 2025-05-07 07:44:08 +03:00
parent cd2e58b898
commit cb5c467e72
No known key found for this signature in database
GPG Key ID: D4E804481939CB21
4 changed files with 41 additions and 42 deletions

View File

@ -35,7 +35,7 @@ Kea in embedded regime.
Optionally you can also: Optionally you can also:
-# Implement unit tests for your backend in the src/bin/dhcp4/tests directory. -# Implement unit tests for your backend in the src/bin/dhcp4/tests directory.
-# Modify src/bin/dhcp4/tests/Makefile.am to include the file(s) containing the -# Modify src/bin/dhcp4/tests/meson.build to include the file(s) containing the
unit tests. unit tests.
@section configBackendJSONDesign The JSON Configuration Backend @section configBackendJSONDesign The JSON Configuration Backend

View File

@ -13,15 +13,10 @@ There are several steps needed to document new API command:
(resp-syntax) or any comment about response (resp-comment), simply (resp-syntax) or any comment about response (resp-comment), simply
remove those unused keys. The generator will attempt to generate remove those unused keys. The generator will attempt to generate
boilerplates for it. boilerplates for it.
3. Update api_files.mk. You can also run: ./generate-api-files > api_files.mk 3. Rebuild User's Guide as usual, run "meson compile doc -C build".
or check the update by: ./generate-api-files | diff - api_files.mk
4. Rebuild User's Guide as usual, run in doc/sphinx folder: make
Files in this directory: Files in this directory:
- README: this file - README: this file
- _template.json: template used by generate-templates - _template.json: template used by generate-templates
- api-files.mk: list of command files for inclusion in Makefiles
(can be build by ./generate-api-files)
- generate-templates: script generating new command files from the - generate-templates: script generating new command files from the
the template (_template.json) the template (_template.json)
- generate-api-files: script generating api-files.mk

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# Copyright (C) 2023-2024 Internet Systems Consortium, Inc. ("ISC") # Copyright (C) 2023-2025 Internet Systems Consortium, Inc. ("ISC")
# #
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this

View File

@ -2,7 +2,7 @@
""" """
This script checks that all source headers are installed by inspecting This script checks that all source headers are installed by inspecting
Makefile.am files. meson.build files.
Usage: ./tools/find-uninstalled-headers.py Usage: ./tools/find-uninstalled-headers.py
""" """
@ -18,49 +18,53 @@ EXCLUDE_LIST = [
def main(): def main():
makefile_ams = sorted(pathlib.Path('./src/lib').glob('**/Makefile.am')) meson_builds = sorted(pathlib.Path('./src/lib').glob('**/meson.build'))
headers = sorted(pathlib.Path('./src/lib').glob('**/*.h')) headers = sorted(pathlib.Path('./src/lib').glob('**/*.h'))
headers_pattern = re.compile(r'kea_.*_headers = \[([^]]*)(\]?)$')
headers_pattern = re.compile(r'_HEADERS [+]?= (.*\.h|)(.*)')
backslash_pattern = re.compile(r'(.*\.h) \\$')
failure = False failure = False
for meson_build in meson_builds:
for makefile_am in makefile_ams: with open(meson_build, 'r', encoding='utf-8') as f:
with open(makefile_am, 'r', encoding='utf-8') as f:
lines = f.readlines() lines = f.readlines()
in_headers_block = False in_headers_block = False
for line in lines: for line in lines:
line = line.strip()
if len(line) == 0: if line == ']':
in_headers_block = False in_headers_block = False
continue
header = None
backslash_matches = backslash_pattern.search(line)
headers_matches = headers_pattern.search(line) headers_matches = headers_pattern.search(line)
if headers_matches is None: if headers_matches is None:
if not in_headers_block: # Entries on multiple lines.
continue 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)
if backslash_matches is None: end_square_bracket = headers_matches.group(2)
header = line if end_square_bracket == ']':
in_headers_block = False in_headers_block = False
else: else:
header = backslash_matches.group(1) in_headers_block = True
else:
in_headers_block = True
candidate = headers_matches.group(1)
if backslash_matches is None and len(candidate):
header = candidate
if header is not None:
relative_path = makefile_am.parent / header.strip()
if relative_path not in headers:
print(f'ERROR: Header {relative_path} not in Makefile.am')
failure = True
continue
headers.remove(relative_path)
first = True first = True
for header in headers: for header in headers:
@ -69,8 +73,8 @@ def main():
if any(i in header.parts for i in ['tests', 'testutils', 'unittests']): if any(i in header.parts for i in ['tests', 'testutils', 'unittests']):
continue continue
if first: if first:
print('The following headers are not in the _HEADERS section of ' print('The following headers are not mentioned in an install_headers call of '
'their respective Makefile.am file:') 'their respective meson.build file:')
first = False first = False
print(f'- {header}') print(f'- {header}')
failure = True failure = True