From patchwork Thu Jan 14 11:06:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 86608 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9F402A0A02; Thu, 14 Jan 2021 12:08:51 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43F9D1411CA; Thu, 14 Jan 2021 12:06:43 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 3157F14119E for ; Thu, 14 Jan 2021 12:06:33 +0100 (CET) IronPort-SDR: 04FYuqNgwobCTo+5G5lCO435W+nI5b+ZS39qyvgN2QuzRJJes/m0+0Abetp2hwPve0PSOakPDU P8WK96HbPSEA== X-IronPort-AV: E=McAfee;i="6000,8403,9863"; a="178498555" X-IronPort-AV: E=Sophos;i="5.79,347,1602572400"; d="scan'208";a="178498555" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2021 03:06:33 -0800 IronPort-SDR: PAp7yZseEWwd7H16p9K8o1YXm2OzQUDOW4bIjTAoS5/+qsTBWkYsn3FLdZxxAUi3r6/bYuCPej dexYsykvUGWA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,347,1602572400"; d="scan'208";a="568139896" Received: from silpixa00399126.ir.intel.com ([10.237.222.4]) by orsmga005.jf.intel.com with ESMTP; 14 Jan 2021 03:06:32 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Date: Thu, 14 Jan 2021 11:06:03 +0000 Message-Id: <20210114110606.21142-18-bruce.richardson@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210114110606.21142-1-bruce.richardson@intel.com> References: <20210114110606.21142-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 17/20] app/chkincs: add chkincs app to verify headers 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. Signed-off-by: Bruce Richardson --- 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 -- 2.27.0 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')