mintro: Add version key to --scan-dependencies (fixes #6287)

pull/6328/head
Daniel Mensinger 5 years ago committed by Jussi Pakkanen
parent 38d3fbca94
commit fc800a2cb8
  1. 6
      docs/markdown/IDE-integration.md
  2. 3
      docs/markdown/snippets/introspect.md
  3. 7
      mesonbuild/ast/introspection.py
  4. 9
      mesonbuild/mintro.py
  5. 7
      run_unittests.py
  6. 5
      test cases/unit/57 introspection/meson.build

@ -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

@ -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

@ -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):

@ -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]]]]:

@ -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
}

@ -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')

Loading…
Cancel
Save