DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH 17/20] app/chkincs: add chkincs app to verify headers
Date: Thu, 14 Jan 2021 11:06:03 +0000	[thread overview]
Message-ID: <20210114110606.21142-18-bruce.richardson@intel.com> (raw)
In-Reply-To: <20210114110606.21142-1-bruce.richardson@intel.com>

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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/chkincs/gen_c_file_for_header.py | 49 ++++++++++++++++++++++++++++
 app/chkincs/main.c                   |  4 +++
 app/chkincs/meson.build              | 28 ++++++++++++++++
 app/meson.build                      |  1 +
 lib/meson.build                      |  1 +
 meson.build                          |  1 +
 meson_options.txt                    |  2 ++
 7 files changed, 86 insertions(+)
 create mode 100755 app/chkincs/gen_c_file_for_header.py
 create mode 100644 app/chkincs/main.c
 create mode 100644 app/chkincs/meson.build

diff --git a/app/chkincs/gen_c_file_for_header.py b/app/chkincs/gen_c_file_for_header.py
new file mode 100755
index 0000000000..f92f2b412c
--- /dev/null
+++ b/app/chkincs/gen_c_file_for_header.py
@@ -0,0 +1,49 @@
+#! /usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Intel Corporation
+
+from sys import argv
+from os.path import abspath
+
+empty_contents = 'static const char *empty __attribute__((unused)) = "empty";'
+# files which are not used directly, but included via others
+exceptions = [
+    'rte_cmp_arm64.h',
+    'rte_cmp_x86.h',
+    'rte_crc_arm64.h',
+    'rte_eal_interrupts.h',
+    'rte_eth_ctrl.h',
+    'rte_ethdev_core.h',
+    'rte_ipsec_group.h',
+    'rte_lpm_altivec.h',
+    'rte_lpm_neon.h',
+    'rte_lpm_sse.h',
+    'rte_lpm_x86.h',
+    'rte_lru_arm64.h',
+    'rte_lru_x86.h',
+    'rte_regexdev_core.h',
+    'rte_ring_core.h',
+    'rte_ring_generic.h',
+    'rte_ring_hts_c11_mem.h',
+    'rte_ring_hts.h',
+    'rte_ring_peek_c11_mem.h',
+    'rte_ring_peek.h',
+    'rte_ring_peek_zc.h',
+    'rte_ring_rts_c11_mem.h',
+    'rte_ring_rts.h',
+    'rte_stack_lf_c11.h',
+    'rte_stack_lf_generic.h',
+    'rte_stack_lf.h',
+    'rte_stack_std.h',
+    'rte_table_hash_func_arm64.h',
+    ]
+
+(h_file, c_file) = argv[1:]
+
+contents = '#include "' + abspath(h_file) + '"'
+for ex in exceptions:
+    if h_file.endswith(ex):
+        contents = empty_contents
+
+with open(c_file, 'w') as cf:
+    cf.write(contents)
diff --git a/app/chkincs/main.c b/app/chkincs/main.c
new file mode 100644
index 0000000000..ecdf641954
--- /dev/null
+++ b/app/chkincs/main.c
@@ -0,0 +1,4 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+int main(void) { return 0; }
diff --git a/app/chkincs/meson.build b/app/chkincs/meson.build
new file mode 100644
index 0000000000..c16ca1f4fe
--- /dev/null
+++ b/app/chkincs/meson.build
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Intel Corporation
+
+if not get_option('test_includes')
+	build = false
+	subdir_done()
+endif
+
+if is_windows
+	# for windows, the shebang line in the script won't work.
+	error('option "test_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 += '-Wno-unused-function' # needed if we include generic headers
+
+# some ethdev headers depend on bus headers
+includes += include_directories('../../drivers/bus/pci',
+	'../../drivers/bus/vdev')
+
+sources += files('main.c')
+sources += gen_c_files.process(dpdk_headers)
+
+deps = enabled_libs
diff --git a/app/meson.build b/app/meson.build
index b6f2a6f56e..8832ba8b17 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -6,6 +6,7 @@ if is_windows
 endif

 apps = [
+	'chkincs',
 	'pdump',
 	'proc-info',
 	'test-acl',
diff --git a/lib/meson.build b/lib/meson.build
index ed00f89146..7698e6749c 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -103,6 +103,7 @@ foreach l:libraries
 		dpdk_conf.set('RTE_LIBRTE_' + name.to_upper(), 1) #old macro
 		dpdk_conf.set('RTE_LIB_' + name.to_upper(), 1) # new macro
 		install_headers(headers)
+		dpdk_headers += headers

 		libname = 'rte_' + name
 		includes += include_directories(dir_name)
diff --git a/meson.build b/meson.build
index 45d974cd2c..5c612fe93a 100644
--- a/meson.build
+++ b/meson.build
@@ -16,6 +16,7 @@ cc = meson.get_compiler('c')
 dpdk_conf = configuration_data()
 dpdk_libraries = []
 dpdk_static_libraries = []
+dpdk_headers = []
 dpdk_driver_classes = []
 dpdk_drivers = []
 dpdk_extra_ldflags = []
diff --git a/meson_options.txt b/meson_options.txt
index e384e6dbb2..9214219444 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -32,5 +32,7 @@ option('enable_trace_fp', type: 'boolean', value: false,
 	description: 'enable fast path trace points.')
 option('tests', type: 'boolean', value: true,
 	description: 'build unit tests')
+option('test_includes', type: 'boolean', value: false,
+	description: 'build "chkincs" to verify each header file can compile alone')
 option('use_hpet', type: 'boolean', value: false,
 	description: 'use HPET timer in EAL')
--
2.27.0


  parent reply	other threads:[~2021-01-14 11:08 UTC|newest]

Thread overview: 165+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 11:05 [dpdk-dev] [PATCH 00/20] ensure headers have correct includes Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 01/20] eal: fix missing header inclusion Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 02/20] telemetry: fix missing header include Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 03/20] ethdev: " Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 04/20] ring: fix missing includes for c11 model header Bruce Richardson
2021-01-14 12:57   ` David Marchand
2021-01-14 13:54     ` Ananyev, Konstantin
2021-01-14 11:05 ` [dpdk-dev] [PATCH 05/20] net: fix missing header include Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 06/20] mbuf: " Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 07/20] bitratestats: " Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 08/20] rib: fix missing header includes Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 09/20] vhost: " Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 10/20] ipsec: fix missing header include Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 11/20] fib: fix missing header includes Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 12/20] table: fix missing header include Bruce Richardson
2021-01-14 11:05 ` [dpdk-dev] [PATCH 13/20] pipeline: fix missing header includes Bruce Richardson
2021-01-14 11:06 ` [dpdk-dev] [PATCH 14/20] metrics: fix variable declaration in header Bruce Richardson
2021-01-14 11:06 ` [dpdk-dev] [PATCH 15/20] node: fix missing header include Bruce Richardson
2021-01-14 11:06 ` [dpdk-dev] [PATCH 16/20] app: fix extra include paths for app builds Bruce Richardson
2021-01-14 11:06 ` Bruce Richardson [this message]
2021-01-14 12:16   ` [dpdk-dev] [PATCH 17/20] app/chkincs: add chkincs app to verify headers David Marchand
2021-01-14 12:28     ` Bruce Richardson
2021-01-14 12:49       ` David Marchand
2021-01-14 16:04   ` David Marchand
2021-01-14 16:18     ` Bruce Richardson
2021-01-14 11:06 ` [dpdk-dev] [PATCH 18/20] eal: add missing include to mcslock Bruce Richardson
2021-01-14 11:06 ` [dpdk-dev] [PATCH 19/20] eal/x86: add architecture-specific headers to chkincs Bruce Richardson
2021-01-14 11:06 ` [dpdk-dev] [PATCH 20/20] test-meson-builds: add includes check to default x86 build Bruce Richardson
2021-01-15 11:10 ` [dpdk-dev] [PATCH v2 00/19] ensure headers have correct includes Bruce Richardson
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 01/19] eal: fix missing header inclusion Bruce Richardson
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 02/19] telemetry: fix missing header include Bruce Richardson
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 03/19] ethdev: " Bruce Richardson
2021-01-15 15:38     ` Andrew Rybchenko
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 04/19] net: " Bruce Richardson
2021-01-16 12:10     ` Ophir Munk
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 05/19] mbuf: " Bruce Richardson
2021-01-15 15:40     ` Andrew Rybchenko
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 06/19] bitratestats: " Bruce Richardson
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 07/19] rib: fix missing header includes Bruce Richardson
2021-01-15 11:37     ` Medvedkin, Vladimir
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 08/19] vhost: " Bruce Richardson
2021-01-21  8:38     ` Maxime Coquelin
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 09/19] ipsec: fix missing header include Bruce Richardson
2021-01-15 11:35     ` Ananyev, Konstantin
2021-01-15 11:37     ` Medvedkin, Vladimir
2021-01-15 11:45       ` Medvedkin, Vladimir
2021-01-15 11:49         ` Bruce Richardson
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 10/19] fib: fix missing header includes Bruce Richardson
2021-01-15 11:37     ` Medvedkin, Vladimir
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 11/19] table: fix missing header include Bruce Richardson
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 12/19] pipeline: fix missing header includes Bruce Richardson
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 13/19] metrics: fix variable declaration in header Bruce Richardson
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 14/19] node: fix missing header include Bruce Richardson
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 15/19] app: fix extra include paths for app builds Bruce Richardson
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 16/19] app/chkincs: add chkincs app to verify headers Bruce Richardson
2021-01-15 11:51     ` Ferruh Yigit
2021-01-15 11:59       ` Bruce Richardson
2021-01-15 14:09         ` Thomas Monjalon
2021-01-15 14:55           ` Bruce Richardson
2021-01-15 14:59             ` Bruce Richardson
2021-01-20 14:34               ` Bruce Richardson
2021-01-20 15:05                 ` David Marchand
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 17/19] eal: add missing include to mcslock Bruce Richardson
2021-01-15 13:25     ` Honnappa Nagarahalli
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 18/19] eal/x86: add architecture-specific headers to chkincs Bruce Richardson
2021-01-15 11:10   ` [dpdk-dev] [PATCH v2 19/19] test-meson-builds: add includes check to default x86 build Bruce Richardson
2021-01-21  9:25   ` [dpdk-dev] [PATCH v2 00/19] ensure headers have correct includes David Marchand
2021-01-21  9:33     ` Bruce Richardson
2021-01-21  9:36       ` Thomas Monjalon
2021-01-21  9:43         ` Bruce Richardson
2021-01-21 15:15         ` Bruce Richardson
2021-01-21 23:20           ` Thomas Monjalon
2021-01-22 10:44             ` Bruce Richardson
2021-01-25 14:11 ` [dpdk-dev] [PATCH v3 0/4] add checking of header includes Bruce Richardson
2021-01-25 14:11   ` [dpdk-dev] [PATCH v3 1/4] eal: add missing include to mcslock Bruce Richardson
2021-01-25 14:11   ` [dpdk-dev] [PATCH v3 2/4] build: separate out headers for include checking Bruce Richardson
2021-01-25 14:11   ` [dpdk-dev] [PATCH v3 3/4] buildtools/chkincs: add app to verify header includes Bruce Richardson
2021-01-25 14:11   ` [dpdk-dev] [PATCH v3 4/4] devtools: remove check-includes script Bruce Richardson
2021-01-25 15:51   ` [dpdk-dev] [PATCH v3 0/4] add checking of header includes David Marchand
2021-01-25 18:17     ` Bruce Richardson
2021-01-26 11:15     ` Bruce Richardson
2021-01-26 14:04       ` David Marchand
2021-01-26 14:24         ` Bruce Richardson
2021-01-26 14:39           ` Bruce Richardson
2021-01-26 15:31             ` Thomas Monjalon
2021-01-26 15:42               ` Bruce Richardson
2021-01-26 15:50                 ` Thomas Monjalon
2021-01-26 14:18 ` [dpdk-dev] [PATCH v4 0/7] " Bruce Richardson
2021-01-26 14:18   ` [dpdk-dev] [PATCH v4 1/7] eal: add missing include to mcslock Bruce Richardson
2021-01-26 14:18   ` [dpdk-dev] [PATCH v4 2/7] eal: fix error attribute use for clang Bruce Richardson
2021-01-26 14:18   ` [dpdk-dev] [PATCH v4 3/7] rib: fix missing header include Bruce Richardson
2021-01-26 14:21     ` Medvedkin, Vladimir
2021-01-26 14:18   ` [dpdk-dev] [PATCH v4 4/7] build: separate out headers for include checking Bruce Richardson
2021-01-26 14:18   ` [dpdk-dev] [PATCH v4 5/7] buildtools/chkincs: add app to verify header includes Bruce Richardson
2021-01-26 14:18   ` [dpdk-dev] [PATCH v4 6/7] devtools: remove check-includes script Bruce Richardson
2021-01-26 14:18   ` [dpdk-dev] [PATCH v4 7/7] ci: add checking of includes to CI builds Bruce Richardson
2021-01-26 21:38 ` [dpdk-dev] [PATCH v5 0/8] add checking of header includes Bruce Richardson
2021-01-26 21:38   ` [dpdk-dev] [PATCH v5 1/8] eal: add missing include to mcslock Bruce Richardson
2021-01-26 21:38   ` [dpdk-dev] [PATCH v5 2/8] eal: fix error attribute use for clang Bruce Richardson
2021-01-26 21:38   ` [dpdk-dev] [PATCH v5 3/8] ethdev: make driver-only headers private Bruce Richardson
2021-01-27  8:56     ` David Marchand
2021-01-26 21:38   ` [dpdk-dev] [PATCH v5 4/8] rib: fix missing header include Bruce Richardson
2021-01-27 11:08     ` Medvedkin, Vladimir
2021-01-26 21:38   ` [dpdk-dev] [PATCH v5 5/8] build: separate out headers for include checking Bruce Richardson
2021-01-26 21:38   ` [dpdk-dev] [PATCH v5 6/8] buildtools/chkincs: add app to verify header includes Bruce Richardson
2021-01-26 21:38   ` [dpdk-dev] [PATCH v5 7/8] devtools: remove check-includes script Bruce Richardson
2021-01-26 21:38   ` [dpdk-dev] [PATCH v5 8/8] ci: add checking of includes to CI builds Bruce Richardson
2021-01-27 14:46     ` Aaron Conole
2021-01-27 17:33 ` [dpdk-dev] [PATCH v6 0/8] add checking of header includes Bruce Richardson
2021-01-27 17:33   ` [dpdk-dev] [PATCH v6 1/8] eal: add missing include to mcslock Bruce Richardson
2021-01-27 17:33   ` [dpdk-dev] [PATCH v6 2/8] eal: fix error attribute use for clang Bruce Richardson
2021-01-28 11:00     ` David Marchand
2021-01-28 11:20       ` Bruce Richardson
2021-01-28 13:36         ` David Marchand
2021-01-28 14:16           ` Bruce Richardson
2021-01-28 15:16             ` Bruce Richardson
2021-01-28 16:46               ` [dpdk-dev] [dpdk-techboard] " Thomas Monjalon
2021-01-28 17:36                 ` Bruce Richardson
2021-01-29  8:35                   ` David Marchand
2021-01-29  8:54                     ` Thomas Monjalon
2021-01-27 17:33   ` [dpdk-dev] [PATCH v6 3/8] rib: fix missing header include Bruce Richardson
2021-01-28 11:01     ` David Marchand
2021-01-28 11:20       ` Bruce Richardson
2021-01-27 17:33   ` [dpdk-dev] [PATCH v6 4/8] ethdev: make driver-only headers private Bruce Richardson
2021-01-27 17:48     ` Maxime Coquelin
2021-01-28 10:17     ` Thomas Monjalon
2021-01-28 11:01     ` David Marchand
2021-01-28 16:38     ` Webster, Steven
2021-01-27 17:33   ` [dpdk-dev] [PATCH v6 5/8] build: separate out headers for include checking Bruce Richardson
2021-01-28 11:07     ` Thomas Monjalon
2021-01-28 11:23       ` Bruce Richardson
2021-01-27 17:33   ` [dpdk-dev] [PATCH v6 6/8] buildtools/chkincs: add app to verify header includes Bruce Richardson
2021-01-28 11:02     ` David Marchand
2021-01-28 11:27       ` Bruce Richardson
2021-01-28 11:31         ` David Marchand
2021-01-28 11:48           ` Bruce Richardson
2021-01-28 17:23           ` Bruce Richardson
2021-01-27 17:33   ` [dpdk-dev] [PATCH v6 7/8] devtools: remove check-includes script Bruce Richardson
2021-01-28 11:10     ` Thomas Monjalon
2021-01-28 11:38       ` Bruce Richardson
2021-01-28 14:05         ` Thomas Monjalon
2021-01-27 17:33   ` [dpdk-dev] [PATCH v6 8/8] ci: add checking of includes to CI builds Bruce Richardson
2021-01-28 11:12     ` Thomas Monjalon
2021-01-28 11:41       ` Bruce Richardson
2021-01-28 18:34         ` Bruce Richardson
2021-01-29 17:42           ` David Marchand
2021-01-29 21:38             ` Aaron Conole
2021-01-28 10:55   ` [dpdk-dev] [PATCH v6 0/8] add checking of header includes David Marchand
2021-01-28 11:47     ` Bruce Richardson
2021-01-29 16:48 ` [dpdk-dev] [PATCH v7 00/10] " Bruce Richardson
2021-01-29 16:48   ` [dpdk-dev] [PATCH v7 01/10] eal: add missing include to mcslock Bruce Richardson
2021-01-29 16:48   ` [dpdk-dev] [PATCH v7 02/10] eal: fix error attribute use for clang Bruce Richardson
2021-01-29 16:48   ` [dpdk-dev] [PATCH v7 03/10] power: fix missing header includes Bruce Richardson
2021-01-29 16:48   ` [dpdk-dev] [PATCH v7 04/10] rib: fix missing header include Bruce Richardson
2021-01-29 16:48   ` [dpdk-dev] [PATCH v7 05/10] ethdev: make driver-only headers private Bruce Richardson
2021-01-29 16:48   ` [dpdk-dev] [PATCH v7 06/10] eventdev: " Bruce Richardson
2021-02-22 22:34     ` Stephen Hemminger
2021-01-29 16:48   ` [dpdk-dev] [PATCH v7 07/10] build: separate out headers for include checking Bruce Richardson
2021-01-29 16:48   ` [dpdk-dev] [PATCH v7 08/10] buildtools/chkincs: add app to verify header includes Bruce Richardson
2021-02-02 11:36     ` David Marchand
2021-02-02 12:23       ` Bruce Richardson
2021-01-29 16:48   ` [dpdk-dev] [PATCH v7 09/10] devtools: remove check-includes script Bruce Richardson
2021-01-29 16:55   ` [dpdk-dev] [PATCH v7 10/10] ci: add checking of includes to CI builds Bruce Richardson
2021-01-29 21:37     ` Aaron Conole
2021-01-29 20:14   ` [dpdk-dev] [PATCH v7 00/10] add checking of header includes David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210114110606.21142-18-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).