From patchwork Mon May 10 08:41:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 12247221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8809BC433B4 for ; Mon, 10 May 2021 08:41:56 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 33D7C60FE7 for ; Mon, 10 May 2021 08:41:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33D7C60FE7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.124971.235335 (Exim 4.92) (envelope-from ) id 1lg1U3-0003BY-8j; Mon, 10 May 2021 08:41:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 124971.235335; Mon, 10 May 2021 08:41:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lg1U3-0003Ak-2g; Mon, 10 May 2021 08:41:47 +0000 Received: by outflank-mailman (input) for mailman id 124971; Mon, 10 May 2021 08:41:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lg1U1-0008L0-OB for xen-devel@lists.xenproject.org; Mon, 10 May 2021 08:41:45 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 120380b4-d6db-4857-8ba4-6d056083678d; Mon, 10 May 2021 08:41:23 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8A29411FB; Mon, 10 May 2021 01:41:23 -0700 (PDT) Received: from e125770.cambridge.arm.com (e125770.cambridge.arm.com [10.1.197.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2A3F33F719; Mon, 10 May 2021 01:41:22 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 120380b4-d6db-4857-8ba4-6d056083678d From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, wei.chen@arm.com, Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v6 6/9] docs: add doxygen preprocessor and related files Date: Mon, 10 May 2021 09:41:02 +0100 Message-Id: <20210510084105.17108-7-luca.fancellu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210510084105.17108-1-luca.fancellu@arm.com> References: <20210510084105.17108-1-luca.fancellu@arm.com> Add preprocessor called by doxygen before parsing headers, it will include in every header a doxygen_include.h file that provides missing defines and includes that are usually passed by the compiler. Add doxy_input.list that is a text file containing the relative path to the source code file to be parsed by doxygen. The path sould be relative to the xen folder: E.g. xen/include/public/grant_table.h Signed-off-by: Luca Fancellu --- docs/xen-doxygen/doxy-preprocessor.py | 110 ++++++++++++++++++++++++++ docs/xen-doxygen/doxy_input.list | 0 docs/xen-doxygen/doxygen_include.h.in | 32 ++++++++ 3 files changed, 142 insertions(+) create mode 100755 docs/xen-doxygen/doxy-preprocessor.py create mode 100644 docs/xen-doxygen/doxy_input.list create mode 100644 docs/xen-doxygen/doxygen_include.h.in diff --git a/docs/xen-doxygen/doxy-preprocessor.py b/docs/xen-doxygen/doxy-preprocessor.py new file mode 100755 index 0000000000..496899d8e6 --- /dev/null +++ b/docs/xen-doxygen/doxy-preprocessor.py @@ -0,0 +1,110 @@ +#!/usr/bin/python3 +# +# Copyright (c) 2021, Arm Limited. +# +# SPDX-License-Identifier: GPL-2.0 +# + +import os, sys, re + + +# Variables that holds the preprocessed header text +output_text = "" +header_file_name = "" + +# Variables to enumerate the anonymous structs/unions +anonymous_struct_count = 0 +anonymous_union_count = 0 + + +def error(text): + sys.stderr.write("{}\n".format(text)) + sys.exit(1) + + +def write_to_output(text): + sys.stdout.write(text) + + +def insert_doxygen_header(text): + # Here the strategy is to insert the #include in the + # first line of the header + abspath = os.path.dirname(os.path.abspath(__file__)) + text += "#include \"{}/doxygen_include.h\"\n".format(abspath) + + return text + + +def enumerate_anonymous(match): + global anonymous_struct_count + global anonymous_union_count + + if "struct" in match.group(1): + label = "anonymous_struct_%d" % anonymous_struct_count + anonymous_struct_count += 1 + else: + label = "anonymous_union_%d" % anonymous_union_count + anonymous_union_count += 1 + + return match.group(1) + " " + label + " {" + + +def manage_anonymous_structs_unions(text): + # Match anonymous unions/structs with this pattern: + # struct/union { + # [...] + # + # and substitute it in this way: + # + # struct anonymous_struct_# { + # [...] + # or + # union anonymous_union_# { + # [...] + # where # is a counter starting from zero, different between structs and + # unions + # + # We don't count anonymous union/struct that are part of a typedef because + # they don't create any issue for doxygen + text = re.sub( + "(? + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#include "@XEN_BASE@/xen/include/xen/config.h" + +#if defined(CONFIG_X86_64) + +#define __x86_64__ 1 + +#elif defined(CONFIG_ARM_64) + +#define __aarch64__ 1 + +#elif defined(CONFIG_ARM_32) + +#define __arm__ 1 + +#else + +#error Architecture not supported/recognized. + +#endif