[v3] build: automatically report minimum meson version

Message ID 20250515134647.932537-1-bruce.richardson@intel.com (mailing list archive)
State Accepted
Delegated to: David Marchand
Headers
Series [v3] build: automatically report minimum meson version |

Checks

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

Commit Message

Bruce Richardson May 15, 2025, 1:46 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>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Patrick Robb <probb@iol.unh.edu>

---
v3: update minimum meson to 0.57.2 (from 0.57.0) to fix CI errors
v2: rebase to latest main
---
 .ci/linux-setup.sh                  |  6 +++++-
 buildtools/get-min-meson-version.py | 26 ++++++++++++++++++++++++++
 buildtools/meson.build              |  5 +++++
 meson.build                         |  2 +-
 4 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100755 buildtools/get-min-meson-version.py
  

Comments

David Marchand May 16, 2025, 7:33 a.m. UTC | #1
Hello Min Zhou,

On Thu, May 15, 2025 at 3:47 PM 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>
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>
> Reviewed-by: Patrick Robb <probb@iol.unh.edu>
>
> ---
> v3: update minimum meson to 0.57.2 (from 0.57.0) to fix CI errors
> v2: rebase to latest main

The LoongArch CI reported an error on this patch, but I can't find out
the reason:
https://mails.dpdk.org/archives/test-report/2025-May/877981.html

This is probably related to the meson version in the build env, since
this patch increases the minimum version to 0.57.2.

Can you have a look please?
  
zhoumin May 16, 2025, 11:28 a.m. UTC | #2
Hello David Marchand,

On Fri, May 16, 2025 at 3:33 PM, David Marchand wrote:

> Hello Min Zhou,
>
> On Thu, May 15, 2025 at 3:47 PM 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>
>> Acked-by: Stephen Hemminger <stephen@networkplumber.org>
>> Reviewed-by: Patrick Robb <probb@iol.unh.edu>
>>
>> ---
>> v3: update minimum meson to 0.57.2 (from 0.57.0) to fix CI errors
>> v2: rebase to latest main
> The LoongArch CI reported an error on this patch, but I can't find out
> the reason:
> https://mails.dpdk.org/archives/test-report/2025-May/877981.html
>
> This is probably related to the meson version in the build env, since
> this patch increases the minimum version to 0.57.2.
>
> Can you have a look please?
Sure. The reason for this error is related to the meson version in the 
build environment. I will update the version of meson and retest this 
patch.
>
  
zhoumin May 16, 2025, 11:32 a.m. UTC | #3
Recheck-request: loongarch-compilation
  
Thomas Monjalon June 9, 2025, 9:44 a.m. UTC | #4
15/05/2025 15:46, Bruce Richardson:
> 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>
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>
> Reviewed-by: Patrick Robb <probb@iol.unh.edu>

Applied, thanks.
  

Patch

diff --git a/.ci/linux-setup.sh b/.ci/linux-setup.sh
index 938d492cbb..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.57.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 1cd1ce02fd..cc0198081d 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -26,6 +26,11 @@  header_gen_cmd = py3 + files('gen-header.py')
 has_hugepages_cmd = py3 + files('has-hugepages.py')
 cmdline_gen_cmd = py3 + files('dpdk-cmdline-gen.py')
 check_dts_requirements = py3 + files('check-dts-requirements.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([
diff --git a/meson.build b/meson.build
index dfb4cb3aee..5ff68cb3af 100644
--- a/meson.build
+++ b/meson.build
@@ -10,7 +10,7 @@  project('DPDK', 'c',
             'default_library=static',
             'warning_level=2',
         ],
-        meson_version: '>= 0.57'
+        meson_version: '>= 0.57.2'
 )
 
 fs = import('fs')