Fix meson.version().version_compare() regression in subproject

pull/9011/head
Xavier Claessens 3 years ago
parent 9afd589c8b
commit 0183954ea1
  1. 2
      mesonbuild/interpreter/dependencyfallbacks.py
  2. 2
      mesonbuild/interpreter/interpreter.py
  3. 2
      mesonbuild/interpreter/mesonmain.py
  4. 2
      mesonbuild/interpreterbase/baseobjects.py
  5. 2
      test cases/unit/82 meson version compare/meson.build
  6. 8
      test cases/unit/82 meson version compare/subprojects/foo/meson.build

@ -17,7 +17,7 @@ if T.TYPE_CHECKING:
class DependencyFallbacksHolder(MesonInterpreterObject):
def __init__(self, interpreter: 'Interpreter', names: T.List[str], allow_fallback: T.Optional[bool] = None) -> None:
super().__init__()
super().__init__(subproject=interpreter.subproject)
self.interpreter = interpreter
self.subproject = interpreter.subproject
self.coredata = interpreter.coredata

@ -2759,4 +2759,4 @@ This will become a hard error in the future.''', location=self.current_node)
raise InterpreterException('stop cannot be less than start')
if step < 1:
raise InterpreterException('step must be >=1')
return RangeHolder(start, stop, step)
return RangeHolder(start, stop, step, subproject=self.subproject)

@ -22,7 +22,7 @@ if T.TYPE_CHECKING:
class MesonMain(MesonInterpreterObject):
def __init__(self, build: 'build.Build', interpreter: 'Interpreter'):
super().__init__()
super().__init__(subproject=interpreter.subproject)
self.build = build
self.interpreter = interpreter
self.methods.update({'get_compiler': self.get_compiler_method,

@ -82,7 +82,7 @@ class ObjectHolder(InterpreterObject, T.Generic[InterpreterObjectTypeVar]):
return f'<[{type(self).__name__}] holds [{type(self.held_object).__name__}]: {self.held_object!r}>'
class RangeHolder(MesonInterpreterObject):
def __init__(self, start: int, stop: int, step: int, *, subproject: T.Optional[str] = None) -> None:
def __init__(self, start: int, stop: int, step: int, *, subproject: str) -> None:
super().__init__(subproject=subproject)
self.range = range(start, stop, step)

@ -15,3 +15,5 @@ endif
# This will error out if elif cause did not enter
assert(foo_dep.found(), 'meson.version_compare did not work')
subproject('foo')

@ -0,0 +1,8 @@
project('foo', meson_version: '>= 0.1')
if meson.version().version_compare('>= 0.55')
# This Should not produce warning even when using function not available in
# meson 0.1.
foo_dep = declare_dependency()
meson.override_dependency('foo2', foo_dep)
endif
Loading…
Cancel
Save