mintro: Added `defined_in` key in the targets introspection

pull/4780/head
Daniel Mensinger 6 years ago committed by Jussi Pakkanen
parent fff88b354a
commit 609ecba37f
  1. 1
      docs/markdown/IDE-integration.md
  2. 1
      docs/markdown/snippets/introspect_multiple.md
  3. 2
      mesonbuild/mintro.py
  4. 12
      run_unittests.py

@ -53,6 +53,7 @@ for one target is defined as follows:
"name": "Name of the target",
"id": "The internal ID meson uses",
"type": "<TYPE>",
"defined_in": "/Path/to/the/targets/meson.build",
"filename": ["list", "of", "generated", "files"],
"build_by_default": true / false,
"target_sources": [],

@ -19,4 +19,5 @@ configuration of the build directory.
Additionlly the format of `meson introspect target` was changed:
- New: the `sources` key. It stores the source files of a target and their compiler parameters.
- New: the `defined_in` key. It stores the meson file where a target is defined
- Added new target types (`jar`, `shared module`).

@ -121,6 +121,7 @@ def list_installed(installdata):
def list_targets(builddata: build.Build, installdata, backend: backends.Backend):
tlist = []
build_dir = builddata.environment.get_build_dir()
src_dir = builddata.environment.get_source_dir()
# Fast lookup table for installation files
install_lookuptable = {}
@ -136,6 +137,7 @@ def list_targets(builddata: build.Build, installdata, backend: backends.Backend)
'name': target.get_basename(),
'id': idname,
'type': target.get_typename(),
'defined_in': os.path.normpath(os.path.join(src_dir, target.subdir, 'meson.build')),
'filename': [os.path.join(build_dir, target.subdir, x) for x in target.get_outputs()],
'build_by_default': target.build_by_default,
'target_sources': backend.get_introspection_data(idname, target)

@ -3172,6 +3172,7 @@ recommended as it is not supported on some platforms''')
('name', str),
('id', str),
('type', str),
('defined_in', str),
('filename', list),
('build_by_default', bool),
('target_sources', list),
@ -3240,11 +3241,11 @@ recommended as it is not supported on some platforms''')
# Check targets
targets_to_find = {
'sharedTestLib': ('shared library', True, False),
'staticTestLib': ('static library', True, False),
'test1': ('executable', True, True),
'test2': ('executable', True, False),
'test3': ('executable', True, False),
'sharedTestLib': ('shared library', True, False, 'sharedlib/meson.build'),
'staticTestLib': ('static library', True, False, 'staticlib/meson.build'),
'test1': ('executable', True, True, 'meson.build'),
'test2': ('executable', True, False, 'meson.build'),
'test3': ('executable', True, False, 'meson.build'),
}
for i in res['targets']:
assertKeyTypes(targets_typelist, i)
@ -3253,6 +3254,7 @@ recommended as it is not supported on some platforms''')
self.assertEqual(i['type'], tgt[0])
self.assertEqual(i['build_by_default'], tgt[1])
self.assertEqual(i['installed'], tgt[2])
self.assertPathEqual(i['defined_in'], os.path.join(testdir, tgt[3]))
targets_to_find.pop(i['name'], None)
for j in i['target_sources']:
assertKeyTypes(targets_sources_typelist, j)

Loading…
Cancel
Save