From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D3647A09E4; Fri, 29 Jan 2021 17:49:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD2092400FC; Fri, 29 Jan 2021 17:49:14 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id EC9C6240110 for ; Fri, 29 Jan 2021 17:49:06 +0100 (CET) IronPort-SDR: SNWpXG/VA14G8iyMUWeFbfk/qjsABuQULgnv7fOIwUdRlJonFkegmOYaTE7Ax6+St614BUStb7 hgZ2NpvzEgDw== X-IronPort-AV: E=McAfee;i="6000,8403,9879"; a="179671335" X-IronPort-AV: E=Sophos;i="5.79,386,1602572400"; d="scan'208";a="179671335" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2021 08:49:06 -0800 IronPort-SDR: IPZqEbkOrqTIvGyM30/1GhUq0ivfVSYGfck3nILBxmjXbJ8B8KJuIbUueotghzihjUp+tuvjzc 0jIqmiqP9dtQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,386,1602572400"; d="scan'208";a="370431564" Received: from silpixa00399126.ir.intel.com ([10.237.222.4]) by orsmga002.jf.intel.com with ESMTP; 29 Jan 2021 08:49:04 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , Thomas Monjalon Date: Fri, 29 Jan 2021 16:48:22 +0000 Message-Id: <20210129164823.3205861-9-bruce.richardson@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210129164823.3205861-1-bruce.richardson@intel.com> References: <20210114110606.21142-1-bruce.richardson@intel.com> <20210129164823.3205861-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 08/10] buildtools/chkincs: add app to verify header includes X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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. 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 --- MAINTAINERS | 1 + buildtools/chkincs/gen_c_file_for_header.py | 12 +++++++ buildtools/chkincs/main.c | 4 +++ buildtools/chkincs/meson.build | 36 +++++++++++++++++++++ devtools/test-meson-builds.sh | 2 +- doc/guides/rel_notes/release_21_02.rst | 8 +++++ meson.build | 5 +++ 7 files changed, 67 insertions(+), 1 deletion(-) create mode 100755 buildtools/chkincs/gen_c_file_for_header.py create mode 100644 buildtools/chkincs/main.c create mode 100644 buildtools/chkincs/meson.build diff --git a/MAINTAINERS b/MAINTAINERS index 1a12916f56..aeefe3b1be 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -98,6 +98,7 @@ F: Makefile F: meson.build F: meson_options.txt F: config/ +F: buildtools/chkincs/ F: buildtools/call-sphinx-build.py F: buildtools/list-dir-globs.py F: buildtools/pkg-config/ diff --git a/buildtools/chkincs/gen_c_file_for_header.py b/buildtools/chkincs/gen_c_file_for_header.py new file mode 100755 index 0000000000..ed46948aea --- /dev/null +++ b/buildtools/chkincs/gen_c_file_for_header.py @@ -0,0 +1,12 @@ +#! /usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2021 Intel Corporation + +from sys import argv +from os.path import abspath + +(h_file, c_file) = argv[1:] + +contents = '#include "' + abspath(h_file) + '"' +with open(c_file, 'w') as cf: + cf.write(contents) diff --git a/buildtools/chkincs/main.c b/buildtools/chkincs/main.c new file mode 100644 index 0000000000..d25bb8852a --- /dev/null +++ b/buildtools/chkincs/main.c @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Intel Corporation + */ +int main(void) { return 0; } diff --git a/buildtools/chkincs/meson.build b/buildtools/chkincs/meson.build new file mode 100644 index 0000000000..f345e87551 --- /dev/null +++ b/buildtools/chkincs/meson.build @@ -0,0 +1,36 @@ +# 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) diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh index efa91e0e40..a99a177e0c 100755 --- a/devtools/test-meson-builds.sh +++ b/devtools/test-meson-builds.sh @@ -227,7 +227,7 @@ default_machine='nehalem' if ! check_cc_flags "-march=$default_machine" ; then default_machine='corei7' fi -build build-x86-default cc skipABI \ +build build-x86-default cc skipABI -Dcheck_includes=true \ -Dlibdir=lib -Dmachine=$default_machine $use_shared # 32-bit with default compiler diff --git a/doc/guides/rel_notes/release_21_02.rst b/doc/guides/rel_notes/release_21_02.rst index 17fcfd661c..fc3bf51cb6 100644 --- a/doc/guides/rel_notes/release_21_02.rst +++ b/doc/guides/rel_notes/release_21_02.rst @@ -132,6 +132,14 @@ New Features * Added support for aes-cbc sha256-128-hmac cipher combination in OCTEON TX2 crypto PMD lookaside protocol offload for IPsec. +* **Added support for build-time checking of header includes** + + A new build option ``check_includes`` has been added, which, when enabled, + will perform build-time checking on DPDK public header files, to ensure none + are missing dependent header includes. This feature, disabled by default, is + intended for use by developers contributing to the DPDK SDK itself, and is + integrated into the build scripts and automated CI for patch contributions. + Removed Items ------------- diff --git a/meson.build b/meson.build index e6e34d0a98..fcc4d4c900 100644 --- a/meson.build +++ b/meson.build @@ -68,6 +68,11 @@ if get_option('enable_kmods') subdir('kernel') endif +# check header includes if requested +if get_option('check_includes') + subdir('buildtools/chkincs') +endif + # write the build config build_cfg = 'rte_build_config.h' configure_file(output: build_cfg, -- 2.27.0