[RFC] build: automatically report minimum meson version

Message ID 20241009152417.4028297-1-bruce.richardson@intel.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series [RFC] build: automatically report minimum meson version |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing pending Testing pending
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing pending Testing pending
ci/iol-sample-apps-testing warning Testing issues

Commit Message

Bruce Richardson Oct. 9, 2024, 3:24 p.m. UTC
Add a script to buildtools to report the minimum meson version given in
our meson.build file. Then use this script in two ways:

1. in the .ci/linux-setup.sh script, use the auto-determined minimum
   version to set up the CI, rather than hard-coding it.
2. in meson.build call the script to report the version. This serves as
   a sanity check to ensure that any changes to meson.build file do not
   break the script.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 .ci/linux-setup.sh                  |  6 +++++-
 buildtools/get-min-meson-version.py | 26 ++++++++++++++++++++++++++
 buildtools/meson.build              |  5 +++++
 3 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100755 buildtools/get-min-meson-version.py
  

Comments

Stephen Hemminger Oct. 9, 2024, 4:40 p.m. UTC | #1
On Wed,  9 Oct 2024 16:24:01 +0100
Bruce Richardson <bruce.richardson@intel.com> wrote:

> Add a script to buildtools to report the minimum meson version given in
> our meson.build file. Then use this script in two ways:
> 
> 1. in the .ci/linux-setup.sh script, use the auto-determined minimum
>    version to set up the CI, rather than hard-coding it.
> 2. in meson.build call the script to report the version. This serves as
>    a sanity check to ensure that any changes to meson.build file do not
>    break the script.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

Make sense, kind of annoying that it requires so many lines to do this
but very understandable.

Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  
Patrick Robb Oct. 14, 2024, 4:31 p.m. UTC | #2
It seems like a good addition that meson.build and /.ci/linux-setup.sh are
automatically in sync now. That's one less thing that someone has to "just
remember" when increasing the meson minimum version.

I will flag on the other thread (increasing the meson version) when UNH's
scripts are updated to always run linux-setup.sh ahead of each testrun.

Reviewed-by: Patrick Robb <probb@iol.unh.edu>

On Wed, Oct 9, 2024 at 11:24 AM Bruce Richardson <bruce.richardson@intel.com>
wrote:

