Improve version check implementation#15674
Draft
bonzini wants to merge 8 commits into
Draft
Conversation
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]
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>
756fd40 to
6a121db
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ofversion_compare_condition_with_minand of warning for redundant version checks.