aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-07-21 12:26:20 -0400
committerNirbheek Chauhan <nirbheek@centricular.com>2021-08-10 15:28:20 +0530
commit76b081a123e25d7d547248771864c14b9f2a8a38 (patch)
treec86bb343e56fcf7e769333205f5f03299c94131d
parent5fe6047b76c616c122fc6c308cad837a3b3f03a4 (diff)
downloadmeson-76b081a123e25d7d547248771864c14b9f2a8a38.zip
meson-76b081a123e25d7d547248771864c14b9f2a8a38.tar.gz
meson-76b081a123e25d7d547248771864c14b9f2a8a38.tar.bz2
Fix meson.version().version_compare() regression in subproject
-rw-r--r--mesonbuild/interpreter/dependencyfallbacks.py2
-rw-r--r--mesonbuild/interpreter/interpreter.py2
-rw-r--r--mesonbuild/interpreter/mesonmain.py2
-rw-r--r--mesonbuild/interpreterbase/baseobjects.py2
-rw-r--r--test cases/unit/82 meson version compare/meson.build2
-rw-r--r--test cases/unit/82 meson version compare/subprojects/foo/meson.build8
6 files changed, 14 insertions, 4 deletions
diff --git a/mesonbuild/interpreter/dependencyfallbacks.py b/mesonbuild/interpreter/dependencyfallbacks.py
index 019073c..2639e42 100644
--- a/mesonbuild/interpreter/dependencyfallbacks.py
+++ b/mesonbuild/interpreter/dependencyfallbacks.py
@@ -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
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index daef5fd..30d3c75 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -2794,4 +2794,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)
diff --git a/mesonbuild/interpreter/mesonmain.py b/mesonbuild/interpreter/mesonmain.py
index bea12e0..97a695b 100644
--- a/mesonbuild/interpreter/mesonmain.py
+++ b/mesonbuild/interpreter/mesonmain.py
@@ -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,
diff --git a/mesonbuild/interpreterbase/baseobjects.py b/mesonbuild/interpreterbase/baseobjects.py
index e65e4cb..8b1293c 100644
--- a/mesonbuild/interpreterbase/baseobjects.py
+++ b/mesonbuild/interpreterbase/baseobjects.py
@@ -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)
diff --git a/test cases/unit/82 meson version compare/meson.build b/test cases/unit/82 meson version compare/meson.build
index ed69a8b..4affe21 100644
--- a/test cases/unit/82 meson version compare/meson.build
+++ b/test cases/unit/82 meson version compare/meson.build
@@ -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')
diff --git a/test cases/unit/82 meson version compare/subprojects/foo/meson.build b/test cases/unit/82 meson version compare/subprojects/foo/meson.build
new file mode 100644
index 0000000..4c66b70
--- /dev/null
+++ b/test cases/unit/82 meson version compare/subprojects/foo/meson.build
@@ -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