From patchwork Wed Dec 19 13:44:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 49118 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6B1541B5BD; Wed, 19 Dec 2018 14:45:10 +0100 (CET) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 05EC01B5A3 for ; Wed, 19 Dec 2018 14:45:08 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 74E0CC00C10B; Wed, 19 Dec 2018 13:45:02 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-117-97.ams2.redhat.com [10.36.117.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FC50171F3; Wed, 19 Dec 2018 13:44:59 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: nhorman@tuxdriver.com, thomas@monjalon.net Date: Wed, 19 Dec 2018 14:44:53 +0100 Message-Id: <1545227093-25493-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 19 Dec 2018 13:45:07 +0000 (UTC) Subject: [dpdk-dev] [RFC PATCH] detect missing experimental tags in headers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Add a little script to get the symbols of a given section looking at a library map file, then, on installation, inspect the sources headers to check that the declaration of the EXPERIMENTAL symbols are prefixed with a __rte_experimental tag. Signed-off-by: David Marchand --- For now, the check is not fatal, since this is just a draft. Finding out the right headers could be improved. We could also move this check to checkpatches so that it is enforced by maintainers. --- buildtools/map-list-symbol.sh | 23 +++++++++++++++++++++++ mk/rte.lib.mk | 27 ++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100755 buildtools/map-list-symbol.sh diff --git a/buildtools/map-list-symbol.sh b/buildtools/map-list-symbol.sh new file mode 100755 index 0000000..e4635df --- /dev/null +++ b/buildtools/map-list-symbol.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 David Marchand + +section=${1:-} +shift + +for file in $@; do + cat "$file" |awk ' + BEGIN { in_sec = 0; } + /^.*{/ { + if ("'$section'" == "all" || $1 == "'$section'") { + in_sec = 1; + } + } + /.*}/ { in_sec = 0; } + /^[^}].*[^:*];/ { + if (in_sec == 1) { + gsub(";",""); + print $1; + } + }' +done diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk index c696a21..fdd9059 100644 --- a/mk/rte.lib.mk +++ b/mk/rte.lib.mk @@ -31,7 +31,7 @@ endif _BUILD = $(LIB) -PREINSTALL = $(SYMLINK-FILES-y) +PREINSTALL = $(SYMLINK-FILES-y) check_headers_experimental _INSTALL = $(INSTALL-FILES-y) $(RTE_OUTPUT)/lib/$(LIB) _CLEAN = doclean @@ -127,6 +127,31 @@ $(LIB): $(OBJS-y) $(DEP_$(LIB)) FORCE endif # +# __rte_experimental inspection +# +check_headers_experimental: + @list_symbols=""; \ + for sym in $$($(RTE_SDK)/buildtools/map-list-symbol.sh EXPERIMENTAL $(SRCDIR)/$(EXPORT_MAP)); do \ + srcdir=$(SRCDIR); \ + if [ "$${srcdir%%linuxapp/eal}" != "$$srcdir" ]; then \ + srcdir="$$srcdir $${srcdir%%linuxapp/eal}common"; \ + fi; \ + files=$$(find $$srcdir -name '*.h' |xargs grep -l $$sym); \ + if [ -z "$$files" ]; then \ + list_symbols="$$list_symbols $$sym"; \ + continue; \ + fi; \ + if ! grep -Pzoha "[^)/;}]+\s*$$sym\s*\(" $$files |grep -q __rte_experimental; then \ + list_symbols="$$list_symbols $$sym"; \ + fi; \ + done; \ + if [ -n "$$list_symbols" ]; then \ + for sym in $$list_symbols; do \ + echo "ERROR: $$sym is not marked as experimental in this library headers"; \ + done; \ + fi + +# # install lib in $(RTE_OUTPUT)/lib # $(RTE_OUTPUT)/lib/$(LIB): $(LIB)