From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8DE7245903; Wed, 4 Sep 2024 17:08:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F6D1410ED; Wed, 4 Sep 2024 17:08:48 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by mails.dpdk.org (Postfix) with ESMTP id F0C0242670 for ; Wed, 4 Sep 2024 17:08:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725462526; x=1756998526; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=I4kKLSj2hwZHDw/zd/supgP64bEPshcsjWyLCJ2K/xw=; b=XI1s3+PYlwGwxPswy2YthNb6+DIA0zDqLPirZpP3zd2ZI3GVh2B7Ef9s Q2//8efzaWBqCWK2bpp64DO6BxGQVmts2+ftfFReuwHjdQ7E9pnZ7LiJA ZsiZzXpU5IWi87ztMEGvr4WzJ9MzFIElsq6Yb1dUGhCepc5k2E5mmBo/W 04D/u29hMNS9GqWAcV9im9BUjHUP1f45bA2uaa8SX4PS0I+00+UsOpUbf oAG9xO6rC/NHGitM3ajt0VWccJFqzy2b3q44v1YcAcUskGnGDrQYWl8C7 ndk9UcbGC+4cmY/9iXJFsX05DP1M4yuDuY1IIq4ZdFkH+kq95FXgoSEQu A==; X-CSE-ConnectionGUID: dkSTh1opTP6mXRTkgNkVfw== X-CSE-MsgGUID: 4orllQuOSUO9Ar4hkTSfwg== X-IronPort-AV: E=McAfee;i="6700,10204,11185"; a="23641078" X-IronPort-AV: E=Sophos;i="6.10,202,1719903600"; d="scan'208";a="23641078" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2024 08:08:46 -0700 X-CSE-ConnectionGUID: nCKArReVSCyIAwUX4IxvGA== X-CSE-MsgGUID: CTd+y0CtRDWVqj7qTzE/uA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,202,1719903600"; d="scan'208";a="96107838" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by fmviesa001.fm.intel.com with ESMTP; 04 Sep 2024 08:08:44 -0700 From: Anatoly Burakov To: dev@dpdk.org Subject: [PATCH v3 2/8] build: output a dependency log in build directory Date: Wed, 4 Sep 2024 16:08:30 +0100 Message-ID: <44ec47b5f303229389a5717ec13d4c95ccb15d66.1725462264.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: References: <20240730145508.551075-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Bruce Richardson As meson processes our DPDK source tree it manages dependencies specified by each individual driver. To enable future analysis of the dependency links between components, log the dependencies of each DPDK component as it gets processed. This could potentially allow other tools to automatically enable or disable components based on the desired end components to be built, e.g. if the user requests net/ice, ensure that common/iavf is also enabled in the drivers. The output file produced is in "dot" or "graphviz" format, which allows producing a graphical representation of the DPDK dependency tree if so desired. For example: "dot -Tpng -O build/deps.dot" to produce the image file "build/deps.dot.png". Signed-off-by: Bruce Richardson Acked-by: Konstantin Ananyev Signed-off-by: Anatoly Burakov --- app/meson.build | 8 ++++- buildtools/log-deps.py | 81 ++++++++++++++++++++++++++++++++++++++++++ buildtools/meson.build | 2 ++ drivers/meson.build | 6 ++++ examples/meson.build | 8 ++++- lib/meson.build | 5 +++ 6 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 buildtools/log-deps.py diff --git a/app/meson.build b/app/meson.build index 1c61cd862c..55a1f076cd 100644 --- a/app/meson.build +++ b/app/meson.build @@ -75,8 +75,14 @@ foreach app:apps reason = 'explicitly disabled via build config' endif + app_name = 'dpdk-' + name if build subdir(name) + type_cmd = '--type=app' + run_command([log_deps_cmd, type_cmd, app_name, deps], check: false) + if optional_deps.length() > 0 + run_command([log_deps_cmd, '--optional', type_cmd, app_name, optional_deps], check: false) + endif if not build and require_apps error('Cannot build explicitly requested app "@0@".\n'.format(name) + '\tReason: ' + reason) @@ -115,7 +121,7 @@ foreach app:apps link_libs = dpdk_static_libraries + dpdk_drivers endif - exec = executable('dpdk-' + name, + exec = executable(app_name, sources, c_args: cflags, link_args: ldflags, diff --git a/buildtools/log-deps.py b/buildtools/log-deps.py new file mode 100644 index 0000000000..e11a102242 --- /dev/null +++ b/buildtools/log-deps.py @@ -0,0 +1,81 @@ +#! /usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Intel Corporation + +"""Utility script to build up a list of dependencies from meson.""" + +import os +import sys +import argparse +import typing as T + + +def file_to_list(filename: str) -> T.List[str]: + """Read file into a list of strings.""" + with open(filename, encoding="utf-8") as f: + return f.readlines() + + +def list_to_file(filename: str, lines: T.List[str]): + """Write a list of strings out to a file.""" + with open(filename, "w", encoding="utf-8") as f: + f.writelines(lines) + + +def gen_deps( + component_type: str, optional: bool, component: str, deps: T.List[str] +) -> str: + """Generate a dependency graph for meson.""" + dep_list_str = '", "'.join(deps) + deps_str = "" if not deps else f' -> {{ "{dep_list_str}" }}' + # we define custom attributes for the nodes + attr_str = f'dpdk_componentType="{component_type}"' + if optional: + # we use a dotted line to represent optional dependencies + attr_str += ',style="dotted"' + return f'"{component}"{deps_str} [{attr_str}]\n' + + +def _main(): + depsfile = f'{os.environ["MESON_BUILD_ROOT"]}/deps.dot' + + # to reset the deps file on each build, the script is called without any params + if len(sys.argv) == 1: + os.remove(depsfile) + sys.exit(0) + + # we got arguments, parse them + parser = argparse.ArgumentParser( + description="Generate a dependency graph for meson." + ) + # type is required + parser.add_argument( + "--type", required=True, help="Type of dependency (lib, examples, etc.)" + ) + parser.add_argument( + "--optional", action="store_true", help="Whether the dependency is optional" + ) + # component is required + parser.add_argument("component", help="The component to add to the graph") + parser.add_argument("deps", nargs="*", help="The dependencies of the component") + + parsed = parser.parse_args() + + try: + contents = file_to_list(depsfile) + except FileNotFoundError: + contents = ["digraph {\n", "}\n"] + + c_type = parsed.type + optional = parsed.optional + component = parsed.component + deps = parsed.deps + contents[-1] = gen_deps(c_type, optional, component, deps) + + contents.append("}\n") + + list_to_file(depsfile, contents) + + +if __name__ == "__main__": + _main() diff --git a/buildtools/meson.build b/buildtools/meson.build index 3adf34e1a8..e2ba9d0ad4 100644 --- a/buildtools/meson.build +++ b/buildtools/meson.build @@ -24,6 +24,8 @@ get_numa_count_cmd = py3 + files('get-numa-count.py') get_test_suites_cmd = py3 + files('get-test-suites.py') has_hugepages_cmd = py3 + files('has-hugepages.py') cmdline_gen_cmd = py3 + files('dpdk-cmdline-gen.py') +log_deps_cmd = py3 + files('log-deps.py') +run_command(log_deps_cmd, check: false) # call with no parameters to reset the file # install any build tools that end-users might want also install_data([ diff --git a/drivers/meson.build b/drivers/meson.build index b9a18a5986..32c9e3f88a 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -155,6 +155,12 @@ foreach subpath:subdirs if build # pull in driver directory which should update all the local variables subdir(drv_path) + type_cmd = '--type=drivers' + drv_name = class + '_' + name + run_command([log_deps_cmd, type_cmd, drv_name, deps], check: false) + if optional_deps.length() > 0 + run_command([log_deps_cmd, '--optional', type_cmd, drv_name, optional_deps], check: false) + endif if dpdk_conf.get('RTE_IOVA_IN_MBUF') == 0 and require_iova_in_mbuf build = false diff --git a/examples/meson.build b/examples/meson.build index 82151d09b4..1589a3057e 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -101,8 +101,14 @@ foreach example: examples optional_deps = [] subdir(example) + example_name = 'dpdk-' + name if build dep_objs = ext_deps + type_cmd = '--type=examples' + run_command([log_deps_cmd, type_cmd, example_name, deps], check: false) + if optional_deps.length() > 0 + run_command([log_deps_cmd, '--optional', type_cmd, example_name, optional_deps], check: false) + endif foreach d:deps + optional_deps var_name = get_option('default_library') + '_rte_' + d if not is_variable(var_name) @@ -125,7 +131,7 @@ foreach example: examples if allow_experimental_apis cflags += '-DALLOW_EXPERIMENTAL_API' endif - executable('dpdk-' + name, sources, + executable(example_name, sources, include_directories: includes, link_whole: link_whole_libs, link_args: ldflags, diff --git a/lib/meson.build b/lib/meson.build index 7916deadd9..f2ac800f5a 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -161,6 +161,11 @@ foreach l:libraries if build subdir(l) + type_cmd = '--type=lib' + run_command([log_deps_cmd, type_cmd, l, deps], check: false) + if optional_deps.length() > 0 + run_command([log_deps_cmd, '--optional', type_cmd, l, optional_deps], check: false) + endif if not build and require_libs error('Cannot build explicitly requested lib "@0@".\n'.format(name) +'\tReason: ' + reason) -- 2.43.5