DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@amd.com>
To: Bruce Richardson <bruce.richardson@intel.com>, dev@dpdk.org
Cc: anatoly.burakov@intel.com
Subject: Re: [PATCH] build: output a dependency log in build directory
Date: Wed, 31 Jul 2024 11:17:54 +0100	[thread overview]
Message-ID: <f3deb013-bb35-495b-a3ac-ebc1fd7764b5@amd.com> (raw)
In-Reply-To: <20240730145508.551075-1-bruce.richardson@intel.com>

On 7/30/2024 3:55 PM, Bruce Richardson wrote:
> 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 <bruce.richardson@intel.com>
>

I tested it quickly, good to have this dependency list, at least it
makes some duplicated dependencies obvious from .dot file.

But generated dependency graph is too large to be useful, does it make
sense to have a new meson option that control this dependency generation:
-Dgenerate_deps=apps
-Dgenerate_deps=libs
-Dgenerate_deps=drivers
-Dgenerate_deps=all

Not sure about what should be the default option,
as this is not always required/used, disabling this option by default
saves unnecessary work,
but disabling it by default may cause not noticing when it is broken,
perhaps this can be addressed by adding this option to
'devtools/test-meson-builds.sh'.

btw, it generates following warning:

WARNING: You should add the boolean check kwarg to the run_command call.


         It currently defaults to false,


         but it will default to true in future releases of meson.


         See also: https://github.com/mesonbuild/meson/issues/9300


> ---
>  app/meson.build        |  1 +
>  buildtools/log-deps.py | 43 ++++++++++++++++++++++++++++++++++++++++++
>  buildtools/meson.build |  2 ++
>  drivers/meson.build    |  1 +
>  lib/meson.build        |  1 +
>  5 files changed, 48 insertions(+)
>  create mode 100644 buildtools/log-deps.py
> 
> diff --git a/app/meson.build b/app/meson.build
> index 5b2c80c7a1..6afa457f4c 100644
> --- a/app/meson.build
> +++ b/app/meson.build
> @@ -76,6 +76,7 @@ foreach app:apps
>  
>      if build
>          subdir(name)
> +        run_command([log_deps_cmd, name, deps])
>          if not build and require_apps
>              error('Cannot build explicitly requested app "@0@".\n'.format(name)
>                    + '\tReason: ' + reason)
> diff --git a/buildtools/log-deps.py b/buildtools/log-deps.py
> new file mode 100644
> index 0000000000..a4331fa15b
> --- /dev/null
> +++ b/buildtools/log-deps.py
> @@ -0,0 +1,43 @@
> +#! /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
> +
> +
> +def file_to_list(filename):
> +    """Read file into a list of strings."""
> +    with open(filename) as f:
> +        return f.readlines()
> +
> +
> +def list_to_file(filename, lines):
> +    """Write a list of strings out to a file."""
> +    with open(filename, 'w') as f:
> +        f.writelines(lines)
> +
> +
> +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)
> +
> +try:
> +    contents = file_to_list(depsfile)
> +except FileNotFoundError:
> +    contents = ['digraph {\n', '}\n']
> +
> +component = sys.argv[1]
> +if len(sys.argv) > 2:
> +    contents[-1] = f'"{component}" -> {{ "{"\", \"".join(sys.argv[2:])}" }}\n'
> +else:
> +    contents[-1] = f'"{component}"\n'
> +
> +contents.append('}\n')
> +
> +list_to_file(depsfile, contents)
> diff --git a/buildtools/meson.build b/buildtools/meson.build
> index 3adf34e1a8..332f0f3d38 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)  # 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 66931d4241..44935e067c 100644
> --- a/drivers/meson.build
> +++ b/drivers/meson.build
> @@ -154,6 +154,7 @@ foreach subpath:subdirs
>          if build
>              # pull in driver directory which should update all the local variables
>              subdir(drv_path)
> +            run_command([log_deps_cmd, drv_path.underscorify(), deps])
>  
>              if dpdk_conf.get('RTE_IOVA_IN_MBUF') == 0 and require_iova_in_mbuf
>                  build = false
> diff --git a/lib/meson.build b/lib/meson.build
> index 162287753f..da2815465f 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -160,6 +160,7 @@ foreach l:libraries
>  
>      if build
>          subdir(l)
> +        run_command([log_deps_cmd, l, deps])
>          if not build and require_libs
>              error('Cannot build explicitly requested lib "@0@".\n'.format(name)
>                      +'\tReason: ' + reason)


  parent reply	other threads:[~2024-07-31 10:18 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30 14:55 Bruce Richardson
2024-07-31  9:07 ` Konstantin Ananyev
2024-07-31 10:17 ` Ferruh Yigit [this message]
2024-07-31 10:27   ` Bruce Richardson
2024-08-02 12:44 ` [PATCH v2 0/7] record and rework component dependencies Bruce Richardson
2024-08-02 12:44   ` [PATCH v2 1/7] build: output a dependency log in build directory Bruce Richardson
2024-09-02 14:34     ` Burakov, Anatoly
2024-09-03  8:31       ` Bruce Richardson
2024-08-02 12:44   ` [PATCH v2 2/7] devtools: add script to flag unneeded dependencies Bruce Richardson
2024-08-02 12:44   ` [PATCH v2 3/7] build: remove kvargs from driver class dependencies Bruce Richardson
2024-08-02 12:44   ` [PATCH v2 4/7] build: reduce library dependencies Bruce Richardson
2024-08-02 12:44   ` [PATCH v2 5/7] build: reduce driver dependencies Bruce Richardson
2024-08-02 12:44   ` [PATCH v2 6/7] build: reduce app dependencies Bruce Richardson
2024-08-02 12:44   ` [PATCH v2 7/7] devtools: add script to generate DPDK dependency graphs Bruce Richardson
2024-08-02 13:29   ` [PATCH v2 0/7] record and rework component dependencies Morten Brørup
2024-08-02 15:05   ` Patrick Robb
2024-08-02 15:11     ` Bruce Richardson
2024-08-02 17:18   ` Ferruh Yigit
2024-08-06  8:35     ` Bruce Richardson
2024-09-04 15:08 ` [PATCH v3 0/8] " Anatoly Burakov
2024-09-04 15:08   ` [PATCH v3 1/8] build: split dependencies into mandatory and optional Anatoly Burakov
2024-09-06 14:51     ` Bruce Richardson
2024-09-09  8:41       ` Burakov, Anatoly
2024-09-09  9:01         ` Bruce Richardson
2024-09-04 15:08   ` [PATCH v3 2/8] build: output a dependency log in build directory Anatoly Burakov
2024-09-04 15:08   ` [PATCH v3 3/8] devtools: add script to flag unneeded dependencies Anatoly Burakov
2024-09-04 15:08   ` [PATCH v3 4/8] build: remove kvargs from driver class dependencies Anatoly Burakov
2024-09-04 15:08   ` [PATCH v3 5/8] build: reduce library dependencies Anatoly Burakov
2024-09-04 15:08   ` [PATCH v3 6/8] build: reduce driver dependencies Anatoly Burakov
2024-09-04 15:08   ` [PATCH v3 7/8] build: reduce app dependencies Anatoly Burakov
2024-09-04 15:08   ` [PATCH v3 8/8] devtools: add script to generate DPDK dependency graphs Anatoly Burakov
2024-09-05  6:05   ` [PATCH v3 0/8] record and rework component dependencies Morten Brørup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3deb013-bb35-495b-a3ac-ebc1fd7764b5@amd.com \
    --to=ferruh.yigit@amd.com \
    --cc=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).