diff options
-rw-r--r-- | docs/markdown/IDE-integration.md | 6 | ||||
-rw-r--r-- | docs/markdown/snippets/introspect.md | 3 | ||||
-rw-r--r-- | mesonbuild/ast/introspection.py | 7 | ||||
-rw-r--r-- | mesonbuild/mintro.py | 9 | ||||
-rwxr-xr-x | run_unittests.py | 7 | ||||
-rw-r--r-- | test cases/unit/57 introspection/meson.build | 5 |
6 files changed, 31 insertions, 6 deletions
diff --git a/docs/markdown/IDE-integration.md b/docs/markdown/IDE-integration.md index 88043d3..1c66d53 100644 --- a/docs/markdown/IDE-integration.md +++ b/docs/markdown/IDE-integration.md @@ -207,6 +207,7 @@ The output format is as follows: { "name": "The name of the dependency", "required": true, + "version": [">=1.2.3"], "conditional": false, "has_fallback": false } @@ -219,7 +220,10 @@ in the `meson.build` (all dependencies are required by default). The inside a conditional block. In a real meson run these dependencies might not be used, thus they _may_ not be required, even if the `required` key is set. The `has_fallback` key just indicates whether a fallback was directly set in the -`dependency()` function. +`dependency()` function. The `version` key always contains a list of version +requirements from the `meson.build` and **not** the actual version of the +dependency on disc. The version list is empty if no version was specified +in the `meson.build`. ## Tests diff --git a/docs/markdown/snippets/introspect.md b/docs/markdown/snippets/introspect.md index 4d9fab2..097fd17 100644 --- a/docs/markdown/snippets/introspect.md +++ b/docs/markdown/snippets/introspect.md @@ -2,3 +2,6 @@ dependencies (--dependencies, intro-dependencies.json): - added the `version` key + +scanning dependencies (--scan-dependencies): +- added the `version` key containing the required dependency version diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py index eb9517c..709dbac 100644 --- a/mesonbuild/ast/introspection.py +++ b/mesonbuild/ast/introspection.py @@ -136,11 +136,15 @@ class IntrospectionInterpreter(AstInterpreter): def func_dependency(self, node, args, kwargs): args = self.flatten_args(args) + kwargs = self.flatten_kwargs(kwargs) if not args: return name = args[0] has_fallback = 'fallback' in kwargs required = kwargs.get('required', True) + version = kwargs.get('version', []) + if not isinstance(version, list): + version = [version] condition_level = node.condition_level if hasattr(node, 'condition_level') else 0 if isinstance(required, ElementaryNode): required = required.value @@ -149,9 +153,10 @@ class IntrospectionInterpreter(AstInterpreter): self.dependencies += [{ 'name': name, 'required': required, + 'version': version, 'has_fallback': has_fallback, 'conditional': condition_level > 0, - 'node': node + 'node': node, }] def build_target(self, node, args, kwargs, targetclass): diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 5e7bebf..1c9c542 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -263,7 +263,14 @@ def list_buildsystem_files(builddata: build.Build) -> List[str]: def list_deps_from_source(intr: IntrospectionInterpreter) -> List[Dict[str, Union[str, bool]]]: result = [] # type: List[Dict[str, Union[str, bool]]] for i in intr.dependencies: - result += [{k: v for k, v in i.items() if k in ['name', 'required', 'has_fallback', 'conditional']}] + keys = [ + 'name', + 'required', + 'version', + 'has_fallback', + 'conditional', + ] + result += [{k: v for k, v in i.items() if k in keys}] return result def list_deps(coredata: cdata.CoreData) -> List[Dict[str, Union[str, List[str]]]]: diff --git a/run_unittests.py b/run_unittests.py index b0668aa..770d236 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -4063,30 +4063,35 @@ recommended as it is not supported on some platforms''') { 'name': 'threads', 'required': True, + 'version': [], 'has_fallback': False, 'conditional': False }, { 'name': 'zlib', 'required': False, + 'version': [], 'has_fallback': False, 'conditional': False }, { 'name': 'bugDep1', - 'required': False, + 'required': True, + 'version': [], 'has_fallback': False, 'conditional': False }, { 'name': 'somethingthatdoesnotexist', 'required': True, + 'version': ['>=1.2.3'], 'has_fallback': False, 'conditional': True }, { 'name': 'look_i_have_a_fallback', 'required': True, + 'version': ['>=1.0.0', '<=99.9.9'], 'has_fallback': True, 'conditional': True } diff --git a/test cases/unit/57 introspection/meson.build b/test cases/unit/57 introspection/meson.build index 7589f3f..a094a55 100644 --- a/test cases/unit/57 introspection/meson.build +++ b/test cases/unit/57 introspection/meson.build @@ -13,8 +13,9 @@ set_variable('list_test_plusassign', []) list_test_plusassign += ['bugs everywhere'] if false - dependency('somethingthatdoesnotexist', required: true) - dependency('look_i_have_a_fallback', fallback: ['oh_no', 'the_subproject_does_not_exist']) + vers_str = '<=99.9.9' + dependency('somethingthatdoesnotexist', required: true, version: '>=1.2.3') + dependency('look_i_have_a_fallback', version: ['>=1.0.0', vers_str], fallback: ['oh_no', 'the_subproject_does_not_exist']) endif subdir('sharedlib') |