> Add a script to buildtools to report the minimum meson version given in
> our meson.build file. Then use this script in two ways:
>
> 1. in the .ci/linux-setup.sh script, use the auto-determined minimum
>    version to set up the CI, rather than hard-coding it.
> 2. in meson.build call the script to report the version. This serves as
>    a sanity check to ensure that any changes to meson.build file do not
>    break the script.
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  .ci/linux-setup.sh                  |  6 +++++-
>  buildtools/get-min-meson-version.py | 26 ++++++++++++++++++++++++++
>  buildtools/meson.build              |  5 +++++
>  3 files changed, 36 insertions(+), 1 deletion(-)
>  create mode 100755 buildtools/get-min-meson-version.py
>
> diff --git a/.ci/linux-setup.sh b/.ci/linux-setup.sh
> index 975bf32144..e025ca0243 100755
> --- a/.ci/linux-setup.sh
> +++ b/.ci/linux-setup.sh
> @@ -3,8 +3,12 @@
>  # Builds are run as root in containers, no need for sudo
>  [ "$(id -u)" != '0' ] || alias sudo=
>
> +# determine minimum meson version
> +ci_dir=$(dirname $(readlink -f $0))
> +meson_ver=$(python3 $ci_dir/../buildtools/get-min-meson-version.py)
> +
>  # need to install as 'root' since some of the unit tests won't run
> without it
> -sudo python3 -m pip install --upgrade 'meson==0.53.2'
> +sudo python3 -m pip install --upgrade "meson==$meson_ver"
>
>  # setup hugepages. error ignored because having hugepage is not mandatory.
>  cat /proc/meminfo
> diff --git a/buildtools/get-min-meson-version.py
> b/buildtools/get-min-meson-version.py
> new file mode 100755
> index 0000000000..f0de8fdf2b
> --- /dev/null
> +++ b/buildtools/get-min-meson-version.py
> @@ -0,0 +1,26 @@
> +#! /usr/bin/env python3
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright(c) 2024 Intel Corporation
> +
> +import os
> +import re
> +import sys
> +from os.path import dirname, realpath, join
> +
> +buildtools_path = dirname(realpath(__file__))
> +basedir = dirname(buildtools_path)
> +
> +with open(join(basedir, "meson.build")) as f:
> +    for ln in f.readlines():
> +        if "meson_version" not in ln:
> +            continue
> +
> +        ln = ln.strip()
> +        ver_match = re.search(r"meson_version:\s*'>=\s*([0-9\.]+)'", ln)
> +        if not ver_match:
> +            print(
> +                f"Meson version specifier not in recognised format:
> '{ln}'",
> +                file=sys.stderr,
> +            )
> +            sys.exit(1)
> +        print(ver_match.group(1), end="")
> diff --git a/buildtools/meson.build b/buildtools/meson.build
> index 3adf34e1a8..8b20ac0dd0 100644
> --- a/buildtools/meson.build
> +++ b/buildtools/meson.build
> @@ -24,6 +24,11 @@ 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')
> +get_min_meson_version_cmd = py3 + files('get-min-meson-version.py')
> +
> +# check that we can correctly report minimum meson version
> +min_ver = run_command(get_min_meson_version_cmd, check: true, capture:
> true)
> +message('Minimum meson required version is ' + min_ver.stdout())
>
>  # install any build tools that end-users might want also
>  install_data([
> --
> 2.43.0
>
>
  

Patch

diff --git a/.ci/linux-setup.sh b/.ci/linux-setup.sh
index 975bf32144..e025ca0243 100755
--- a/.ci/linux-setup.sh
+++ b/.ci/linux-setup.sh
@@ -3,8 +3,12 @@ 
 # Builds are run as root in containers, no need for sudo
 [ "$(id -u)" != '0' ] || alias sudo=
 
+# determine minimum meson version
+ci_dir=$(dirname $(readlink -f $0))
+meson_ver=$(python3 $ci_dir/../buildtools/get-min-meson-version.py)
+
 # need to install as 'root' since some of the unit tests won't run without it
-sudo python3 -m pip install --upgrade 'meson==0.53.2'
+sudo python3 -m pip install --upgrade "meson==$meson_ver"
 
 # setup hugepages. error ignored because having hugepage is not mandatory.
 cat /proc/meminfo
diff --git a/buildtools/get-min-meson-version.py b/buildtools/get-min-meson-version.py
new file mode 100755
index 0000000000..f0de8fdf2b
--- /dev/null
+++ b/buildtools/get-min-meson-version.py
@@ -0,0 +1,26 @@ 
+#! /usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 Intel Corporation
+
+import os
+import re
+import sys
+from os.path import dirname, realpath, join
+
+buildtools_path = dirname(realpath(__file__))
+basedir = dirname(buildtools_path)
+
+with open(join(basedir, "meson.build")) as f:
+    for ln in f.readlines():
+        if "meson_version" not in ln:
+            continue
+
+        ln = ln.strip()
+        ver_match = re.search(r"meson_version:\s*'>=\s*([0-9\.]+)'", ln)
+        if not ver_match:
+            print(
+                f"Meson version specifier not in recognised format: '{ln}'",
+                file=sys.stderr,
+            )
+            sys.exit(1)
+        print(ver_match.group(1), end="")
diff --git a/buildtools/meson.build b/buildtools/meson.build
index 3adf34e1a8..8b20ac0dd0 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -24,6 +24,11 @@  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')
+get_min_meson_version_cmd = py3 + files('get-min-meson-version.py')
+
+# check that we can correctly report minimum meson version
+min_ver = run_command(get_min_meson_version_cmd, check: true, capture: true)
+message('Minimum meson required version is ' + min_ver.stdout())
 
 # install any build tools that end-users might want also
 install_data([