Bruce Richardson 05050ac4ce build: add header includes check
To verify that all DPDK headers are ok for inclusion directly in a C file,
and are not missing any other pre-requisite headers, we can auto-generate
for each header an empty C file that includes that header. Compiling these
files will throw errors if any header has unmet dependencies.

For some libraries, there may be some header files which are not for direct
inclusion, but rather are to be included via other header files. To allow
later checking of these files for missing includes, we separate out the
indirect include files from the direct ones.

To ensure ongoing compliance, we enable this build test as part of the
default x86 build in "test-meson-builds.sh".

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2021-01-29 20:59:37 +01:00

37 lines
935 B
Meson

# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2021 Intel Corporation
if not get_option('check_includes')
build = false
subdir_done()
endif
if is_windows
# for windows, the shebang line in the script won't work.
error('option "check_includes" is not supported on windows')
endif
gen_c_file_for_header = find_program('gen_c_file_for_header.py')
gen_c_files = generator(gen_c_file_for_header,
output: '@BASENAME@.c',
arguments: ['@INPUT@', '@OUTPUT@'])
cflags = machine_args
cflags += '-Wno-unused-function' # needed if we include generic headers
cflags += '-DALLOW_EXPERIMENTAL_API'
sources = files('main.c')
sources += gen_c_files.process(dpdk_chkinc_headers)
deps = []
foreach l:enabled_libs
deps += get_variable('static_rte_' + l)
endforeach
executable('chkincs', sources,
c_args: cflags,
include_directories: includes,
dependencies: deps,
link_whole: dpdk_static_libraries + dpdk_drivers,
install: false)