Skip to content

Improve version check implementation#15674

Draft
bonzini wants to merge 8 commits into
mesonbuild:masterfrom
bonzini:range-version
Draft

Improve version check implementation#15674
bonzini wants to merge 8 commits into
mesonbuild:masterfrom
bonzini:range-version

Conversation

@bonzini
Copy link
Copy Markdown
Contributor

@bonzini bonzini commented Apr 3, 2026

This introduces a Range class that makes it possible to track the current nesting of if meson.version().version_compare('...') conditionals. The new class also simplifies the implementation of version_compare_condition_with_min and of warning for redundant version checks.

bonzini added 5 commits April 3, 2026 14:29
Right now specifying 1.10.0 gives warnings like

meson.build:18: WARNING: Project targets '>1.10.0' but uses feature introduced in '1.10.0': meson.version().version_compare() with multiple arguments. From 1.8.0 - 1.9.* it failed to match str.version_compare

This is incorrect.  A project targeting 1.10.1 or later can use features
introduced by 1.10.0.  Fix the bug in version_compare_condition_with_min
and adjust the testcases.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Add a class that can be used to encode a range of versions.  It is
useful to express the project's minimum version and to reason on it,
for example to detect redundant Meson version checks.
version_compare_condition_with_min includes both parsing and
manipulation of the project's minimum version.

Simplify it version_compare_condition_with_min by first converting
the project(meson_version: ...) to a Range, and then operating
(not surprisingly) on its .min field.
An empty string does not really have an equivalent with Range;
change it to None in preparation for tracking the current
project version in a Range[Version]
@bonzini bonzini requested a review from jpakkane as a code owner April 3, 2026 12:34
@bonzini bonzini added this to the 1.12 milestone Apr 3, 2026
@bonzini bonzini marked this pull request as draft April 3, 2026 12:52
Parse it just once, ahead of time, and pass it to
version_compare_condition_with_min.

This gives, for free, support for multi-argument
meson.version().version_compare().

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
@bonzini bonzini force-pushed the range-version branch 3 times, most recently from 756fd40 to 6a121db Compare April 3, 2026 16:07
check if this is really necessary...
We might encounter a Meson version check that always evaluates to true
or to false:

    project('t', 'c', meson_version: '>=0.60.0')
    if meson.version().version_compare('>=0.55.0')
      v = 1
    endif
    if meson.version().version_compare('<0.60.0')
      v = 2
    endif

Print warnings in such cases.

Co-authored-by: Benjamin Gilbert <bgilbert@backtick.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant