From patchwork Wed Apr 6 17:10:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 109338 X-Patchwork-Delegate: thomas@monjalon.net 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 35384A0509; Wed, 6 Apr 2022 19:10:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AB8F64286E; Wed, 6 Apr 2022 19:10:36 +0200 (CEST) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by mails.dpdk.org (Postfix) with ESMTP id 501454286E for ; Wed, 6 Apr 2022 19:10:35 +0200 (CEST) Received: by mail-lj1-f172.google.com with SMTP id m12so4108843ljp.8 for ; Wed, 06 Apr 2022 10:10:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9k5RzIJZwwc4N98B7exJ7WTuOoaC0sDoGJjjho5TcS0=; b=B1/w/kzecjJOggsoH0nZllOmMDOcj/AyS8ACGIGJvAZt0N2ckUG5xQhh8CYaEJobBs paXsCxdR7T9DnqxTqFcg01SuWWoLorq8Gy7gWGzDURrM7QjobHT05QAKZHoE6uaFMHYm JhQ9YnID2hldvFS9sj7dEbRU88ZgrNYUErRxe+xwuDCnKg/3Zmq1E7WM0//i6UoTCE0Q 3XQ5EVMRvrWIDHF+YvTJLzC8l3krd0dlMoJIfdNW2mncD/4JWjOjRJVV2LrB8csjBoHm eVGVh0t0teJefzZIZaZlmprC5CIeh8VS9YdBW0X0vrstTSmtMOL7dSplYH5vewIj1Y4j Q3lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9k5RzIJZwwc4N98B7exJ7WTuOoaC0sDoGJjjho5TcS0=; b=aj05P3XyRrGuDZI5miVvei3FnD++WyZdcRwROXBhHC2UUQuhNUBiwsJb1+b5av/AXs 1wk4pjUDvNM1jLy8Jl+H/6hObkHps3bguosZstrojyUDsWbsZHLKvxCbfu8yB/CYo1QR /8L+sOn+ir0amyGN5FzroTPCkJcb6MdkfjpKFzKHncxr5SQCAVeSZKmdjWa6+fep98gT Qlz9kMp7/1V/MEpHTnrRXIcDNKmRF7DEU3q5/tOkkvKH8nsjCh6+VKh20DSKPfiR8sgr ifotY5xvmBy8XGIZIAn1c74+G5wEE3LngO1CHeFhDFI305dBS+AaOtZi4taNau8Jj9CJ MoLw== X-Gm-Message-State: AOAM530LCMnpXYwQ8y7ejjnU6F0d8RubWyh4IhCq/WdRijGxc5ZbShY3 0u1f/Vva3sIL07xVSkF+uBJ1Ga46oNQ= X-Google-Smtp-Source: ABdhPJyqr/FYFylpc+n6p4Ot5Ko/mF1w1SYZxEv0FMiOl2nX/8gMn9omp9XltBWA/dio7lWo6GUF8g== X-Received: by 2002:a2e:bc1e:0:b0:249:896f:6dbf with SMTP id b30-20020a2ebc1e000000b00249896f6dbfmr6022291ljf.180.1649265033203; Wed, 06 Apr 2022 10:10:33 -0700 (PDT) Received: from sovereign.. (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id e23-20020a196757000000b0044a27dced95sm1887769lfj.3.2022.04.06.10.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 10:10:32 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Vipin Varghese , Dmitry Kozlyuk , Bruce Richardson Subject: [PATCH v2 3/3] doc: rewrite shell scripts in Python Date: Wed, 6 Apr 2022 20:10:12 +0300 Message-Id: <20220406171012.87759-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20220406171012.87759-1-dmitry.kozliuk@gmail.com> References: <20220331212830.708912-1-dmitry.kozliuk@gmail.com> <20220406171012.87759-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 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 Shell used in documentation generation could not run on Windows. Rewrite scripts in Python. New scripts use proper path separators and handle paths with spaces. Signed-off-by: Dmitry Kozlyuk Reviewed-by: Bruce Richardson --- doc/api/generate_doxygen.py | 19 +++++++++++++++++++ doc/api/generate_doxygen.sh | 12 ------------ doc/api/generate_examples.py | 31 +++++++++++++++++++++++++++++++ doc/api/generate_examples.sh | 20 -------------------- doc/api/meson.build | 6 +++--- 5 files changed, 53 insertions(+), 35 deletions(-) create mode 100644 doc/api/generate_doxygen.py delete mode 100755 doc/api/generate_doxygen.sh create mode 100644 doc/api/generate_examples.py delete mode 100755 doc/api/generate_examples.sh diff --git a/doc/api/generate_doxygen.py b/doc/api/generate_doxygen.py new file mode 100644 index 0000000000..2ccedf844e --- /dev/null +++ b/doc/api/generate_doxygen.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# (c) 2018 Luca Boccassi +# (c) 2022 Dmitry Kozlyuk + +import os, re, subprocess, sys + +pattern = re.compile('^Preprocessing (.*)...$') +out_dir, *doxygen_command = sys.argv[1:] +out_file = os.path.join(os.path.dirname(out_dir), 'doxygen.out') +dep_file = f'{out_dir}.d' +with open(out_file, 'w') as out: + subprocess.run(doxygen_command, check=True, stdout=out) +with open(out_file) as out, open(dep_file, 'w') as dep: + print(f'{out_dir}:', end=' ', file=dep) + for line in out: + match = re.match(pattern, line) + if match: + print(match.group(1), end=' ', file=dep) diff --git a/doc/api/generate_doxygen.sh b/doc/api/generate_doxygen.sh deleted file mode 100755 index 1940ea46e2..0000000000 --- a/doc/api/generate_doxygen.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/sh -e -# SPDX-License-Identifier: BSD-3-Clause -# Copyright 2018 Luca Boccassi - -DOXYCONF=$1 -OUTDIR=$2 - -OUT_FILE=$(dirname $OUTDIR)/doxygen.out - -# run doxygen, capturing all the header files it processed -doxygen "${DOXYCONF}" > $OUT_FILE -echo "$OUTDIR: $(awk '/Preprocessing/ {printf("%s ", substr($2, 1, length($2) - 3))}' $OUT_FILE)" > $OUTDIR.d diff --git a/doc/api/generate_examples.py b/doc/api/generate_examples.py new file mode 100644 index 0000000000..c35e72f280 --- /dev/null +++ b/doc/api/generate_examples.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# (c) 2018 Luca Boccassi +# (c) 2022 Dmitry Kozlyuk + +import os, sys + +examples_dir, api_examples = sys.argv[1:] + +sources = [] +with open(f'{api_examples}.d', 'w') as dep: + print(f'{api_examples}:', end=' ', file=dep) + for root, _, files in os.walk(examples_dir): + for name in files: + is_source = name.endswith('.c') + if is_source or name == 'meson.build': + path = os.path.join(root, name) + if is_source: + sources.append(path) + print(path , end=' ', file=dep) + +with open(api_examples, 'w') as out: + print('''/** +@page examples DPDK Example Programs +''', file=out) + for path in sources: + # Produce consistent output with forward slashes on all systems. + # Every \ in paths within examples directory is a separator, not escape. + relpath = os.path.relpath(path, examples_dir).replace('\\', '/') + print(f'@example examples/{relpath}', file=out) + print('*/', file=out) diff --git a/doc/api/generate_examples.sh b/doc/api/generate_examples.sh deleted file mode 100755 index 48574563ca..0000000000 --- a/doc/api/generate_examples.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /bin/sh -e -# SPDX-License-Identifier: BSD-3-Clause -# Copyright 2018 Luca Boccassi - -EXAMPLES_DIR=$1 -API_EXAMPLES=$2 - -FIND=find - -# generate a .d file including both C files and also build files, so we can -# detect both file changes and file additions/deletions -echo "$API_EXAMPLES: $($FIND ${EXAMPLES_DIR} -type f \( -name '*.c' -o -name 'meson.build' \) | tr '\n' ' ' )" > ${API_EXAMPLES}.d - -exec > "${API_EXAMPLES}" -printf '/**\n' -printf '@page examples DPDK Example Programs\n\n' -$FIND "${EXAMPLES_DIR}" -type f -name '*.c' | - sed "s|${EXAMPLES_DIR}|@example examples|" | - LC_ALL=C sort -printf '*/\n' diff --git a/doc/api/meson.build b/doc/api/meson.build index 53338a02d6..2876a78a7e 100644 --- a/doc/api/meson.build +++ b/doc/api/meson.build @@ -11,8 +11,8 @@ endif # is in a subdirectory that is created at build time and thus it cannot # be an individual custom_target, we need to wrap the doxygen call in a # script to run the CSS modification afterwards -generate_doxygen = find_program('generate_doxygen.sh') -generate_examples = find_program('generate_examples.sh') +generate_doxygen = py3 + files('generate_doxygen.py') +generate_examples = py3 + files('generate_examples.py') htmldir = join_paths(get_option('datadir'), 'doc', 'dpdk') @@ -51,7 +51,7 @@ doxy_build = custom_target('doxygen', input: doxy_conf, output: 'html', depfile: 'html.d', - command: [generate_doxygen, '@INPUT@', '@OUTPUT@'], + command: [generate_doxygen, '@OUTPUT@', doxygen, '@INPUT@'], install: get_option('enable_docs'), install_dir: htmldir, build_by_default: get_option('enable_docs'))